简体   繁体   中英

Android App crashes on launch after downloading from Google Play

The app is made with React Native, and it's running fine in both simulators/emulators.

Also on iPhone (through usb... on debug mode).

I couldn't try it on Android (there was no "Build number" !?).

I haven't upload it yet to "App Store"...

But when I download it from "Google Play" the app crashes on launch.

Note: I "use the signing/keytool UI that's part of Android Studio" to generate the APK.

  1. I've found this: Support third-party 64-bit libraries on Android.

    And I tried this solution: Mixing 32- and 64-bit Dependencies in Android.

    And some other similar to the above...

  2. I tried deleting the ios and android files and then run ios and android again...

  3. Also, tried to upload an "Android App Bundle" instead of APK (with this the app wouldn't even download... not just pending. There was only the spinner to see...

So, nothing worked!

Then I realised I get an error message on the Android device which was:

java.lang.RuntimeException: Unable to load script. Make sure you're either running a Metro server or that your bundle index.android.bundle is packaged correctly for release.

在此处输入图片说明

I've found this: Release APK fails immediately on launch.

I want to try the following comment, but I don't understand it.

@alexmbp

Well. It's working with

1 react-native run-android --variant=release

2 and with ./gradlew assembleRelease and configuring signing.

3 Also I've updated gradle and should set android.enableAapt2=false.

Probably issue connected with gradle update.

Could someone please explain...

I think 1 is just a command in terminal.

But what is 2 and 3?

Thanks :)

Run the following command in the react native directory of your project and then build your app after that:

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

  • Change the bold text to your app directory
  • Change the italic text to what you named the bundle file in your configurations

Hope this helps. Happy Coding!

The native bundle is not created by default if you are using a debug build. Instead it is expecting that you're running the bundler on your computer and the phone is connected to your computer.

You should build for release anyway ( gradle assembleRelease ) when submitting to the Play Store, but you can also have it generate the bundle in debug by adding the following to your android/app/build.gradle file:

project.ext.react = [
        entryFile: "index.js", //this part is there by default
        bundleInDebug: true, //this causes it to bundle when building debug, defaults to false
        bundleInRelease: true, //this causes it to bundle when building release, defaults to true
]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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