简体   繁体   English

React Native Android版本APK是调试版本,而不是版本

[英]React Native Android release apk is debug, not release

I have an existing Android app. 我有一个现有的Android应用程序。 I've added React Native v0.30 activity to the project according to the docs (except I replaced Activity class with AppCompatActivity ). 我已经根据文档将React Native v0.30活动添加到了项目中(除了我用AppCompatActivity替换了Activity类)。 Everything works fine in development mode. 在开发模式下一切正常。 But when I create release build of the app, it looks like the React Native part of the app is still in debug mode, I get the following error message in logcat when I open the React Native-powered activity: 但是,当我创建应用程序的发布版本时,看起来该应用程序的React Native部分仍处于调试模式,当我打开由React Native驱动的活动时,我在logcat中收到以下错误消息:

java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Could not connect to development server.

Which means that the app is trying to connect to the packager instead of using bundle somehow. 这意味着该应用程序正在尝试连接到打包程序,而不是以某种方式使用捆绑软件。

The APK is getting signed, the native app is otherwise built as release. APK已签名,否则本机应用将作为发行版构建。 Do I have to somehow create the JavaScript bundle manually and add it to the project? 我是否必须以某种方式手动创建JavaScript捆绑包并将其添加到项目中? Am I missing something obvious? 我是否缺少明显的东西?

I'm building and deploying the app using the following command: 我正在使用以下命令构建和部署应用程序:

cd android && ./gradlew installRelease

I thought that this should bundle the JavaScript files into the APK and that they'll be used when the activity is launched. 我认为这应该将JavaScript文件捆绑到APK中,并在启动活动时使用它们。

Update: 更新:

BTW I've got this in my buildTypes in the app's gradle config: 顺便说一句,我已经在应用程序的gradle配置中的buildTypes中找到了它:

    release {
        signingConfig signingConfigs.release
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }

Have you executed this before installRelease : installRelease之前是否执行过此installRelease

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

There's a flag --dev false 有一个标志--dev false

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM