如何解决调试和发布 apk 在 React Native 0.63.3 中不起作用
我正在使用以下步骤来构建调试和发布 apk
- cd android && ./gradlew clean && cd ..
- cd android && ./gradlew cleanBuildCache && cd ..
- npx react-native bundle --platform android --dev true --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android /app/src/main/res --verbose
- cd android && ./gradlew assembleDebug && cd .. 或 cd android && ./gradlew assembleRelease && cd ..
apk 生成成功。但是当我运行它们时,我总是得到这个。
但是,如果我启动 Metro-server,该应用程序可以正常工作,但不能正常运行 debug-apk。
任何帮助将不胜感激。
安卓配置:
buildToolsVersion = "29.0.2"
minSdkVersion = 23
compileSdkVersion = 29
targetSdkVersion = 29
classpath 'com.google.gms:google-services:4.1.0'
清单
<application
android:name=".MainApplication"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
>
app 的 build.gradle
project.ext.react = [
entryFile: "index.js",bundleAssetName: "index.android.bundle",enableHermes: false,// clean and rebuild if changing
devDisabledInDev: true,// Disable dev server in dev release
bundleInDev: true,// add
bundleInDebug: true
]
谢谢
解决方法
在项目目录的终端中:-
cd android
然后./gradlew clean
然后cd ..
然后
//创建包npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
然后
//创建调试版本npx react-native run-android variant=debug
和
//创建发布版本npx react-native run-android variant=release
注意:- 确保您之前已经在项目根目录中运行了 npm start
。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。