如何在不要求开发设置服务器IP的情况下生成开发APK文件?[英] How to generate dev APK file without asking for dev settings server ip in react native

本文是小编为大家收集整理的关于如何在不要求开发设置服务器IP的情况下生成开发APK文件?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我能够使用Android Studio生成APK(未签名的APK)文件.如果我安装该APK,那么我们需要在DEV设置中输入DEV服务器IP地址,然后只有应用程序工作.现在如何生成APK,而无需提供任何服务器IP?

谢谢.

推荐答案

用于调试APK,您需要手动创建调试构建的捆绑包,并使用Gradlew生成APK.

react-native bundle --dev false --platform android --entry-file index.android.js --bundle-output ./android/app/build/intermediates/assets/debug/index.android.bundle --assets-dest ./android/app/build/intermediates/res/merged/debug
cd android
./gradlew assembleDebug

生成的apk将位于android/app/build/outputs/apk

此APK在调试模式下运行.如果振动设备并尝试开发设置菜单以进行重新加载,则需要服务器IP.但是你可以解雇消息.您的应用程序将正常工作.

您还可以生成APK以用于发布模式.它不需要任何IP而不显示任何开发设置.

在释放模式下生成apk

cd android
./gradlew assembleRelease

本文地址:https://www.itbaoku.cn/post/1938016.html

问题描述

I am able to generate APK(not signed APK) file using android studio. if i install that apk then we need to enter Dev server ip address in dev settings then only app working. Now how to generate apk without need of giving any server ip?

Thanks.

推荐答案

For debug apk you need to manually create the bundle for a debug build and generate apk using gradlew.

react-native bundle --dev false --platform android --entry-file index.android.js --bundle-output ./android/app/build/intermediates/assets/debug/index.android.bundle --assets-dest ./android/app/build/intermediates/res/merged/debug
cd android
./gradlew assembleDebug

Generated apk will be located at android/app/build/outputs/apk

This apk run in debug mode. If you shake device and try dev setting menu for reload, It required server IP. but you can dismiss message. Your app will work properly.

You can also generate apk for release mode. It not required any IP and not show any dev setting.

To generate apk in release mode

cd android
./gradlew assembleRelease