【问题标题】:Gradle is generating debuggable APKs on release modeGradle 在发布模式下生成可调试的 APK
【发布时间】:2016-08-02 02:37:45
【问题描述】:

我的 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
        }
    }

要生成 de release APK,我使用以下命令:

./gradlew assembleEnemRelease

在 Google Play 上上传生成的 APK (app-enem-release.apk) 时出现以下错误:

您上传了一个可调试的 APK。出于安全原因,您需要先禁用调试,然后才能在 Google Play 中发布它。详细了解可调试的 APK。

通过在 android Manifest android:debuggable="false" 上进行硬编码,我能够生成一个不可调试的 APK。但是构建配置仍然像可调试的构建一样,正如您在生成的 Build.config 中看到的那样(我仔细检查,这个构建配置来自发布文件夹,我也没有收到 Crashlytics 上的任何数据,我从调试构建)。

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";
}

【问题讨论】:

  • 同样的问题...
  • @Guiherme Torres Castro : 你能试着用这个ideone.com/c376gt替换你的gradle文件吗@
  • 我提供链接是因为我不确定答案,但通过这种方式我解决了我的问题。
  • @dex 感谢您的提示,不幸的是它没有用

标签: android gradle


【解决方案1】:

我发现这个奇怪的结果来自testCoverageEnabled true

如果您的发布版本启用了测试覆盖率,它会生成覆盖率报告,然后您的 APK 变为可调试 APK。

testCoverageEnabled 设置为false 即可解决问题,而且在发布版本中不生成覆盖率报告也是有意义的。

【讨论】:

  • 救命稻草!谢谢!
  • 如果你向谷歌举报就更好了
【解决方案2】:

作为解决方法,我在 defaultConfig 中将 debuggable 设置为 true,在 release 中我覆盖配置并将 debuggable 设置为 false。

【讨论】:

  • 不确定将debuggable true 设置为发布模式是否是个好主意。好像不太对
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-02-18
  • 1970-01-01
  • 2014-08-18
  • 1970-01-01
  • 2019-10-02
相关资源
最近更新 更多