如何在Android Studio中构建一个“发布”APK ?

时间:2021-10-09 20:49:13

I am trying to build an APK that I can upload to the Play Store.

我正在尝试建立一个APK,我可以上传到Play商店。

When I select Build|Generate Signed APK... in Android Studio (version 0.3.1), I am directed to a link on how to properly set up the signing process in the "gradle build scripts":

当我选择Build|生成签名APK…在Android Studio(0.3.1版本)中,我被引导到一个关于如何在“gradle build scripts”中正确设置签名过程的链接:

如何在Android Studio中构建一个“发布”APK ?

http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Signing-Configurations

http://tools.android.com/tech-docs/new-build-system/user-guide TOC-Signing-Configurations

Unfortunately, after checking that page I'm at a loss as to what file to edit and what to put in it - I'm coming from a Visual Studio background, so lazily expect stuff to 'just work' :).

不幸的是,在检查完这一页后,我对该编辑什么文件以及该如何放入文件感到茫然——我来自一个Visual Studio的背景,所以懒懒地期待一些东西“只工作”:)。

(After OK'ing Android Studio's warning message, A.S. brings up a Generate Signed APK Wizard, which I went through, passing my key's details. The resulting APK was rejected by the Play Store for having a key with a too-soon expiry-date).

(在OK'ing Android Studio的警告消息之后,A.S.出现了一个生成签名的APK向导,我通过它传递了我的密匙的详细信息。结果的APK被Play商店拒绝了,因为它有一个很快过期的键)。

I also tried bringing up the Android Studio Terminal window and running 'gradle', as instructed in the above message, but this command was not found. So as an aside, since perhaps running the command might do something useful, how would I run gradle?

我还尝试打开Android Studio终端窗口,按照上面的提示运行“gradle”,但是没有找到这个命令。顺便说一下,既然运行这个命令可能会做一些有用的事情,我该如何运行gradle呢?

I found a 'Gradle' window in the A.S. IDE, and tried building the assembleRelease target found in that window. However, the Run window output just shows "Executing external task 'assembleRelease'...".

我在A.S. IDE中找到了一个“Gradle”窗口,并试着在那个窗口中找到了安装程序。然而,运行窗口输出仅仅显示“执行外部任务‘汇编程序’…”。

3 个解决方案

#1


55  

Follow this steps:

参照下面的步骤:

-Build
-Generate Signed Apk
-Create new

Then fill up "New Key Store" form. If you wand to change .jnk file destination then chick on destination and give a name to get Ok button. After finishing it you will get "Key store password", "Key alias", "Key password" Press next and change your the destination folder. Then press finish, thats all. :)

然后填写“新密钥存储”表单。如果您想要更改.jnk文件目的地,那就在目标上给它一个名称来获取Ok按钮。完成后,您将获得“密钥存储密码”、“密钥别名”、“密钥密码”,然后按next并更改目标文件夹。然后按finish。:)

如何在Android Studio中构建一个“发布”APK ?

如何在Android Studio中构建一个“发布”APK ?如何在Android Studio中构建一个“发布”APK ?

如何在Android Studio中构建一个“发布”APK ?如何在Android Studio中构建一个“发布”APK ?

#2


18  

AndroidStudio is alpha version for now. So you have to edit gradle build script files by yourself. Add next lines to your build.gradle

AndroidStudio目前是alpha版本。所以你必须自己编辑等级构建脚本文件。在你的建筑上添加下一行

android {

    signingConfigs {

        release {

            storeFile file('android.keystore')
            storePassword "pwd"
            keyAlias "alias"
            keyPassword "pwd"
        }
    }

    buildTypes {

       release {

           signingConfig signingConfigs.release
       }
    }
}

To actually run your application at emulator or device run gradle installDebug or gradle installRelease.

要在仿真器或设备上实际运行应用程序,请运行等级安装调试或等级安装发布。

You can create helloworld project from AndroidStudio wizard to see what structure of gradle files is needed. Or export gradle files from working eclipse project. Also this series of articles are helpfull http://blog.stylingandroid.com/archives/1872#more-1872

您可以从AndroidStudio wizard创建helloworld项目,查看需要什么级别的文件结构。或从工作eclipse项目导出渐变文件。本系列文章也提供了帮助http://blog.stylingandroid.com/archives/1872#more-1872

#3


10  

Click \Build\Select Build Variant... in Android Studio. And choose release.

点击\制造\选择构建变体……在Android工作室。并选择释放。

#1


55  

Follow this steps:

参照下面的步骤:

-Build
-Generate Signed Apk
-Create new

Then fill up "New Key Store" form. If you wand to change .jnk file destination then chick on destination and give a name to get Ok button. After finishing it you will get "Key store password", "Key alias", "Key password" Press next and change your the destination folder. Then press finish, thats all. :)

然后填写“新密钥存储”表单。如果您想要更改.jnk文件目的地,那就在目标上给它一个名称来获取Ok按钮。完成后,您将获得“密钥存储密码”、“密钥别名”、“密钥密码”,然后按next并更改目标文件夹。然后按finish。:)

如何在Android Studio中构建一个“发布”APK ?

如何在Android Studio中构建一个“发布”APK ?如何在Android Studio中构建一个“发布”APK ?

如何在Android Studio中构建一个“发布”APK ?如何在Android Studio中构建一个“发布”APK ?

#2


18  

AndroidStudio is alpha version for now. So you have to edit gradle build script files by yourself. Add next lines to your build.gradle

AndroidStudio目前是alpha版本。所以你必须自己编辑等级构建脚本文件。在你的建筑上添加下一行

android {

    signingConfigs {

        release {

            storeFile file('android.keystore')
            storePassword "pwd"
            keyAlias "alias"
            keyPassword "pwd"
        }
    }

    buildTypes {

       release {

           signingConfig signingConfigs.release
       }
    }
}

To actually run your application at emulator or device run gradle installDebug or gradle installRelease.

要在仿真器或设备上实际运行应用程序,请运行等级安装调试或等级安装发布。

You can create helloworld project from AndroidStudio wizard to see what structure of gradle files is needed. Or export gradle files from working eclipse project. Also this series of articles are helpfull http://blog.stylingandroid.com/archives/1872#more-1872

您可以从AndroidStudio wizard创建helloworld项目,查看需要什么级别的文件结构。或从工作eclipse项目导出渐变文件。本系列文章也提供了帮助http://blog.stylingandroid.com/archives/1872#more-1872

#3


10  

Click \Build\Select Build Variant... in Android Studio. And choose release.

点击\制造\选择构建变体……在Android工作室。并选择释放。