我尝试在谷歌播放上上传我的apk,遇到了一个错误消息:“你上传了一个可调试的apk。出于安全原因,您需要在谷歌播放中发布调试之前禁用调试。了解更多关于可调试apk的信息。”

然后我在我的manifest中写了android:debuggable="false",然后再试一次。我遇到了同样的错误,所以我已经从我的模块中设置了构建变体,并尝试再次生成apk,但这一次,生成了这个错误:

Error:Gradle: Execution failed for task ':app:lintVitalRelease'.
Lint found fatal errors while assembling a release target.
  To proceed, either fix the issues identified by lint, or modify your build script as follows:
  ...
  android {
      lintOptions {
          checkReleaseBuilds false
          // Or, if you prefer, you can continue to check for errors in release builds,
          // but continue the build even when errors are found:
          abortOnError false
      }
  }
  ...

当前回答

升级gradle分发url到,

// android/gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip

并将buildscript -> dependencies -> classpath升级为,

// android/build.gradle
classpath 'com.android.tools.build:gradle:7.0.0'

为我修正了这个问题

其他回答

我不建议关掉棉绒检查,它们的存在是有原因的。相反,检查错误是什么并修复它。

错误报告保存到[app module]/build/reports/lint-results-yourBuildName-fatal.html。您可以在浏览器中打开此文件以阅读有关错误的信息。

如果Gradle能让错误报告生成的位置更加清晰,那就太好了。

进入build.gradle(模块:app)

lintOptions {
    checkReleaseBuilds false
    // Or, if you prefer, you can continue to check for errors in release builds,
    // but continue the build even when errors are found:
    abortOnError false
}

在你的app.gradle文件中试试这3行。

android {
lintOptions {
    checkReleaseBuilds false
    // Or, if you prefer, you can continue to check for errors in release builds,
    // but continue the build even when errors are found:
    abortOnError false
}

只要在这里找到错误的原因并修复它。

yourProject/app/build/reports/lint-results-release-fatal.xml

这对我来说很管用,我只是像这样修改了我的BuildTypes:

buildTypes {
    release {
        android {
            lintOptions {
                checkReleaseBuilds false
                // Or, if you prefer, you can continue to check for errors in release builds,
                // but continue the build even when errors are found:
                abortOnError false
            }
        }
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}