0

TERMINAL

~/StudioProjects/hsp_mgmt_kamranhccp

flutter build apk --release

ERROR: Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in /home/kamranhccpszorin/StudioProjects/hsp_mgmt_kamranhccp/build/app/outputs/mapping/release/missing_rules.txt. ERROR: R8: Missing class proguard.annotation.Keep (referenced from: com.razorpay.AnalyticsEvent and 8 other contexts) Missing class proguard.annotation.KeepClassMembers (referenced from: com.razorpay.AnalyticsEvent and 8 other contexts)

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:minifyReleaseWithR8'.

A failure occurred while executing com.android.build.gradle.internal.tasks.R8Task$R8Runnable 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 24s Running Gradle task 'assembleRelease'... 85.0s Gradle task assembleRelease failed with exit code 1

WHAT I AM FACING

I am running my hospital management flutter app with payment integration with firestore as database. While getting release apk, I get this error. Anyone facing issue like this with "with Progauard missing referecing to razorpay."

1 Answer 1

0

Apk file is generated using flutter build apk --release and the R8 makes the code smaller. This tool allows us to kill some classes and it shall reduce app size. But here in error because use the classes like proguard.annotation.Keep or proguard.annotation.KeepClassMembers of Razorpay code (example for this case com.razorpay.AnalyticsEvent) is not available in normal classes. It means R8 would be removing these classes but app need them.

While at the time of production, because of R8 enabled and with no ProGuard rules that it doesnt know what to keep of this.. cause build failing with

You get suggested rules from missing_rules.txt and write in file proguard-rules.pro

Go to android/app/build.gradle file and find buildTypes section, look whether these lines are present there:

buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), 'proguard-rules.pro'
    }
}

And then, execute these commands:

flutter clean
flutter pub get
flutter build apk --release
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.