简体   繁体   English

在 Android Studio 中生成签名的 APK

[英]Generate Signed APK in Android Studio

There are a few questions related to my question in Stackoverflow, such as:我在Stackoverflow中的问题有几个相关的问题,比如:

How do I export a project in the Android studio? 如何在 Android Studio 中导出项目?

How to create a release signed apk file using Gradle 如何使用 Gradle 创建发布签名的 apk 文件

They're good.他们很好。 But Still make me confused.但还是让我很困惑。 When I selected Build->Generate signed APK in Android Studio, I got this warning message:当我在 Android Studio 中选择 Build->Generate signed APK 时,我收到以下警告消息:

在此处输入图片说明

What does this mean?这是什么意思? Does it mean I have to use gradle command line by config the build.gradle?这是否意味着我必须通过配置 build.gradle 来使用 gradle 命令行? Then what is the wizard for?那么法师有什么用呢? If I just ignore the warning by click ok and follow the wizard to generate the apk file, I'll get error message saying the apk is in debug mode when I upload the apk to Google Play.如果我只是通过单击确定忽略警告并按照向导生成 apk 文件,当我将 apk 上传到 Google Play 时,我会收到错误消息,指出 apk 处于调试模式。

If I follow the instruction to setup the build.gradle like this:如果我按照说明设置 build.gradle 是这样的:

 signingConfigs {

        debug {
            storeFile file("debug.keystore")
        }

        release {
            storeFile file("../key/test.keystore")
            storePassword "password"
            keyAlias "key"
            keyPassword "password"
        }
    }

    buildTypes {
        release {
            debuggable false
            signingConfig signingConfigs.release
        }
    }

And everything is file when I run ./gradlew assembleRelease in terminal.当我在终端中运行 ./gradlew assembleRelease 时,一切都是文件。

In summary, I'm confused at:总之,我很困惑:

  1. What is the purpose of "Generate signed APK" wizard if I have to setup the build.gradle如果我必须设置 build.gradle,“生成签名的 APK”向导的目的是什么
  2. How to build my application in release mode when I run "Generate signed APK"运行“生成签名的 APK”时如何在发布模式下构建我的应用程序

Thank you for any suggestion.谢谢你的任何建议。

In left bottom corner of Android Studio, select the Build Variances, then you can change the build mode to "release".在 Android Studio 的左下角,选择 Build Variances,然后您可以将构建模式更改为“发布”。 When building in release mode, I think the "Generate Signed APK" wizard works.在发布模式下构建时,我认为“生成签名 APK”向导有效。 So just ignore the build.gradle configuration!所以只需忽略 build.gradle 配置!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM