生成签名的apk android studio

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20268520/
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 02:33:08  来源:igfitidea点击:

Generate signed apk android studio

androidandroid-studio

提问by Chinmay Dabke

I am new to android development and just finished my first app. I want to generate a signed apk in android studio. I read the developer docs but couldn't understand the steps. When I click on Build>Generate Signed APK..., it shows me a dialog box asking the following:

我是 android 开发的新手,刚刚完成了我的第一个应用程序。我想在 android studio 中生成一个签名的 apk。我阅读了开发人员文档,但无法理解这些步骤。当我单击 时Build>Generate Signed APK...,它会显示一个对话框,询问以下内容:

Keystore path  //with two options create new and choose existing
Keystore password
Key alias
key password

I don't get what is keystore even after googling it. When I choose create newit asks me to select a path and locate a .jksfile which I don't have! Can anyone please explain and list the steps in order to generate a signed apk.

即使在谷歌搜索之后我也不明白什么是密钥库。当我选择时,create new它会要求我选择一个路径并找到一个.jks我没有的文件!任何人都可以解释并列出生成签名apk的步骤。

采纳答案by VJ Vélan Solutions

Use Keytool binary or exe to generate a private keystore. Instructions here. You can then sign your app using this keystore. Keytool gets installed when you install Java.

使用 Keytool 二进制文件或 exe 生成私有密钥库。说明在这里。然后,您可以使用此密钥库对您的应用程序进行签名。安装 Java 时会安装 Keytool。

NOTE: Save/backup this keystore because once you publish an app on play by signing it with this keystore, you will have to use the same keystore for any future updates. So, it's important that you back it up.

注意:保存/备份此密钥库,因为一旦您通过使用此密钥库对其进行签名来发布正在播放的应用程序,您将必须使用相同的密钥库来进行任何未来的更新。因此,备份它很重要。

HTH.

哈。

回答by Hymanspicer

I dont think anyone has answered the question correctly.So, for anyone else who has the same question, this should help :

我认为没有人正确回答了这个问题。所以,对于其他有同样问题的人,这应该会有所帮助:

Step 1Go to Build>Generate Signed APK>Next (module selected would be your module , most often called "app")

步骤 1转到 Build>Generate Signed APK>Next(选择的模块将是您的模块,通常称为“应用程序”)

Step 2Click on create new

第二步点击新建

Step 3Basically, fill in the form with the required details. The confusing bit it is where it asks for a Key Store Path. Click on the icon on the right with the 3 dots ("..."), which will open up a navigator window asking you to navigate and select a .jks file.Navigate to a folder where you want your keystore file saved and then at the File Namebox at the bottom of that window, simply enter a name of your liking and the OK button will be clickable now. What is happening is that the window isnt really asking you chose a .jks file but rather it wants you to give it the location and name that you want it to have.

第 3 步基本上,用所需的详细信息填写表格。令人困惑的一点是它要求Key Store Path。单击右侧带有 3 个点(“...”)的图标,这将打开一个导航器窗口,要求您导航并选择 .jks 文件。导航到要保存密钥库文件的文件夹,然后在该窗口底部的“文件名”框中,只需输入您喜欢的名称,现在就可以单击“确定”按钮。发生的情况是该窗口并没有真正要求您选择 .jks 文件,而是希望您为其提供您希望它拥有的位置和名称。

Step 4Click on Nextand then select Releaseand Voila ! you are done.

第 4 步单击Next,然后选择Release和 Voila!你完成了。

回答by Ajay S

Read this my answer here

在这里阅读我的答案

How do I export a project in the Android studio?

如何在 Android Studio 中导出项目?

This will guide you step by step to generate signed APK and how to create keystore file from Android Studio.

这将指导您逐步生成已签名的 APK 以及如何从 Android Studio 创建密钥库文件。

From the link you can do it easily as I added the screenshot of it step by step.

从链接中您可以轻松完成,因为我逐步添加了它的屏幕截图。

Short answer

简答

If you have Key-store file then you can do same simply.

如果您有密钥库文件,那么您可以简单地做同样的事情。

Go to Build then click on Generate Signed APK

转到 Build 然后单击 Generate Signed APK

回答by GaRRaPeTa

The "official" way to configure the build.gradle file as recommended by Google is explained here.

此处解释了 Google 推荐的配置 build.gradle 文件的“官方”方法。

Basically, you add a signingConfig, in where you specify the location an password of the keystore. Then, in the release build type, refer to that signing configuration.

基本上,您添加了一个signatureConfig,在其中指定密钥库的密码的位置。然后,在发布构建类型中,参考该签名配置。

...
android {
    ...
    defaultConfig { ... }
    signingConfigs {
        release {
            storeFile file("myreleasekey.keystore")
            storePassword "password"
            keyAlias "MyReleaseKey"
            keyPassword "password"
        }
    }
    buildTypes {
        release {
            ...
            signingConfig signingConfigs.release
        }
    }
}
...

回答by Tony Baby

  1. Go to Build-> Generate Signed APKin Android Studio.
  2. In the new window appeared, click on Create new...button.
  3. Next enter details as like shown below and click OK-> Next. enter image description here
  4. Select the Build Typeas releaseand click Finishbutton.
  5. Wait until APK generated successfullymessage is displayed as like shown below.enter image description here
  6. Click on Show in Explorerto see the signed APK file.
  1. 在 Android Studio 中转到Build-> Generate Signed APK
  2. 在出现的新窗口中,单击Create new...按钮。
  3. 接下来输入如下所示的详细信息,然后单击OK-> Next在此处输入图片说明
  4. 选择Build Type作为release并单击Finish按钮。
  5. 等到APK 生成成功消息显示如下。在此处输入图片说明
  6. 单击在资源管理器中显示以查看已签名的 APK 文件。

For more details go to thislink.

有关更多详细信息,请访问链接。

回答by cubeloid

I had the same problem. I populated the field with /home/tim/android.jks file from tutorial thinking that file would be created. and when i would click enter it would say cant find the file. but when i would try to create the file, it would not let me create the jks file. I closed out of android studio and ran it again and it worked fine. I had to hit the ... to correctly add my file. generate signed apk wizard-->new key store-->hit ... choose key store file. enter filename I was thinking i was going to have to use openjdk and create my own keyfile, but it is built into android studio

我有同样的问题。我使用教程中的 /home/tim/android.jks 文件填充该字段,认为将创建该文件。当我点击回车时,它会说找不到文件。但是当我尝试创建文件时,它不会让我创建 jks 文件。我关闭了 android studio 并再次运行它,它运行良好。我必须点击 ... 才能正确添加我的文件。生成签名apk向导-->新密钥库-->点击...选择密钥库文件。输入文件名我想我将不得不使用 openjdk 并创建我自己的密钥文件,但它内置于 android studio

回答by Joolah

you can add this to your build gradel

您可以将其添加到您的构建等级中

android {
    ...
    defaultConfig { ... }
    signingConfigs {
        release {
            storeFile file("my.keystore")
            storePassword "password"
            keyAlias "MyReleaseKey"
            keyPassword "password"
        }
    }
    buildTypes {
        release {
            ...
            signingConfig signingConfigs.release
        }
    }
}

if you then need a keyHash do like this via android stdio terminal on project root folder

如果你需要一个keyHash,请通过项目根文件夹上的android stdio终端执行此操作

keytool -exportcert -alias my.keystore -keystore app/my.keystore.jks | openssl sha1 -binary | openssl base64

回答by Karl Johan Vallner

Official Android Documentation on the matter at hand with a step-by-step guide included on how to generate signed APK keys in Android Studio and even on how to setup the automatic APK key generation in a Gradle build.

关于手头问题的官方 Android 文档,其中包含有关如何在 Android Studio 中生成签名 APK 密钥,甚至如何在 Gradle 构建中设置自动 APK 密钥生成的分步指南。

https://developer.android.com/studio/publish/app-signing.html

https://developer.android.com/studio/publish/app-signing.html

Look under the chapter: Sign your release build

查看章节:签署您的发布版本