如何从我的react-native项目构建android apk?这个命令"react-native run-android“在文件夹android\app\build\output\apk\上创建app-debug.apk,但是当我把它安装到我的手机上时,我得到了一个错误"Unable to download JS bundle”。当我第一次在模拟器上启动时,我使用命令来解决这个问题:
react-native start curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
发布于 2016-02-17 09:10:50
这都是用here写的。
你需要首先生成签名密钥,然后将它们设置为变量,使用它们来配置你的应用程序,然后创建一个签名的apk。
如果你在这个过程中需要任何帮助,我很乐意帮助你。但是检查一下文档,它们写得很好。
发布于 2019-11-05 07: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
发布于 2018-12-24 13:58:40
一个更简单的方法是,如果你有一些Android Studio的使用经验+ "Android“过去的经验,
即使你对Android Studio没有任何经验,我也给出了一步一步的变通方法,上面也提到了Android Studio的设置链接:
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.
https://stackoverflow.com/questions/35450777
复制相似问题