Status Update
Comments
di...@google.com <di...@google.com>
je...@google.com <je...@google.com>
ga...@google.com <ga...@google.com> #2
Okay. I tried a bunch of agp+android studio versions
The last working version was classpath("com.android.tools.build:gradle:7.4.0-alpha06")
once I moved to
classpath("com.android.tools.build:gradle:7.4.0-alpha07")
then things start breaking on firebase app dist.
ni...@nrbtech.io <ni...@nrbtech.io> #3
Scott, assigning to you as it seem to complain the zip is not aligned while packaging which is very puzzling considering the steps...
bi...@google.com <bi...@google.com> #4
OP, when you build the APK with AGP, are you doing any post-processing on the APK and/or do you have any custom tasks that are modifying the APK?
Can you try to verify the alignment of your APK with zipalign
locally (zipalign
is included in build-tools
):
zipalign -c -v 4 foo.apk
ni...@nrbtech.io <ni...@nrbtech.io> #5
Not doing any post processing. No custom tasks. I will try to verify alignment now. Give me a sec.
bi...@google.com <bi...@google.com> #6
Scenario 1:
built my apk with agp alpha09, but didn't update firebase (bom = 30.2.0)
/Users/idle/Library/Android/sdk/build-tools/31.0.0/zipalign -c -v 4 app-release.apk
"Verification succesful"
Scenario 2:
built my apk with agp alpha09, but I DID update firebase (bom = 30.3.1)
/Users/idle/Library/Android/sdk/build-tools/31.0.0/zipalign -c -v 4 app-release.apk
"Verification FAILED"
ni...@nrbtech.io <ni...@nrbtech.io> #7
Scenario 3:
built my apk with agp alpha09, with androidx.splash rc01
/Users/idle/Library/Android/sdk/build-tools/31.0.0/zipalign -c -v 4 app-release.apk
"Verification succesful"
Scenario 4:
built my apk with agp alpha09, with androidx.splash 1.0.0
/Users/idle/Library/Android/sdk/build-tools/31.0.0/zipalign -c -v 4 app-release.apk
"Verification FAILED"
In both failed cases if I do | grep BAD
I get
7216334 junit/runner/logo.gif (BAD - 2)
7217354 junit/runner/smalllogo.gif (BAD - 2)
ww...@gmail.com <ww...@gmail.com> #8
In the cases where zipalign
verification fails, is the APK generated by a clean build (e.g., ./gradlew clean :app:assembleRelease
)?
Does verification succeed if you add this to your build.gradle?
android {
packagingOptions {
exclude 'junit/runner/logo.gif'
exclude 'junit/runner/smalllogo.gif'
}
}
ww...@gmail.com <ww...@gmail.com> #9
In the cases where zipalign verification fails, is the APK generated by a clean build (e.g., ./gradlew clean :app:assembleRelease)?
I clean before i generate the apk using the Android Studio menu for generating an apk
Does verification succeed if you add this to your build.gradle?
I assume it will, but let me try. Any reason why changing from androidx.splash 1.0.0-rc01 to 1.0.0 stable (which is 0 changes. all it changed was the dependency version) that it fails verification. It seems like something else is wrong that's a bit deeper than just adding these two exclude statements.
bi...@google.com <bi...@google.com> #10
It seems like something else is wrong that's a bit deeper than just adding these two exclude statements.
I agree, but I'd like to find a workaround for you in the meantime.
I think I'll probably need a repro project to get to the bottom of it. In your other thread, it sounded like you weren't able to create a repro project... any luck since then?
ww...@gmail.com <ww...@gmail.com> #11
I was not able to create a repro unfortunately. As soon as I started to prune things out of my project it started to succeed.
Similarly. firebase came out with a new version. and if i use that new version... then it also succeeds. 🤯
I'm glad to hear there is a workaround for now (and i learned something new about zipalign). I will try to create a repo project again later today when I have about an hour or so free to play around with it, but for now I will just commit the
android {
packagingOptions {
exclude 'junit/runner/logo.gif'
exclude 'junit/runner/smalllogo.gif'
}
}
to my codebase because that did the trick for me. Everything works. Thank you for your quick response and helpful debugging steps.
bi...@google.com <bi...@google.com>
ni...@nrbtech.io <ni...@nrbtech.io> #12
Thanks!
[Deleted User] <[Deleted User]> #13
not able to get a repro case. literally any minor thing i change makes this verify successfully. im a bit out of ideas. the only thing i can think of that might help is why is junit being packaged into my app.
and i think the reason for that is that I depend on okhttp3:mockwebserver:4.10.0
implementation("junit:junit:4.13.2") // Needed because mockwebserver has a dependency on it. This can be removed in okhttp 5+
so the apps i ship through firebase have a mockwebserver using okhttpmockwebserver, but version 4+ requires junit while okhttp 5+ (not yet released), removes this dep.
so maybe just playing around with adding junit as a dependency to an actual app might help repro?
source:
maybe still owrth checking out as there could be other deps that end up with the same issue. idk. just trying to be helpful i guess. but as for me. im going to consider this case closed. excluding the above like you mentioned has unblocked my team. cheers
ro...@miquido.com <ro...@miquido.com> #14
Thanks for looking into it!
I agree it's strange they have an implementation
dependency on junit, and I'm glad they're removing it in okhttp 5+.
I'll go ahead and close this bug for now.
ww...@gmail.com <ww...@gmail.com> #15
This is fixed by Change-Id: I12ec8785cd4dbb6e523c66b4620ed2388f448822, which will be in AGP 7.4.0-rc01 and 8.0.0-alpha08.
bi...@google.com <bi...@google.com> #16
Thanks for filing the bug, OP. Your observation in
ww...@gmail.com <ww...@gmail.com> #17
FUCK YEAH! Glad I was helpful! Appreciate you working through it with me here. Cheers. Once I update to alpha08 I will remove the workaround I added. cheers
bi...@google.com <bi...@google.com> #18
I am afraid it cannot be done in project like in gradle.properties
bi...@google.com <bi...@google.com> #19
Actually, can you try adding com.android.tools.analytics.AnalyticsSettings.setOptedIn(false)
to the build.gradle
file of each root project?
In your sample project, add it to MyLibrary/build.gradle
and MyApplication/build.gradle
ww...@gmail.com <ww...@gmail.com> #20
I couldn't add exact code you've provided bacause of the error Unresolved reference: setOptedIn
.
Intrestingly enough I could set opt in flag via reflections:
Class.forName("com.android.tools.analytics.AnalyticsSettings")
.getMethod("setOptedIn", Boolean::class.java)
.invoke(null , false)
It somewhat works but first sync always fails with the original error Could not create an instance of type com.android.build.gradle.internal.profile.AnalyticsService
.
Don't know how it will behaive with CI. Will check somewhere later, don't have access to CI at the moment.
ww...@gmail.com <ww...@gmail.com> #21
I don't know if these are really related but even though you can sync project from the second try - native code breakpoints don't work even with Dual
debug type. Moreover LLDB doesn't even attach on its own when debug type is Detect Automatically
.
It was not a problem with 7.1.X and Bumblebee.
bi...@google.com <bi...@google.com> #22
That is weird cause I am able to make it work by adding it to your sample project.
bi...@google.com <bi...@google.com> #23
Fixed with I905dd70a2e7ccf05b3a7da1c83e2af4260b71ece and the fix will be available since 8.0-alpha01.
ka...@gmail.com <ka...@gmail.com> #24
While I am building I receive:
"A build operation failed.
Failed to create service 'com.android.build.gradle.internal.profile.AnalyticsService_704aac9b-2502-42f4-80cd-cccdba9bb437'.
Failed to create service 'com.android.build.gradle.internal.profile.AnalyticsService_704aac9b-2502-42f4-80cd-cccdba9bb437'.
Could not create an instance of type com.android.build.gradle.internal.profile.AnalyticsService.
Cannot query the value of this property because it has no value available."
Details:
Android Studio version: Android Studio Electric Eel | 2022.1.1
OS: Windows 10
Java versions: Oracle OpenJDK 11.0.10, Azul Zulu version 13.0.10
And some more details below:
I would like to mention that my Android Studio project contains two projects on the same root as it is mentioned in the previous comments (multi-root project).
Here are some more tests I did:
Windows 10, Android Studio Electric Eel | 2022.1.1, Gradle 7.5, AGP 7.4.0 => The problem as it is described above
Windows 10, Android Studio Electric Eel | 2022.1.1, Gradle 7.5, AGP 7.3.1 => Build and run successfully
Windows 10, Android Studio Electric Eel | 2022.1.1, Gradle 7.4, AGP 7.3.1 => Build and run successfully
Mac OS Monterey 12.6.2, Android Studio Electric Eel | 2022.1.1, Gradle 7.5, AGP 7.4.0 => The problem as it is described above
Mac OS Monterey 12.6.2, Android Studio Electric Eel | 2022.1.1, Gradle 7.5, AGP 7.3.1 => Build and run successfully
Mac OS Monterey 12.6.2, Android Studio Dolphin | 2021.3.1, Gradle 7.5, AGP 7.4.0 => The problem as it is described above
Mac OS Monterey 12.6.2, Android Studio Dolphin | 2021.3.1, Gradle 7.5, AGP 7.3.1 => Could not run due to the reason that AGP 7.3.1 requires as minimum the Gradle 7.4
As I can understand, the problem is on the AGP 7.4.0 which tries to create the AnalyticsSettings instance.
As a current solution to my problem, I am using Gradle 7.5 with AGP 7.3.1 in the latest Android Studio versions(Dolphin and Electric) for my project.
Regards,
ga...@linecorp.com <ga...@linecorp.com> #25
Fixed with I905dd70a2e7ccf05b3a7da1c83e2af4260b71ece and the fix will be available since 8.0-alpha01.
Is it possible to backport this change on stable version(AGP 7.4)?
pa...@gmail.com <pa...@gmail.com> #26
@ww... in #20
> I couldn't add exact code you've provided because of the error Unresolved reference: setOptedIn.
This happens when the class is not on the right classpath.
It's housed in com.android.tools.analytics-library:shared:30.4.0.
Which is a transitive dependency of com.android.tools:sdk-common:30.4.0.
In one of the AGP 7.x versions a lot of dependencies (including sdk-common) have been moved from compile to runtime scope in the POM, so they moved from compileClasspath to runtimeClasspath configuration in Gradle.
So, in Kotlin we need the class be present and compileClasspath, Groovy doesn't care as it's interpreted and does exactly the reflective code you posted.
I couldn't make it work with this hack, tried many-many ways, but only synced by editing analytics.settings.
dm...@mapbox.com <dm...@mapbox.com> #27
The only workaround that worked was to disable `Send usage statistics to google` in settings, changing flag manually in `~./android/analytics.settings` had no effect and AS kept overwriting the file.
pa...@gmail.com <pa...@gmail.com> #28
Edit the file and make it read-only. It will warn on every AGP build, and on AS startup you'll get a weird opt-in dialog, but AS won't be able to change it back.
fu...@gmail.com <fu...@gmail.com> #29
Fixed with I905dd70a2e7ccf05b3a7da1c83e2af4260b71ece and the fix will be available since 8.0-alpha01.
Is it possible to backport this change on stable version(AGP 7.4) or gradle(7.5+)?
bi...@google.com <bi...@google.com> #30
Unfortunately, it is not an option
da...@gmail.com <da...@gmail.com> #31
Please advise if possible on a solution. Thank you in advance.
[Deleted User] <[Deleted User]> #32
// 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()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
//apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
namespace "com.example.notification_fiebase"
compileSdkVersion 33
ndkVersion flutter.ndkVersion
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
multiDexEndabled true
// TODO: Specify your own unique Application ID (
applicationId "com.example.notification_fiebase"
// You can update the following values to match your application needs.
// For more information, see:
minSdkVersion 19
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
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 "com.google.firebase:firebase-bom:32.7.1"
}
'flutter' for extension 'android' of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension.
solve that issue
Description
DESCRIBE THE ISSUE IN DETAIL:
While Gradle 7.2 works fine, and Gradle 7.4 works fine in AS 2021.1.1, Gradle 7.4 fails in AS 2021.3.1 Canary 7 with the following exception:
STEPS TO REPRODUCE:
ATTACH SCREENSHOTS/RECORDINGS OF THE ISSUE
ATTACH LOG FILES (Select Help > Show Log in Files, or Show Log in Finder on a Mac)
Build: AI-213.6777.52.2113.8305692, 202203160046,
AI-213.6777.52.2113.8305692, JRE 11.0.13+0-b1751.21-8125866x64 JetBrains s.r.o., OS Mac OS X(aarch64) v12.3, screens 3456.0x2234.0, 5120.0x2880.0; Retina
AS: Dolphin | 2021.3.1 Canary 7; Kotlin plugin: 213-1.6.20-M1-release-for-android-studio-AS6777.52; Android Gradle Plugin: 7.1.2; Gradle: 7.4; Gradle JDK: version 11.0.13; NDK: from local.properties: (not specified), latest from SDK: (not found); LLDB: pinned revision 3.1 not found, latest from SDK: (package not found); CMake: from local.properties: (not specified), latest from SDK: 3.18.1-g262b901, from PATH: 3.22.0