Jan Kalfus
Jan Kalfus

Reputation: 5912

React Native Android release apk is debug, not release

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.

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. 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

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

Update:

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'
    }

Upvotes: 2

Views: 2108

Answers (1)

Samuli Hakoniemi
Samuli Hakoniemi

Reputation: 19059

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/

There's a flag --dev false

Upvotes: 4

Related Questions