首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何从我的react-native项目构建android apk?

如何从我的react-native项目构建android apk?
EN

Stack Overflow用户
提问于 2016-02-17 15:52:43
回答 3查看 18.9K关注 0票数 8

如何从我的react-native项目构建android apk?这个命令"react-native run-android“在文件夹android\app\build\output\apk\上创建app-debug.apk,但是当我把它安装到我的手机上时,我得到了一个错误"Unable to download JS bundle”。当我第一次在模拟器上启动时,我使用命令来解决这个问题:

代码语言:javascript
运行
复制
react-native start curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2016-02-17 17:10:50

这都是用here写的。

你需要首先生成签名密钥,然后将它们设置为变量,使用它们来配置你的应用程序,然后创建一个签名的apk。

如果你在这个过程中需要任何帮助,我很乐意帮助你。但是检查一下文档,它们写得很好。

票数 4
EN

Stack Overflow用户

发布于 2019-11-05 15:27:27

生成APK

手动创建调试版本的捆绑包的

  • react-native bundle --dev false --platform android --entry-file index.js --bundle-output ./android/app/src/main/assets/index.android.bundle --assets-dest ./android/app/src/main/res

要在捆绑后构建APK

  • cd android
  • ./gradlew assembleDebug
  • ./gradlew assembleRelease
票数 7
EN

Stack Overflow用户

发布于 2018-12-24 21:58:40

一个更简单的方法是,如果你有一些Android Studio的使用经验+ "Android“过去的经验,

即使你对Android Studio没有任何经验,我也给出了一步一步的变通方法,上面也提到了Android Studio的设置链接:

代码语言:javascript
运行
复制
1. Open your Android Studio.
2. Click "File" in the top Menu bar.
3. Click "New Option" and "Import Project".
4. Navigate to your React Native Project's Folder -> android -> app 5.Click "Ok" button at the bottom of the Dialog.
5. Now wait for few minutes before Android Studio completes its process.
6. Once Done, Click on "Build" in the top Menu Bar.
7. Click on the Generate Signed APK option.
8. Now, if you have a existing key store path, you are good to go, if not then click the "Create New" button, and enter data in the fields.
9. Fill in the "Key store Password", "Key alias", and "Key Password" and click "Next" button at the bottom of the Dialog.
10. Select the Build Type from the Drop down menu, "Debug" or "Release".
11. Check the Signature versions v1, v2 according to you requirements(v1,v2 both are usually checked when you make a build in android).
12. Click on Finish.
13. Now wait for few minutes before the Android Studio completes its process of making an Android APK of your app.
14. Once Done , You can find your React Native App's Android APK file in the : "YOURPROJECT/android/app/debug" folder, or in case of Release Build in the: "YOURPROJECT/android/app/release" folder.

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35450777

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档