Skip to content

Commit

Permalink
build(app): hacky fix for building APKs
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Nov 14, 2024
1 parent 7d7a8e4 commit b9de79b
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Files generated due to fix
android/build/app/

# Miscellaneous
*.class
*.log
Expand Down
18 changes: 18 additions & 0 deletions app/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,24 @@ alias flutter-generate='dart run build_runner build --delete-conflicting-outputs
alias flutter-clean='find . -maxdepth 20 -type f \( -name "*.inject.summary" -o -name "*.inject.dart" -o -name "*.g.dart" \) -delete'
```

## Updating Flutter and Android

... can be super painful, because Java, Gradle, and Kotlin versions may be
wrong.

Often problems in packages arise that rely on older Gradle versions.

The places to check are:

- Your Flutter version
- Your `JAVA_HOME` version
- The Gradle version in `gradle-wrapper.properties`; the recommended versions
are "between 7.3 and 7.6.1." (see
[Android Java Gradle migration guide](https://docs.flutter.dev/release/breaking-changes/android-java-gradle-migration-guide))
- The Java version in `android/app/build/gradle`
- The Java version used for Gradle (check in Android Studio)
- The Kotlin version in `settings.gradle`

## Architecture

The app consists of multiple so-called modules. Our main modules (usually app
Expand Down
30 changes: 29 additions & 1 deletion app/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ allprojects {
}
}

// From https://medium.com/@vortj/solving-namespace-errors-in-flutters-android-gradle-configuration-c2baa6262f8b
subprojects {
afterEvaluate { project ->
// From https://medium.com/@vortj/solving-namespace-errors-in-flutters-android-gradle-configuration-c2baa6262f8b
if (project.hasProperty('android')) {
project.android {
if (namespace == null) {
Expand All @@ -43,7 +43,28 @@ subprojects {
}
}
}
// From https://github.com/flutter/flutter/issues/153281#issuecomment-2292201697
if (project.extensions.findByName("android") != null) {
Integer pluginCompileSdk = project.android.compileSdk
if (pluginCompileSdk != null && pluginCompileSdk < 31) {
project.logger.error(
"Warning: Overriding compileSdk version in Flutter plugin: "
+ project.name
+ " from "
+ pluginCompileSdk
+ " to 31 (to work around https://issuetracker.google.com/issues/199180389)."
+ "\nIf there is not a new version of " + project.name + ", consider filing an issue against "
+ project.name
+ " to increase their compileSdk to the latest (otherwise try updating to the latest version)."
)
project.android {
compileSdk 31
}
}
}
}
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(":app")
}

rootProject.buildDir = '../build'
Expand All @@ -55,3 +76,10 @@ subprojects {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}

// From https://stackoverflow.com/a/69050529
configurations.all {
resolutionStrategy {
force 'androidx.core:core-ktx:1.6.0'
}
}

0 comments on commit b9de79b

Please sign in to comment.