Gradle creates debugged APKs in release mode

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 an APK release, I use the following command:

./gradlew assembleEnemRelease

When downloading the generated APK ( app-enem-release.apk ) to Google Play, I received the following error:

You have downloaded the debugged APK. For security reasons, you need to disable debugging before publishing to Google Play. Learn more about debugged APKs.

I managed to create an indestructible APK using hard coding in android Manifest android:debuggable="false" . But the assembly configuration still acts as a debugged assembly, as you can see in the Build.config generation (I double check and this configuration assembly is from the release folder, also I don't get any Crashlytics data and I disabled it from Debug) .

 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"; } 
+5
source share
2 answers

I found out that this weird result comes from testCoverageEnabled true .

If your release version is included, then it generates coverage reports, then your APK becomes a debugged APK.

Set testCoverageEnabled to false to solve the problem, and it also makes sense not to generate coverage reports in the release build.

+7
source

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

+3
source

Source: https://habr.com/ru/post/1246896/


All Articles