Skip to content Skip to sidebar Skip to footer

Can't Generate Apk After Adding Google Analytics, But Working Fine In Debug Mode

It's a very weird situation. I can build my project, clean and build my project and can even run on physical device with debug mode. I also get all the data that I require on Googl

Solution 1:

The problem is proguard related, you have proguard activated only on release profile ( minifyEnabled true ).

You have two options:

  1. Disable Proguard setting this property to false. This option is really not recommended in case you are going to release the app.

  2. Add rules to Proguard to works correctly with Analytics. This rules should be added to the file proguard-rules.pro and this is an example:

    -keep class com.google.android.gms.** { *; }-dontwarn com.google.android.gms.**

More info about Proguard in the Android Developers Page and the official project page

Hope it helps.

Solution 2:

There is one more solution, which I prefer more until Google will fix the issue. You can add missing classes and don't worry that there might be some ClassNotFoundException.

So simply add this in the gradle config:

android {
     useLibrary 'org.apache.http.legacy'
}

Post a Comment for "Can't Generate Apk After Adding Google Analytics, But Working Fine In Debug Mode"