React Native Android 发布 apk 是调试,而不是发布 [英] React Native Android release apk is debug, not release

查看:28
本文介绍了React Native Android 发布 apk 是调试,而不是发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个现有的 Android 应用.我已根据 docs(除了我用 AppCompatActivity 替换了 Activity 类).在开发模式下一切正常.但是当我创建应用程序的发布版本时,应用程序的 React Native 部分似乎仍处于调试模式,当我打开由 React Native 驱动的活动时,我在 logcat 中收到以下错误消息:

I have an existing Android app. I've added React Native v0.30 activity to the project according to the docs (except I replaced Activity class with AppCompatActivity). 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:

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

这意味着应用正在尝试连接到打包程序,而不是以某种方式使用 bundle.

Which means that the app is trying to connect to the packager instead of using bundle somehow.

APK 正在签名,本机应用程序以其他方式构建为发布.我是否必须以某种方式手动创建 JavaScript 包并将其添加到项目中?我是否遗漏了一些明显的东西?

The APK is getting signed, the native app is otherwise built as release. Do I have to somehow create the JavaScript bundle manually and add it to the project? Am I missing something obvious?

我正在使用以下命令构建和部署应用程序:

I'm building and deploying the app using the following command:

cd android && ./gradlew installRelease

我认为这应该将 JavaScript 文件捆绑到 APK 中,并在 Activity 启动时使用它们.

I thought that this should bundle the JavaScript files into the APK and that they'll be used when the activity is launched.

更新:

顺便说一句,我在应用程序的 gradle 配置中的 buildTypes 中有这个:

BTW I've got this in my buildTypes in the app's gradle config:

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

推荐答案

你在 installRelease 之前执行过这个:

Have you executed this before 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/

有一个标志--dev false

这篇关于React Native Android 发布 apk 是调试,而不是发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆