Amplitude-Flutter icon indicating copy to clipboard operation
Amplitude-Flutter copied to clipboard

Flutter app fails for release after adding amplitude package

Open mikerashoo opened this issue 2 years ago • 1 comments

Hi we added amplitude on existing flutter app. it works fine when we run debug mode on emulator. but running release mode is crashing app on start even without implementing and only adding amplitude_flutter dependency without implementing it causes the same issue.

Another issue is after adding when we try to build copy of build folder is created under android/app/.. folder. has been while tiring to fix but no luck.

any help is appreciated

mikerashoo avatar Aug 25 '22 11:08 mikerashoo

@mikerashoo Thank you for submitting issues here. Is there any log or info about the crashing? We'll look into the problem. Any additional information would be helpful.

bohan-amplitude avatar Aug 26 '22 20:08 bohan-amplitude

@bohan-amplitude I'm running into the same issue with the amplitude_flutter package causing the Android release build to fail. I've copied the error message below. I’m using amplitude_flutter: 3.10.0 and Flutter 3.0.5. Please let me know if there's any other information I can provide that would be helpful.


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) #2 AndroidGradleBuilder.buildApk (package:flutter_tools/src/android/gradle.dart:184:5) #3 AndroidDevice.startApp (package:flutter_tools/src/android/android_device.dart:577:7) #4 FlutterDevice.runCold (package:flutter_tools/src/resident_runner.dart:505:33) #5 ColdRunner.run (package:flutter_tools/src/run_cold.dart:71:28) #6 RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:692:26) #7 FlutterCommand.run. (package:flutter_tools/src/runner/flutter_command.dart:1183:27) #8 AppContext.run. (package:flutter_tools/src/base/context.dart:150:19) #9 CommandRunner.runCommand (package:args/command_runner.dart:209:13) #10 FlutterCommandRunner.runCommand. (package:flutter_tools/src/runner/flutter_command_runner.dart:281:9) #11 AppContext.run. (package:flutter_tools/src/base/context.dart:150:19) #12 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5) #13 run.. (package:flutter_tools/runner.dart:62:9) #14 AppContext.run. (package:flutter_tools/src/base/context.dart:150:19) #15 main (package:flutter_tools/executable.dart:94:3)

sarlow avatar Sep 07 '22 18:09 sarlow

Hi @sarlow, can you also provide the following info?

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.

yuhao900914 avatar Sep 21 '22 00:09 yuhao900914

Hi @yuhao900914, 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.

sarlow avatar Sep 21 '22 23:09 sarlow

Thanks, @sarlow. Do you mind to share the changes in gradle-wrapper.properties and android/build.gradle?

yuhao900914 avatar Sep 21 '22 23:09 yuhao900914

Sure, the changes were:

gradle-wrapper.properties distributionUrl=https://services.gradle.org/distributions/gradle-7.0.2-all.zip => distributionUrl=https://services.gradle.org/distributions/gradle-7.3.3-all.zip

android/build.gradle classpath 'com.android.tools.build:gradle:7.0.4' => classpath 'com.android.tools.build:gradle:7.2.1'

sarlow avatar Sep 21 '22 23:09 sarlow

Thanks!

yuhao900914 avatar Sep 23 '22 21:09 yuhao900914