Solved

Flutter plugin broken for Android release

  • 7 September 2022
  • 9 replies
  • 1598 views

Badge

I recently added the Amplitude Flutter plugin to my app.

Everything is working perfectly in dev mode, but as soon as I build the app for Android in release mode, the build fails with the errors I’ve copied below.

I’m sure the issue is with the Amplitude plugin, since removing it allows me to build the app in release mode with no problems.

I’m using amplitude_flutter: 3.10.0 and Flutter 3.0.5. 

---

ERROR:R8: com.android.tools.r8.internal.r8: Attribute Signature requires InnerClasses attribute. Check -keepattributes directive.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:minifyReleaseWithR8'.
> com.android.tools.r8.CompilationFailedException: Compilation failed to complete

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 29s
Running Gradle task 'assembleRelease'...                           90.6s

┌─ Flutter Fix ──────────────────────────────────────────────────────────────┐
│ [!] The shrinker may have failed to optimize the Java bytecode.            │
│ To disable the shrinker, pass the `--no-shrink` flag to this command.      │
│ To learn more, see: https://developer.android.com/studio/build/shrink-code │
└────────────────────────────────────────────────────────────────────────────┘
Exception: Gradle task assembleRelease failed with exit code 1
#0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
#1      AndroidGradleBuilder.buildGradleApp (package:flutter_tools/src/android/gradle.dart:444:7)
<asynchronous suspension>
#2      AndroidGradleBuilder.buildApk (package:flutter_tools/src/android/gradle.dart:184:5)
<asynchronous suspension>
#3      AndroidDevice.startApp (package:flutter_tools/src/android/android_device.dart:577:7)
<asynchronous suspension>
#4      FlutterDevice.runCold (package:flutter_tools/src/resident_runner.dart:505:33)
<asynchronous suspension>
#5      ColdRunner.run (package:flutter_tools/src/run_cold.dart:71:28)
<asynchronous suspension>
#6      RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:692:26)
<asynchronous suspension>
#7      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1183:27)
<asynchronous suspension>
#8      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#9      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
<asynchronous suspension>
#10     FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:281:9)
<asynchronous suspension>
#11     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#12     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5)
<asynchronous suspension>
#13     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
<asynchronous suspension>
#14     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#15     main (package:flutter_tools/executable.dart:94:3)
<asynchronous suspension>

icon

Best answer by sia-amp 22 September 2022, 01:36

View original

9 replies

Userlevel 5
Badge +9

Hello @sia-amp ! 

 

So sorry to hear that you are experiencing issues using the Flutter SDK. Are you running into this issue with various versions of the SDK? I understand that 3.10.0 is the most recent release but I am wondering if we can tunnel the issue to the specific version of it’s affecting others.

Could you try the version before, 3.9.0, please? Link: https://github.com/amplitude/Amplitude-Flutter/releases

Badge

Hi @eddie.gaona, thanks for your reply. I’ve tried every version between 3.4.0 and 3.10.0 and all are showing the same errors. (For versions prior to 3.4.0, there were additional Android Gradle version incompatibility issues).

Badge

@eddie.gaona Do you have an update or any suggestions about what I should try next?

I’d rather not have to remove Amplitude from the Android version of my Flutter app, but I’m not sure what other options there are at this point. 

Userlevel 6
Badge +9

Thanks for following up @sia-amp I’ll ping the team, who can take a closer look and get back to you.

Userlevel 5
Badge +9

Hello @sia-amp sorry to hear that you are still experiencing issues using the Flutter SDK. I can confirm that I have opened a bug ticket with our engineering team to provide advice for these errors. We will report back once we have more information.

Userlevel 5
Badge +9

Hello @sia-amp 

Can you provide the following information?

  1. run flutter build apk --release -v and return the verbose log

  2. provide pubspec.yaml file

  3. provide build.gradle file

  4. provide gradle.properties file.

The theory right now is that the issue is coming from a duplicate library installed.

Badge

Hi @eddie.gaona, thanks for following up. After updating the `android/gradle/wrapper/gradle-wrapper.properties` distributionUrl and the `android/build.gradle` classpath, it seems to be working now, so possibly it was an issue with using an older Gradle version. I shared this info on the Github issue as well so the team is looped in.

Userlevel 5
Badge +9

@sia-amp Glad to hear that the Flutter SDK is working!

Here is the GitHub Issue for anyone else interested in the fix: https://github.com/amplitude/Amplitude-Flutter/issues/117

Some apps are not available on the Play Store, so we have to get them manually. Sideloading apps is one of the key features of Android. On your device, you can sideload apk files. Best site for all APK

Reply