sentry-android-gradle-plugin icon indicating copy to clipboard operation
sentry-android-gradle-plugin copied to clipboard

Support new Android Gradle APIs

Open marandaneto opened this issue 4 years ago • 9 comments

We could improve how to find the mapping file using the latest APIs https://github.com/getsentry/sentry-android-gradle-plugin/blob/main/plugin-build/src/main/kotlin/io/sentry/android/gradle/SentryMappingFileProvider.kt

https://developer.android.com/reference/tools/gradle-api/4.1/com/android/build/api/artifact/ArtifactType.OBFUSCATION_MAPPING_FILE

https://medium.com/androiddevelopers/new-apis-in-the-android-gradle-plugin-f5325742e614

this won't work for people using AGP 4.0 though, only >= 4.1

marandaneto avatar May 21 '21 10:05 marandaneto

https://github.com/ReactiveCircus/app-versioning/blob/b30fb5435b25ad7fb8acdf61179c7010f4074fdb/src/main/kotlin/io/github/reactivecircus/appversioning/AppVersioningPlugin.kt uses the onVariants API, we can learn from there

marandaneto avatar May 31 '21 14:05 marandaneto

variant API is now stable: https://developer.android.com/studio/releases/gradle-plugin#7-0-0 https://github.com/android/gradle-recipes/tree/agp-7.0/Kotlin

marandaneto avatar Jul 29 '21 08:07 marandaneto

variant API is now stable: developer.android.com/studio/releases/gradle-plugin#7-0-0 https://github.com/android/gradle-recipes/tree/agp-7.0/Kotlin

Awesome 🎉 I believe we want to try to land this https://github.com/getsentry/sentry-android-gradle-plugin/pull/106 first right?

cortinico avatar Jul 29 '21 09:07 cortinico

@cortinico yeah landing https://github.com/getsentry/sentry-android-gradle-plugin/pull/106 would be nice, but if migrating to AGP 7.x is painless, I'd not mind ignoring it since AGP 4.1 to 4.2 does not have any benefits by the final user.

AGP 7.x though introduces breaking changes, but we can always bump a major and recommend people using the v2.x when using AGP < 7.x

what do you think? I'm fine either way, right now I believe our plugin 2.x works pretty well with AGP 7.x right? as we run tests on the beta version as well, so not an urgent issue to work on either.

marandaneto avatar Jul 29 '21 11:07 marandaneto

https://github.com/getsentry/sentry-android-gradle-plugin/pull/155 for testing AGP 7.0.0 stable version

marandaneto avatar Jul 29 '21 12:07 marandaneto

com.android.build.gradle.api.ApplicationVariant is deprecated and should be replaced

marandaneto avatar Oct 05 '21 12:10 marandaneto

AndroidComponentsExtension does not exist on AGP 4.x so we have to drop support on 4.x

marandaneto avatar Oct 06 '21 07:10 marandaneto

there's no way to access the object variant.buildType using the new API, variant.buildType is a String instead of a BuildType object, we really need to access the isMinifyEnabled and isDebuggable properties, better to not do it right now till finding a better solution

marandaneto avatar Oct 06 '21 12:10 marandaneto

We'd also need to switch to the new instrumentation API introduced in 7.2 (https://developer.android.com/studio/releases/gradle-plugin-api-updates#instrumentatin-apis-deprecated). For now we'll stick to the deprecated version for compat's sake, but at some point it will be removed and we'll need to migrate.

romtsn avatar Jun 21 '22 08:06 romtsn