Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle is generating debuggable APKs on release mode

Tags:

android

gradle

I have the following code on my build.gradle:

productFlavors {
        juridico {
            applicationId "br.com.eit.appprovaconcursos"
        }
        enem {
            applicationId "com.ioasys.appprova"
        }
    }

    buildTypes {
        defaultConfig {
            debuggable false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            debuggable true
            testCoverageEnabled true
        }
        release {
            debuggable false
            testCoverageEnabled true
            //noinspection GroovyAssignabilityCheck
            signingConfig signingConfigs.release
        }
    }

To generate de release APK I use the following command:

./gradlew assembleEnemRelease

When uploading the generated APK (app-enem-release.apk) on the Google Play I got the following error:

You uploaded a debuggable APK. For security reasons you need to disable debugging before it can be published in Google Play. Learn more about debuggable APKs.

I was able to generated a non-debuggable APK by hard coding on android Manifest android:debuggable="false". But the build config still acting like a debuggable build, as you can see in the generate Build.config (I double check and this build config is from the release folder, also I am not receiving any data on Crashlytics, and I disable it from Debug builds).

public final class BuildConfig {
  public static final boolean DEBUG = Boolean.parseBoolean("true");
  public static final String APPLICATION_ID = "com.ioasys.appprova";
  public static final String BUILD_TYPE = "release";
  public static final String FLAVOR = "enem";
  public static final int VERSION_CODE = 20135;
  public static final String VERSION_NAME = "3.0.1";
}
like image 918
Guilherme Torres Castro Avatar asked Apr 11 '16 19:04

Guilherme Torres Castro


2 Answers

I found out this weird result comes from testCoverageEnabled true.

If your release build enabled test coverage, it generates coverage reports then your APK becomes debuggable APK.

Set testCoverageEnabled to false solve the problem, and it also make sense to not generating coverage reports on release build.

like image 169
saiday Avatar answered Oct 23 '22 04:10

saiday


As workaround I set debuggable to true in the defaultConfig and in release I override the configuration and set debuggable to false.

like image 28
Guilherme Torres Castro Avatar answered Oct 23 '22 06:10

Guilherme Torres Castro