Moment For Technology

Crash records of Flutter debug properly and Crash release

Posted on Sept. 23, 2022, 10:24 p.m. by 崔惠如
Category: android Tag: android

Write down any recent problems with Flutter learning

While developing the product version of Flutter, it has been under normal development since the integration of Alibaba Cloud Player. It was found that after the Release package was typed, the App would Crash directly when entering the player page.

The error message from Flutter is also not obvious.

JNI DETECTED ERROR IN APPLICATION: java_class == null in call to GetFieldID from java.lang.String java.lang.Runtime.nativeLoad(java.lang.String, Java. Lang. This, Java. Lang. Class) Runtime aborting... Dumping all threads without mutator lock held

It says that the JNI call returned NULL, but I don't think this layer was touched either.

At the beginning of the stack information research for a long time, has been no results. I'm the only one on the move. No chicken for the big guy. Later, I thought about it carefully. This kind of debug is normal, and the problem of release Crash should be related to the configuration, and then I will troubleshoot according to the configuration.

1. Signature problem (failed)

The first thing to worry about is signing. Release and Debug signatures are different because there is no signature to create release. Flutter uses debug's signature by default.

Create the Release signature and reset. failure

2. Version problems (failed)

Because of the Flutter project, many things will not be prompted, such as Gradle. So open the Android Studio interface as an Android project.

Checked the version of Aricloud Player. Gradle Plugin version of the project. Modify it and try again. Still fail.

A relatively useful piece of information, however, is that when changing Gradle versions, it says that AliPlayer Gradle no longer disables R8 after 5.0. All of a sudden, confounding compression comes to mind

3. Obfuscation compression (successful)

The first Flutter project did not obfuscate the code at all, nor was this aspect considered at the outset.

Later, IT occurred to me that I had read an article shared by Google on Android developers before, about the detailed explanation of R8 compression. R8 compression is enabled by default in the release version.

Then modify the configuration in build.gradle

buildTypes {
        release {
            minifyEnabled false
            shrinkResources false
            signingConfig signingConfigs.release
Copy the code

Try again using the Build APk function of Flutter, but this does not work. It is strange to turn off compression and remove useless resources.

Never thought of it. I compiled the release package with the command flutter build apk --release. A success. Later, I tried again and found that there should be a cache problem.

At this point, the problem is solved. It took me two days because I wasn't careful enough. Left no knowledge of tears.

About (Moment For Technology) is a global community with thousands techies from across the global hang out!Passionate technologists, be it gadget freaks, tech enthusiasts, coders, technopreneurs, or CIOs, you would find them all here.