Android:如何禁用调试以上传 apk

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20706951/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 03:19:21  来源:igfitidea点击:

Android: How to disable debugging to upload the apk

androiddebugginguploadandroid-studio

提问by cross_flame

When I try to upload my app in Google Play I get this error.

当我尝试在 Google Play 中上传我的应用时,出现此错误。

Upload failed

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.

上传失败

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

I compile my app with Android Studio 0.4.0

我用 Android Studio 0.4.0 编译我的应用程序

I tried to set this in my Manifest.xml - Android:debuggable="false", but nothing happened. When I tried to set this <option name="SOURCE_GEN_TASK_NAME" value="generateReleaseSources" />in .iml file, and again nothing.

我试图在我的 Manifest.xml - 中设置它Android:debuggable="false",但什么也没发生。当我试图<option name="SOURCE_GEN_TASK_NAME" value="generateReleaseSources" />在 .iml 文件中设置它时,又什么都没有。

I tried and with this in build.gradle,and again nothing.

我尝试在 build.gradle 中使用它,但再次没有。

android {
    signingConfigs {
        debug {
            storeFile file("horoskopSms.jks")
            storePassword "1q2w3e"
            keyAlias "horoskopSms"
            keyPassword "1q2w3e"
        }
    }
}

My.iml file

我的.iml文件

<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE"    type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android" name="Android">
  <configuration>
    <option name="SELECTED_BUILD_VARIANT" value="debug" />
    <option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
    <option name="COMPILE_JAVA_TASK_NAME" value="compileDebugJava" />
    <option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
    <option name="SOURCE_GEN_TASK_NAME" value="generateReleaseSources" />
    <option name="ALLOW_USER_CONFIGURATION" value="false" />
    <option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
    <option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
    <option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
    <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
    <option name="APK_PATH" value="/build/apk/HoroskopSms-debug-unaligned.apk" />
  </configuration>
</facet>
     <facet type="android-gradle" name="Android-Gradle">
     <configuration>
     <option name="GRADLE_PROJECT_PATH" value=":HoroskopSms" />
  </configuration>
</facet>
  </component>
           <component name="NewModuleRootManager" inherit-compiler-output="false">
        <output url="file://$MODULE_DIR$/build/classes/debug" />
      <exclude-output />
     <content url="file://$MODULE_DIR$">
   <sourceFolder url="file://$MODULE_DIR$/build/source/r/debug" isTestSource="false" />
  <sourceFolder url="file://$MODULE_DIR$/build/source/aidl/debug" isTestSource="false" />

<sourceFolder url="file://$MODULE_DIR$/build/source/buildConfig/debug"         isTestSource="false" />
 <sourceFolder url="file://$MODULE_DIR$/build/source/rs/debug" isTestSource="false" />
     <sourceFolder url="file://$MODULE_DIR$/build/res/rs/debug" type="java-resource" />
  <sourceFolder url="file://$MODULE_DIR$/build/source/r/test/debug" isTestSource="true" />
  <sourceFolder url="file://$MODULE_DIR$/build/source/aidl/test/debug" isTestSource="true" />
  <sourceFolder url="file://$MODULE_DIR$/build/source/buildConfig/test/debug" isTestSource="true" />
  <sourceFolder url="file://$MODULE_DIR$/build/source/rs/test/debug" isTestSource="true" />
  <sourceFolder url="file://$MODULE_DIR$/build/res/rs/test/debug" type="java-test-resource" />
  <sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
  <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" isTestSource="false" />
  <sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
  <sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
  <sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
  <sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
  <sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
  <sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
  <sourceFolder url="file://$MODULE_DIR$/src/main/assets" isTestSource="false" />
  <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
  <sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
  <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
  <sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
  <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
  <sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/aidl" isTestSource="true" />
  <sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/assets" isTestSource="true" />
  <sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/java" isTestSource="true" />
  <sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/jni" isTestSource="true" />
  <sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/rs" isTestSource="true" />
  <sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/res" type="java-test-resource" />
  <sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/resources" type="java-test-resource" />
  <excludeFolder url="file://$MODULE_DIR$/build/apk" />
  <excludeFolder url="file://$MODULE_DIR$/build/assets" />
  <excludeFolder url="file://$MODULE_DIR$/build/bundles" />
  <excludeFolder url="file://$MODULE_DIR$/build/classes" />
  <excludeFolder url="file://$MODULE_DIR$/build/dependency-cache" />
  <excludeFolder url="file://$MODULE_DIR$/build/incremental" />
  <excludeFolder url="file://$MODULE_DIR$/build/libs" />
  <excludeFolder url="file://$MODULE_DIR$/build/manifests" />
  <excludeFolder url="file://$MODULE_DIR$/build/res" />
  <excludeFolder url="file://$MODULE_DIR$/build/symbols" />
  <excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-v4-19.0.0" level="project" />
<orderEntry type="library" exported="" name="ComAndroidSupportAppcompatV71900.aar" level="project" />
<orderEntry type="library" exported="" name="FortumoInApp-android-9.1.0" level="project" />
</component>
       </module>

回答by cross_flame

I found a solution in Android Studio, I go to "Build variants" and change it from debbug to release.

我在 Android Studio 中找到了一个解决方案,我转到“构建变体”并将其从 debbug 更改为 release。

回答by Scott Barta

There's a debuggableproperty you can set in a build type in your build.gradlefile; that will supersede any setting in your manifest. You haven't done anything there, have you? The debuggable property of your release build should already be false.

debuggable您可以在build.gradle文件的构建类型中设置一个属性;这将取代清单中的任何设置。你在那里什么都没做,是吗?您的发布版本的 debuggable 属性应该已经是 false。

Which build are you trying to upload to Google Play? If you're uploading the debug build, then that's your problem -- upload the release build instead.

您想将哪个版本上传到 Google Play?如果您要上传调试版本,那么这就是您的问题——请上传发布版本。

回答by Gabriele Mariotti

You should not use the debugas BuildVariant to sign and export your apk in Google Play.

您不应该使用调试作为 BuildVariant 来签署和导出您在 Google Play 中的 apk。

You should use the ReleaseBuildVariant. Gradle has some default values, as debuggable that you have to override in your build.gradle (these values override the properties in AndroidManifest).

您应该使用ReleaseBuildVariant。Gradle 有一些默认值,作为可调试的,您必须在 build.gradle 中覆盖这些值(这些值覆盖 AndroidManifest 中的属性)。

Change your build.gradle, switch to Release as BuildVariant(on the left edge) and export your apk.

更改您的 build.gradle,切换到 Release as BuildVariant(在左边缘)并导出您的 apk。

android {
    signingConfigs {
        release {
            storeFile file("horoskopSms.jks")
            storePassword "1q2w3e"
            keyAlias "horoskopSms"
            keyPassword "1q2w3e"
        }
   }
}

回答by Ahmed

This is because you did not configure your gradle correctly. Please check this link please http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Signing-Configurations

这是因为您没有正确配置您的 gradle。请检查此链接 http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Signing-Configurations

回答by Harsh Shah

this code worked for me

这段代码对我有用

change debuggable false and minifyEnabled false insted of true like below code in your app level build.gradle file

更改 debuggable false 和 minifyEnabled false 插入 true 如下面的代码在您的应用程序级别 build.gradle 文件中

 buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        debuggable false
        signingConfig signingConfigs.firstapp
    }
}

回答by Yeuni

On Android studio just Click build then choose Generate Signed Apk...enter your credentials and other info related to your app & then its done.

在 Android Studio 上,只需单击构建,然后选择生成签名的 Apk...输入您的凭据和其他与您的应用程序相关的信息,然后就完成了。