Skip to content

Commit

Permalink
[Mobile App] 989: Update Flutter SDK and packages, Xcode, Android Gra…
Browse files Browse the repository at this point in the history
…dle (#991)

* Update to Flutter SDK 3.27.1

* Update Firebase Flutter packages

- Update Android minimum version from 21 to 23
- Update iOS minimum version from iOS 12 to iOS 13

* Update remaining flutter packages to latest possible version

* Upgrade Android Gradle to be compatible to Android Studio LadyBug with Java JDK 21 instead of JDK17

* Flutter analyse fix: Don't use 'BuildContext's across async gaps.

Try rewriting the code to not use the 'BuildContext', or guard the use with a 'mounted' check.

* Prettified Code!

* Only add comments

* Remove not used FlutterFire CLI file

* Update README.md

* Update codemagic.yaml to tools upgrade

* Update build_number

* Prettified Code!

* Use Java 21

* clean artifact to upload to CodeMagic build

* increment build number

* correct apk path to avoid uploading two apks

* Update recipients_app/ios/Flutter/AppFrameworkInfo.plist to use iOS 13.0 to maintain consistency across configuration files.

* Remove TODO
  • Loading branch information
KarinBerg authored Jan 27, 2025
1 parent 54f4eaf commit b0a8fa8
Show file tree
Hide file tree
Showing 31 changed files with 504 additions and 454 deletions.
17 changes: 5 additions & 12 deletions codemagic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ definitions:
max_build_duration: 30

env_versions: &env_versions
flutter: 3.22.3
xcode: 15.4
flutter: 3.27.1
xcode: 16.2
cocoapods: 1.16.2
java: 17
java: 21

scripts:
- &verify_flutter_version
Expand Down Expand Up @@ -88,10 +88,8 @@ workflows:
working_directory: recipients_app

artifacts:
- recipients_app/build/**/outputs/**/*.apk
- recipients_app/build/**/outputs/**/*.aab
- recipients_app/build/**/outputs/apk/stage/**/*.apk
- recipients_app/build/**/outputs/**/mapping.txt
- flutter_drive.log

publishing:
#google_play:
Expand Down Expand Up @@ -182,10 +180,8 @@ workflows:
working_directory: recipients_app

artifacts:
- recipients_app/build/**/outputs/**/*.apk
- recipients_app/build/**/outputs/**/*.aab
- recipients_app/build/**/outputs/apk/prod/**/*.apk
- recipients_app/build/**/outputs/**/mapping.txt
- flutter_drive.log

publishing:
#google_play:
Expand Down Expand Up @@ -269,7 +265,6 @@ workflows:
artifacts:
- recipients_app/build/ios/ipa/*.ipa
- /tmp/xcodebuild_logs/*.log
- flutter_drive.log

publishing:
# Publish to Apple's Testflight via AppStore Connect
Expand Down Expand Up @@ -365,7 +360,6 @@ workflows:
artifacts:
- recipients_app/build/ios/ipa/*.ipa
- /tmp/xcodebuild_logs/*.log
- flutter_drive.log

publishing:
# Publish to Firebase App Distribution
Expand Down Expand Up @@ -458,7 +452,6 @@ workflows:
artifacts:
- recipients_app/build/ios/ipa/*.ipa
- /tmp/xcodebuild_logs/*.log
- flutter_drive.log

publishing:
# Publish to Apple's Testflight via AppStore Connect
Expand Down
3 changes: 2 additions & 1 deletion recipients_app/.tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
flutter 3.22.3
flutter 3.27.1
ruby 3.2.2
53 changes: 34 additions & 19 deletions recipients_app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Mobile App for Recipients of a Social Income.
- Java JDK 17
- Android Studio LadyBug or later
- Latest vsCode
- Xcode 16.1
- Xcode 16.x

## Configure the Apple Silicon Mac environment to build our app

Expand All @@ -26,23 +26,25 @@ Mobile App for Recipients of a Social Income.
export PATH="$PATH:$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools"
```
- Restart your terminal so that these changes take effect
- Install Java 17 via Homebrew `brew install openjdk@17`
- Homebrew is telling you to execute a symlink command, so that the
system Java wrappers can find this JDK. Please do this.
- Additionally in your USER's HOME directory in the file '.zshrc', add
the lines to set the JAVA_HOME environment variable to Java 17 and
add Java to the PATH environment variable
```shell
export JAVA_HOME=$(/usr/libexec/java_home -v17)
export PATH="$PATH:$JAVA_HOME/bin"
```
- Restart your terminal so that these changes take effect
- Install Flutter
- Tell Flutter to use our Java 17 JDK and not the one bundle with
Android Studio via `flutter config --jdk-dir "$JAVA_HOME"`.
Otherwise, you will get the error "Unsupported class file major
version 65” when building the app for Android.
- Restart your terminal and IDE so that these changes take effect
- Optional: Pin Flutter's JDK version and do not use the JDK from
Android Studio by default
- Install Java 21 via Homebrew `brew install openjdk@21`
- Homebrew is telling you to execute a symlink command, so that the
system Java wrappers can find this JDK. Please do this.
- Additionally in your USER's HOME directory in the file '.zshrc',
add the lines to set the JAVA_HOME environment variable to Java 21
and add Java to the PATH environment variable
```shell
export JAVA_HOME=$(/usr/libexec/java_home -v21)
export PATH="$PATH:$JAVA_HOME/bin"
```
- Restart your terminal so that these changes take effect
- Install Flutter
- Tell Flutter to use our Java 21 JDK and not the one bundle with
Android Studio via `flutter config --jdk-dir "$JAVA_HOME"`.
Otherwise, you will get the error "Unsupported class file major
version XX" when building the app for Android.
- Restart your terminal and IDE so that these changes take effect
- Install vsCode
- Install Flutter extension
- Install Xcode
Expand Down Expand Up @@ -154,7 +156,20 @@ locations as well:
- .tool-versions (version file for version manager ASDF)
- If you use 'asdf' run the comman `asdf local flutter x.y.z` #Replace
x.y.z with the new Flutter version.
- Otherwise just update the version number in the file
- Otherwise just update the version number in the file with the text
editor
- Update Flutter and dependent tool versions like Xcode, Java, etc.
"env_versions" in codemagic.yaml

## CI/CD Pipelines

We use CodeMagic to build our apps. The pipeline/workflows to build and
release the apps are define in the file codemagic.yaml.

CodeMagic documentation:
https://docs.codemagic.io/yaml-quick-start/building-a-flutter-app/
CodeMagic Cheetsheet:
https://docs.codemagic.io/codemagic-yaml-cheatsheet.html

## Testing

Expand Down
4 changes: 3 additions & 1 deletion recipients_app/android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ gradle-wrapper.jar
GeneratedPluginRegistrant.java

# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
# See https://flutter.dev/to/reference-keystore
key.properties
**/*.keystore
**/*.jks
18 changes: 13 additions & 5 deletions recipients_app/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
plugins {
id "com.android.application"
id "kotlin-android"
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id "dev.flutter.flutter-gradle-plugin"
// The Google services Gradle plugin
id "com.google.gms.google-services"
}

Expand Down Expand Up @@ -30,15 +32,25 @@ if (keystorePropertiesFile.exists()) {
}

android {
namespace 'org.socialincome.app'
compileSdkVersion 34

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
applicationId "org.socialincome.app"
minSdkVersion 21
minSdkVersion 23
targetSdkVersion 34
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down Expand Up @@ -84,7 +96,3 @@ flutter {
source '../..'
}

dependencies {
}


6 changes: 3 additions & 3 deletions recipients_app/android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.socialincome.app">
<!-- Flutter needs it to communicate with the running application
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
Expand Down
3 changes: 1 addition & 2 deletions recipients_app/android/app/src/dev/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.socialincome.app">
xmlns:tools="http://schemas.android.com/tools">
<!-- Flutter needs it for communicate with firebase emulators -->
<application
android:label="Dev Social Income"
Expand Down
3 changes: 1 addition & 2 deletions recipients_app/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.socialincome.app">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />

Expand Down

This file was deleted.

6 changes: 3 additions & 3 deletions recipients_app/android/app/src/profile/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.socialincome.app">
<!-- Flutter needs it to communicate with the running application
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
Expand Down
3 changes: 1 addition & 2 deletions recipients_app/android/app/src/stage/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.socialincome.app">
xmlns:tools="http://schemas.android.com/tools">
<application
android:label="Stage Social Income"
tools:replace="android:label"/>
Expand Down
4 changes: 2 additions & 2 deletions recipients_app/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ allprojects {
}
}

rootProject.buildDir = '../build'
rootProject.buildDir = "../build"
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}

subprojects {
project.evaluationDependsOn(':app')
project.evaluationDependsOn(":app")
}

tasks.register("clean", Delete) {
Expand Down
5 changes: 4 additions & 1 deletion recipients_app/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
org.gradle.jvmargs=-Xmx1536M
org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true
android.enableJetifier=true
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
5 changes: 3 additions & 2 deletions recipients_app/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ pluginManagement {

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
id "com.android.application" version '8.7.3' apply false
id "org.jetbrains.kotlin.android" version "1.8.22" apply false
// The dependency for the Google services Gradle plugin
// TODO(Verena): update to 4.4.0 once https://github.com/firebase/flutterfire/discussions/8691 is fixed
id "com.google.gms.google-services" version "4.3.15" apply false
}
Expand Down
2 changes: 1 addition & 1 deletion recipients_app/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>12.0</string>
<string>13.0</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions recipients_app/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
platform :ios, '12.0'
platform :ios, '13.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down Expand Up @@ -30,7 +30,7 @@ flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '10.25.0'
pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '11.4.0'

flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
Expand Down
Loading

0 comments on commit b0a8fa8

Please sign in to comment.