-
Notifications
You must be signed in to change notification settings - Fork 23
chore: Update to Android Gradle Plugin 8.3.2 and SDK 34 #314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Upgraded Android Gradle Plugin, Gradle wrapper, and dexcount plugin versions. Migrated all modules to use compileSdk 34 and targetSdk 34, added namespace declarations, and updated build configuration to match latest Gradle and Android standards. Improved build script structure and fixed deprecation warnings for Gradle tasks.
Added ProGuard rules to contract-tests and example modules to suppress warnings for error-prone annotations. Improved build.gradle files to support reflection for tests and enhanced Javadoc generation with proper boot classpath handling. Cleaned up AndroidManifest.xml files by removing explicit package attributes.
…d 13+ - remove obsolete package attribute from androidTest manifest (namespace comes from Gradle) - register connectivity broadcast receiver with RECEIVER_NOT_EXPORTED on API 33+ - bump AndroidX test/orchestrator deps to 1.5.x/1.4.2 to satisfy receiver export requirement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a bug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, but I updated the target SDK to 34 and it is required for apps targeting 34 and above. https://developer.android.com/about/versions/14/behavior-changes-14#runtime-receivers-exported
| classpath += bootClasspath | ||
| if (options instanceof StandardJavadocDocletOptions) { | ||
| options.bootClasspath = bootClasspath.files.toList() | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What motivated these changes?
This seems a little magic
if (options instanceof StandardJavadocDocletOptions) {
options.source = "8"
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We’re running the build (incl. Javadoc) on JDK 17 after the AGP/Gradle upgrade, since AGP 8 requires it, but the SDK still targets Java 8 bytecode/APIs (lines 51/52 build.gradle(android-client-sdk) to make it compatible with apps compiling with Java 8 + desugaring and minSdk 21.
Setting options.source = "8" makes Javadoc enforce Java 8 syntax so we don’t accidentally expose Java 9+ APIs. If we leave it at the default, Javadoc assumes 17.
If we raised the whole SDK to Java 17 would it make sense to drop this and align everything to 17, but doing that will require all the apps using this SDK to bump their Java versions to 17 which I think it's not currently recommendable.
The specific code snippet you mentioned it's saying to Javadoc that uses Java 8
| buildTypes { | ||
| release { | ||
| minifyEnabled = true | ||
| proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can these proguard additions be eliminated? We want to avoid proguard in examples to focus on core functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ProGuard / R8 (Same thing, R8 is the new name) is enabled when minifyEnabled = true is set. So, R8 is currently enabled on the main branch.
I just added these lines because otherwise I get the error "Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in..." when I try to run ./gradlew assemble.
We could get rid of R8 in the example app, but given that most of the client apps use R8, I think leaving it enabled could catch possible issues that happen in our lib only when R8 is enabled.
|
|
||
| publishing { | ||
| singleVariant("release") | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double check implications of this singleVariant. I don't think we used this before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to avoid creating a Gradle "component" for the debug version, since it's not necessary given that later is discarded and only the "release" component is used. (Line 184).
https://developer.android.com/build/publish-library/configure-pub-variants#single-pub-var
Upgraded Android Gradle Plugin, Gradle wrapper, and dexcount plugin versions. Migrated all modules to use compileSdk 34 and targetSdk 34, added namespace declarations, and updated build configuration to match latest Gradle and Android standards. Improved build script structure and fixed deprecation warnings for Gradle tasks.
Requirements
Related issues
Describe the solution you've provided
Upgrade gradle from 7.3.3 version to 8.5.0
Additional context
I wanted to build the project to check something, but I was asked to upgrade the gradle version to 8.x.x and I thought it was a good idea to push the change.
I haven't tested it extensively since this is out of the scope of my tickets, but it seems to work correctly. @tanderson-ld check it a bit more before approve it please.
Note
Upgrade build system to Gradle 8.5/AGP 8.3.2 and migrate all modules to compile/target SDK 34 with namespace and modern Gradle/Android DSL updates, plus test/proguard tweaks and a receiver fix for Android 13+.
8.5, Android Gradle Plugin to8.3.2, dexcount to4.0.0, and Nexus Publish plugin to1.3.0.build.gradle: usebase.archivesName, centralize Android config viaBaseExtension, enable deprecation checks, and add test JVM--add-opens.compileSdk/targetSdk34, addnamespace, switch to newminSdk/compileSdkDSLs, removebuildToolsVersion.android:exportedwhere needed); switch to newpackaging { resources { excludes } }andpublishing { singleVariant("release") }.exampleandcontract-tests; excludeerror_prone_annotationsto avoid dexing issues.BroadcastReceiverwithContext.RECEIVER_NOT_EXPORTEDinAndroidPlatformState.Written by Cursor Bugbot for commit cd3320f. This will update automatically on new commits. Configure here.