使用 Android Studio 构建未签名的 APK 文件 [英] Build unsigned APK file with Android Studio
问题描述
我正在使用 Android Developer Tool 开发 Android 应用.现在我尝试了新的Android Studio,如果将我的智能手机与PC连接并直接在Android Studio中运行程序,一切正常.但现在我想用其他智能手机测试该程序,而无需将它们连接到我的电脑.
I'm developing an Android app with the Android Developer Tool. Now I tried the new Android Studio, everything works fine if connect my smartphone with the PC and directly run the program in the Android Studio. But now I want to test the program with other smartphones without connecting them to my PC.
ADT 在projectname/bin"下创建 .apk 文件.每次编译程序时.我目前的看法是,Android Studio 不会这样做.
The ADT creates the .apk file under "projectname/bin" every time you compile the program. How I see it at the moment, Android Studio doesn't do that.
所以,我的问题是:是否可以使用 Android Studio 创建一个未签名的 .apk 文件?
So, my question is: Is it possible to create an unsigned .apk file with Android Studio?
推荐答案
我建议你使用 Gradle 构建你的 APK 文件:
I would recommend you to build your APK file with Gradle:
- 点击顶部工具栏中的下拉菜单(打开编辑运行/调试配置"对话框)
- 选择编辑配置"
- 点击+"
- 选择Gradle"
- 选择您的模块作为 Gradle 项目
- 在任务中:输入
assemble
- 按运行
您未签名的 APK 现在位于
Your unsigned APK is now located in
ProjectName\app\build\outputs\apk
有关如何使用 Gradle 的详细信息,本教程很不错:在 Android Studio 中使用 Gradle 构建.我还写了一篇关于如何构建未签名的博客文章带有 Gradle 的 APK.
For detailed information on how to use Gradle, this tutorial is good to go: Building with Gradle in Android Studio. I also wrote a blog post on how to build an unsigned APK with Gradle.
如果您从其他 IDE 移动项目并且不想重新编译,您可能会发现您的 APK 文件已经在您移动的 IDE 中构建:
If you moved your project from the other IDE and don't want to recompile, you may find your APK file that was already built in the IDE you moved from:
如果您使用 Android Studio 生成项目,APK 文件将在
ProjectName/ProjectName/build/apk/...
从eclipse导入项目:文件应该在同一个目录下.转到 Project
- 在资源管理器中显示
.您应该在那里找到您的 APK 文件所在的 bin 文件夹.
Imported the project from eclipse: File should be in the same directory. Go to Project
- Show in Explorer
. There you should find the bin folder where your APK file is located in.
从 IntelliJ 导入,位置为 ProjectName/out/production/...
Imported from IntelliJ, the location would be ProjectName/out/production/...
旁注:正如 Chris Stratton 在评论中提到的:
Side note: As Chris Stratton mentioned in his comment:
从技术上讲,您需要的是使用调试密钥签名的 APK.一个 APK实际上未签名的将被设备拒绝.
Technically, what you want is an APK signed with a debug key. An APK that is actually unsigned will be refused by the device.
这篇关于使用 Android Studio 构建未签名的 APK 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!