From 78db2e0ccd8d9ce62e689ee78471ff2807744ee7 Mon Sep 17 00:00:00 2001 From: Pranav <122373207+pranavkonidena@users.noreply.github.com> Date: Sat, 23 Mar 2024 17:34:43 +0530 Subject: [PATCH 1/8] Dockerized NoticeBoard --- .devcontainer/devcontainer.json | 27 +++++++++++++++++++++ Dockerfile | 42 +++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 .devcontainer/devcontainer.json create mode 100644 Dockerfile diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..374f20e --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,27 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile +{ + "name": "Existing Dockerfile", + "build": { + // Sets the run context to one level up instead of the .devcontainer folder. + "context": "..", + // Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename. + "dockerfile": "../Dockerfile" + }, + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [5037], + + // Uncomment the next line to run commands after the container is created. + // "postCreateCommand": "cat /etc/os-release", + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "devcontainer" + "dockerRun": {"network": "host", "runArgs": ["--privileged"]} +} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6c6de33 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +FROM ubuntu:22.04 + +# Prerequisites +RUN apt update && apt install -y curl git unzip xz-utils zip libglu1-mesa openjdk-8-jdk wget adb libjaxb-api-java + +# Set up new user +RUN useradd -ms /bin/bash developer +WORKDIR /home/developer + +# Prepare Android directories and system variables +RUN cd /home/developer +RUN mkdir -p Android/sdk +ENV ANDROID_SDK_ROOT /home/developer/Android/sdk +RUN mkdir -p .android && touch .android/repositories.cfg + +# # Set up Android SDK +RUN wget -O sdk-tools.zip https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip +RUN unzip sdk-tools.zip && rm sdk-tools.zip +RUN cd /home/developer +RUN mv tools Android/sdk/tools +RUN cd Android/sdk/tools/bin && yes | ./sdkmanager --licenses +RUN cd /home/developer +RUN cd Android/sdk/tools/bin && touch /root/.android/repositories.cfg && ./sdkmanager "build-tools;29.0.2" "platform-tools" "platforms;android-29" "sources;android-29" "cmdline-tools;latest" +ENV PATH "$PATH:/home/developer/Android/sdk/platform-tools" +RUN cd /home/developer + +# Download Flutter SDK +RUN wget https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.19.1-stable.tar.xz +RUN tar -xvf flutter_linux_3.19.1-stable.tar.xz +RUN git config --global --add safe.directory /home/developer/flutter +WORKDIR /home/developer +ENV PATH "$PATH:/home/developer/flutter/bin" + +# Run basic check to download Dark SDK +RUN flutter doctor +RUN apt install -y openjdk-17-jdk +RUN flutter doctor --android-licenses +RUN flutter doctor +RUN cd /workspaces/noticeboard-mobile-app/noticeboard +RUN flutter pub get +WORKDIR /workspaces/noticeboard-mobile-app +USER developer From 166b4bc0bffd91f081a9cea26e412a45003bb704 Mon Sep 17 00:00:00 2001 From: Pranav <122373207+pranavkonidena@users.noreply.github.com> Date: Sat, 23 Mar 2024 17:44:39 +0530 Subject: [PATCH 2/8] Added comments in Dockerfile --- Dockerfile | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6c6de33..5a082af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ +# Use ubuntu 22.04 LTS as Base Image FROM ubuntu:22.04 -# Prerequisites +# This sets up java and git in the container RUN apt update && apt install -y curl git unzip xz-utils zip libglu1-mesa openjdk-8-jdk wget adb libjaxb-api-java # Set up new user @@ -13,7 +14,7 @@ RUN mkdir -p Android/sdk ENV ANDROID_SDK_ROOT /home/developer/Android/sdk RUN mkdir -p .android && touch .android/repositories.cfg -# # Set up Android SDK +# Set up Android SDK and accept licenses RUN wget -O sdk-tools.zip https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip RUN unzip sdk-tools.zip && rm sdk-tools.zip RUN cd /home/developer @@ -22,9 +23,9 @@ RUN cd Android/sdk/tools/bin && yes | ./sdkmanager --licenses RUN cd /home/developer RUN cd Android/sdk/tools/bin && touch /root/.android/repositories.cfg && ./sdkmanager "build-tools;29.0.2" "platform-tools" "platforms;android-29" "sources;android-29" "cmdline-tools;latest" ENV PATH "$PATH:/home/developer/Android/sdk/platform-tools" -RUN cd /home/developer -# Download Flutter SDK +# Download Flutter SDK and add flutter to path +RUN cd /home/developer RUN wget https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.19.1-stable.tar.xz RUN tar -xvf flutter_linux_3.19.1-stable.tar.xz RUN git config --global --add safe.directory /home/developer/flutter @@ -33,10 +34,22 @@ ENV PATH "$PATH:/home/developer/flutter/bin" # Run basic check to download Dark SDK RUN flutter doctor + +# Install JavaDevelopment Kit RUN apt install -y openjdk-17-jdk + +# Accept all Android-SDK licenses RUN flutter doctor --android-licenses + +# Verify android toolchain is set up for development RUN flutter doctor + +# Go to noticeboard-mobile directory RUN cd /workspaces/noticeboard-mobile-app/noticeboard + +# Install dependencies RUN flutter pub get + +# Set up work directory and current user in container WORKDIR /workspaces/noticeboard-mobile-app USER developer From 58f889fc4863fb75304d2ff9cc90668cf2a42ea5 Mon Sep 17 00:00:00 2001 From: Pranav <122373207+pranavkonidena@users.noreply.github.com> Date: Sat, 23 Mar 2024 17:55:56 +0530 Subject: [PATCH 3/8] Recitified Android SDK version --- noticeboard/android/app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noticeboard/android/app/build.gradle b/noticeboard/android/app/build.gradle index 6636fc1..45c397f 100644 --- a/noticeboard/android/app/build.gradle +++ b/noticeboard/android/app/build.gradle @@ -33,7 +33,7 @@ if (keystorePropertiesFile.exists()) { } android { - compileSdkVersion 33 + compileSdkVersion 34 sourceSets { main.java.srcDirs += 'src/main/kotlin' From 4073c88eafd24575d659d5461c8b103be5c536d3 Mon Sep 17 00:00:00 2001 From: Pranav <122373207+pranavkonidena@users.noreply.github.com> Date: Sat, 23 Mar 2024 20:01:11 +0530 Subject: [PATCH 4/8] Fix breaking changes --- noticeboard/android/app/build.gradle | 72 ++++++++----------- .../noticeboard/MainActivity.kt | 0 noticeboard/android/build.gradle | 14 ---- .../gradle/wrapper/gradle-wrapper.properties | 2 +- noticeboard/android/settings.gradle | 31 +++++--- 5 files changed, 54 insertions(+), 65 deletions(-) rename noticeboard/android/app/src/main/kotlin/com/{example => img}/noticeboard/MainActivity.kt (100%) diff --git a/noticeboard/android/app/build.gradle b/noticeboard/android/app/build.gradle index 45c397f..6cff323 100644 --- a/noticeboard/android/app/build.gradle +++ b/noticeboard/android/app/build.gradle @@ -1,3 +1,9 @@ +plugins { + id "com.android.application" + id "kotlin-android" + id "dev.flutter.flutter-gradle-plugin" +} + def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { @@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) { } } -def flutterRoot = localProperties.getProperty('flutter.sdk') -if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") -} - def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' @@ -21,59 +22,46 @@ if (flutterVersionName == null) { flutterVersionName = '1.0' } -apply plugin: 'com.android.application' -apply plugin: 'com.google.gms.google-services' -apply plugin: 'kotlin-android' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" +android { + namespace 'com.img.noticeboard' + compileSdk 34 + ndkVersion flutter.ndkVersion -def keystoreProperties = new Properties() -def keystorePropertiesFile = rootProject.file('key.properties') -if (keystorePropertiesFile.exists()) { - keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) -} + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } -android { - compileSdkVersion 34 + kotlinOptions { + jvmTarget = '1.8' + } sourceSets { main.java.srcDirs += 'src/main/kotlin' } - lintOptions { - disable 'InvalidPackage' - } - defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.img.noticeboard" - minSdkVersion 19 - targetSdkVersion 31 + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. + minSdkVersion 21 + targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName } - signingConfigs { - release { - keyAlias keystoreProperties['keyAlias'] - keyPassword keystoreProperties['keyPassword'] - storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null - storePassword keystoreProperties['storePassword'] - } - } - - buildTypes { - release { - signingConfig signingConfigs.release - } - } - + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } } flutter { source '../..' } -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation platform('com.google.firebase:firebase-bom:29.0.3') - implementation 'com.google.firebase:firebase-analytics' -} +dependencies {} \ No newline at end of file diff --git a/noticeboard/android/app/src/main/kotlin/com/example/noticeboard/MainActivity.kt b/noticeboard/android/app/src/main/kotlin/com/img/noticeboard/MainActivity.kt similarity index 100% rename from noticeboard/android/app/src/main/kotlin/com/example/noticeboard/MainActivity.kt rename to noticeboard/android/app/src/main/kotlin/com/img/noticeboard/MainActivity.kt diff --git a/noticeboard/android/build.gradle b/noticeboard/android/build.gradle index 2c56939..5869be3 100644 --- a/noticeboard/android/build.gradle +++ b/noticeboard/android/build.gradle @@ -1,17 +1,3 @@ -buildscript { - ext.kotlin_version = '1.9.23' - repositories { - google() - jcenter() - } - - dependencies { - classpath 'com.android.tools.build:gradle:7.3.0' - classpath 'com.google.gms:google-services:4.3.14' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - allprojects { repositories { google() diff --git a/noticeboard/android/gradle/wrapper/gradle-wrapper.properties b/noticeboard/android/gradle/wrapper/gradle-wrapper.properties index 6b66533..89e56bd 100644 --- a/noticeboard/android/gradle/wrapper/gradle-wrapper.properties +++ b/noticeboard/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip diff --git a/noticeboard/android/settings.gradle b/noticeboard/android/settings.gradle index 44e62bc..3613de8 100644 --- a/noticeboard/android/settings.gradle +++ b/noticeboard/android/settings.gradle @@ -1,11 +1,26 @@ -include ':app' +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + }() -def localPropertiesFile = new File(rootProject.projectDir, "local.properties") -def properties = new Properties() + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") -assert localPropertiesFile.exists() -localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} -def flutterSdkPath = properties.getProperty("flutter.sdk") -assert flutterSdkPath != null, "flutter.sdk not set in local.properties" -apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version "7.3.0" apply false + id "com.google.gms.google-services" version "4.3.14" apply false + id "org.jetbrains.kotlin.android" version "1.9.23" apply false +} + +include ":app" From 19fad49e50f751a110eeb7c8125a25a1b8ecb253 Mon Sep 17 00:00:00 2001 From: Pranav <122373207+pranavkonidena@users.noreply.github.com> Date: Sat, 23 Mar 2024 22:20:57 +0530 Subject: [PATCH 5/8] Fix dockerfile --- .devcontainer/devcontainer.json | 4 ++-- Dockerfile | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 374f20e..3344e69 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,7 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the // README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile { - "name": "Existing Dockerfile", + "name": "Noticeboard Docker File", "build": { // Sets the run context to one level up instead of the .devcontainer folder. "context": "..", @@ -23,5 +23,5 @@ // Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root. // "remoteUser": "devcontainer" - "dockerRun": {"network": "host", "runArgs": ["--privileged"]} + "dockerRun": {"runArgs": ["--privileged"]} } diff --git a/Dockerfile b/Dockerfile index 5a082af..58c77bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # Use ubuntu 22.04 LTS as Base Image FROM ubuntu:22.04 -# This sets up java and git in the container +# This sets up java in the container RUN apt update && apt install -y curl git unzip xz-utils zip libglu1-mesa openjdk-8-jdk wget adb libjaxb-api-java # Set up new user @@ -42,14 +42,14 @@ RUN apt install -y openjdk-17-jdk RUN flutter doctor --android-licenses # Verify android toolchain is set up for development -RUN flutter doctor +RUN flutter doctor -v # Go to noticeboard-mobile directory -RUN cd /workspaces/noticeboard-mobile-app/noticeboard +WORKDIR /workspaces/noticeboard-mobile-app/noticeboard + # Install dependencies -RUN flutter pub get +CMD [ "flutter" "pub" "get" ] + + -# Set up work directory and current user in container -WORKDIR /workspaces/noticeboard-mobile-app -USER developer From 9db50c31dd07a166add8600f38257c3b9deb0ce8 Mon Sep 17 00:00:00 2001 From: Pranav <122373207+pranavkonidena@users.noreply.github.com> Date: Sat, 23 Mar 2024 22:31:42 +0530 Subject: [PATCH 6/8] Update README.md --- README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/README.md b/README.md index efd66c8..0d7ee1b 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,48 @@ The official digital noticeboard of IITR. Provides easy access to the Channel i - Bookmark notices on the go! - Now after many demands from the iPhone users, noticeboard finally comes on the app store! +## Development Setup + +### Prerequisites +- Visual Studio Code +- Docker +- Android phone with USB debugging enabled + +### Installing VS Code Dev Container Extension +1. Open Visual Studio Code. +2. Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window or by pressing Ctrl+Shift+X. +3. Search for "Remote - Containers" and click Install. + +### Opening the Project in a Dev Container +1. Clone the project repository. +2. Open the project folder in Visual Studio Code. +3. Press Cmd+Shift+P on Mac or Ctrl+Shift+P on Ubuntu/Windows to open the Command Palette. +4. Search for "Remote-Containers: Open Folder in Container" and select it. +5. Wait for the container to build (this may take some time, especially the first time). + +### Setting up Android Phone for Debugging +1. Ensure your phone and PC are connected to the same Wi-Fi network. +2. Enable USB debugging on your phone: + - Go to Settings > About phone > Software information. + - Tap "Build number" seven times to enable Developer options. + - Go back to the main Settings screen, and now you should see "Developer options". + - Open Developer options and enable USB debugging. +3. Enable wireless debugging on your phone: + - Connect your phone to your computer via USB cable. + - Run `adb usb` from inside the dev container. + - Run `adb tcpip 5037` from inside the dev container. + - Run `adb connect :5037` from inside the dev container. + - Disconnect the USB cable. + - Run `flutter run` + +### Running the App on Your Android Phone +1. After connecting your phone, wait for the app to build (this may take up to 15 minutes for the first build). +2. Once the build is complete, the app will be launched on your phone. +3. You can now make changes to the app and view updates in real-time on your phone. + +Please replace `` with the actual IP address of your phone. If you encounter any issues with the connection, try running `adb connect :5555` instead. + + ## Privacy Policy Link to privacy policy: https://docs.google.com/document/d/1vsbooZi9PIiVIMaLts2wv0tODEJafCaRT41zsENYN3I/edit From 40e408f33814f0418fb50da1ce73c1237673abd8 Mon Sep 17 00:00:00 2001 From: Pranav <122373207+pranavkonidena@users.noreply.github.com> Date: Sat, 23 Mar 2024 22:47:19 +0530 Subject: [PATCH 7/8] Update workflow.yml --- .github/workflows/workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 4962127..c1337da 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -44,4 +44,4 @@ jobs: - uses: actions/upload-artifact@v3 with: name: NoticeBoard - path: build/app/outputs/apk/release/NoticeBoardApp.apk + path: build/app/outputs/flutter-apk/app-release.apk From 8846a5674d09e4dfaafd6ccd12b27f8ed69de016 Mon Sep 17 00:00:00 2001 From: Pranav <122373207+pranavkonidena@users.noreply.github.com> Date: Sat, 23 Mar 2024 22:47:32 +0530 Subject: [PATCH 8/8] Update release.yml --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6399bcd..228bb81 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -44,4 +44,4 @@ jobs: - uses: actions/upload-artifact@v3 with: name: NoticeBoard - path: build/app/outputs/apk/release/NoticeBoardApp.apk + path: build/app/outputs/flutter-apk/app-release.apk