从 Android Studio 中的 Gradle 项目导出未签名的 apk
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22269048/
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
Export unsigned apk from a Gradle Project in Android Studio
提问by Marian Klühspies
I usually create projects with Eclipse and import them into Android Studio, because I hate the project structure AS gives me. In it′s module settings, I have the possibility to create artifacts which allow me to output the built apk to a certain path.
我通常使用 Eclipse 创建项目并将它们导入 Android Studio,因为我讨厌 AS 给我的项目结构。在它的模块设置中,我可以创建工件,允许我将构建的 apk 输出到某个路径。
Now I have created a Gradle project directly with AS and it seems that those projects have quite less options than eclipse projects. I don′t find anything to output my apk and I don′t find any apk inside my project folder after building.
现在我已经直接用 AS 创建了一个 Gradle 项目,看起来这些项目的选项比 eclipse 项目少得多。我没有找到任何可以输出我的 apk 的东西,并且在构建后我的项目文件夹中也没有找到任何 apk。
How do I get my unsigned apk out of the build process??
如何让我的未签名 apk 退出构建过程?
回答by pyus13
Use
用
Build > Make Project
to build an apk file from Android Studio.
从 Android Studio 构建一个 apk 文件。
You can get your unsigned apk under the below path
您可以在以下路径下获取未签名的 apk
$YOUR_PROJECT/$YOUR_MODULE/build/apk
unsigned apk files will have "unsigned" text in their names.
未签名的 apk 文件的名称中将包含“未签名”文本。
[ UPDATE ] :
[ 更新 ] :
In Recent release of Android Studio you will not get apk file on sysncing or Make Project. There are two other methods in order to get the apk file
在 Android Studio 的最新版本中,您不会在 sysncing 或 Make Project 上获得 apk 文件。还有另外两种方法可以获取apk文件
- Run the app
- Execute assemble Task from Gradle panel present in right hand side of Studio window or from embedded terminal window on bottom(in project Root)
- 运行应用程序
- 从 Studio 窗口右侧的 Gradle 面板或从底部的嵌入式终端窗口(在项目根目录中)执行 assemble Task
gradlew assembleDebug(or whatever build varient you want a build for)
gradlew assembleDebug(或您想要构建的任何构建变体)
and the update new apk path will be
并且更新新的 apk 路径将是
$YOUR_PROJECT/$YOUR_MODULE/build/outputs/apk
This has been done by Android Tools team to improve the Android Studio performance.
这已由 Android 工具团队完成,以提高 Android Studio 的性能。
回答by kaolick
The above answer of pyus13 did not work for me (Android Studio 0.8.1).
pyus13 的上述答案对我不起作用(Android Studio 0.8.1)。
Instead use
而是使用
Run > Run "YourProject"
to build the code and create the unsigned apk. You can find your apk file under
构建代码并创建未签名的 apk。您可以在下面找到您的 apk 文件
$YOUR_PROJECT/$YOUR_MODULE/build/outputs/apk
UPDATE
更新
Still works with Android Studio 1.5.1 You only get new APKs when you have code changes since you last built your code.
仍然适用于 Android Studio 1.5.1 只有在自上次构建代码以来发生代码更改时,您才会获得新的 APK。
回答by Stefano
Open Gradle panel, open the tasks list of your project and double click on BUILD task, then under " -> build -> outputs -> apk" you will find your unsigned APK with name -release-unsigned.apk
打开 Gradle 面板,打开你项目的任务列表,双击 BUILD 任务,然后在“-> 构建 -> 输出 -> apk”下你会找到你的未签名 APK,名称为 -release-unsigned.apk
回答by bbodenmiller
As of Android Studio 1.5 you can now generate an APK using
从 Android Studio 1.5 开始,您现在可以使用生成 APK
Build > Build APK
Which you can then find under
然后你可以在下面找到
$YOUR_PROJECT/$YOUR_MODULE/build/outputs/apk.
$YOUR_PROJECT/$YOUR_MODULE/build/outputs/apk.
Edit: New Android Studio gives this Path:
编辑:新的 Android Studio 给出了这个路径:
$YOUR_PROJECT/$YOUR_MODULE/build/outputs/apk.
回答by user3889585
It is also possible to build an apk by using the command line (Android Terminal).
也可以使用命令行(Android 终端)构建 apk。
- Choose the Terminal in Android Studio - very bottom next to Android Monitor and Version Control
- Build apk with command Windows: gradlew.bat assembleRelease Mac: ./gradlew assembleRelease
- Find unsigned apk file - /app/build/outputs/apk/app-release-unsigned.apk
- 在 Android Studio 中选择终端 - Android Monitor 和 Version Control 旁边的最底部
- 使用 Windows 命令构建 apk:gradlew.bat assembleRelease Mac:./gradlew assembleRelease
- 查找未签名的 apk 文件 - /app/build/outputs/apk/app-release-unsigned.apk
Tested in Android 1.5
在 Android 1.5 中测试
回答by liruqi
Edit app.gradle buildTypesblock, set
编辑 app.gradle buildTypes块,设置
signingConfig null
Then rebuild.
然后重建。