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

我试图建立一个 APK,我可以上传到播放商店。

当我在 Android Studio (版本0.3.1)中选择 Build | Generate Signed APK... 时,我会被指向一个关于如何在“ gradle Build script”中正确设置签名过程的链接:

enter image description here

Http://tools.android.com/tech-docs/new-build-system/user-guide#toc-signing-configurations

不幸的是,在检查了那个页面之后,我不知道该编辑什么文件,以及该放入什么内容——我来自 Visual Studio 背景,所以懒惰地期望东西“只是工作”:)。

(在确认 Android Studio 的警告消息之后,A.S 打开了一个 Generate Signed APK Wizard,我浏览了一遍,传递了密钥的详细信息。由此产生的 APK 被 Play Store 拒绝,因为它有一个过早到期的密钥)。

我也尝试打开 Android Studio Terminal 窗口并运行“ gradle”,正如上面信息中指示的那样,但是没有找到这个命令。因此,顺便说一句,既然运行命令可能会做一些有用的事情,那么如何运行 gradle 呢?

我在 A.S.IDE 中找到了一个“ Gradle”窗口,并尝试构建在该窗口中找到的汇编释放目标。但是,Run 窗口的输出只显示“ 执行外部任务“组装发布”..。”。

155809 次浏览

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

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

Follow these steps in the IDE: 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. :)

enter image description here

enter image description here enter image description here

enter image description here enter image description here

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