0

So, I run the app on debug mode with a usb cable, it works fine. Then, I run the release version with a usb cable, it works fine too UNTIL I disconnect it from the phone and restart the app. The app is not able to load assets anymore. I have tried all the ways referenced here and here, but still no help.

When app cannot load the assets, it logs this message:

[Error: Could not fetch data from url http://localhost:8081/assets/src/assets/modelv2.pb?platform=android&hash=889b05962c1b1b35b1c07a84b98bcc63]
      framesToPop: 1,
      code: 'EUNSPECIFIED',
      line: 17119,
      column: 31,
      sourceURL: 'http://localhost:8081/index.delta?platform=android&dev=true&minify=false' }

So, it means it is still trying to grab the assets from the local host packager which is dead. Please help me!

React Native: ^0.55.4

React: ^16.3.1

index.js

import { AppRegistry } from 'react-native';
import App from './App'; 
AppRegistry.registerComponent('TagMosquito', () => App);

2 Answers2

0

If you want to create a Signed APK(Signed apk used for Android APK so I think you want to create a APK) you first need to create a bundle. If you already created it then let me know the command you used and also just share the screenshot of your project structure and it should show your main index file and android assets folder path as well then I will give you the command. For now you just.

If not use below commands.

Android

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

iOS (It's create bundle it self but if not Please use below command)

react-native bundle --entry-file index.js --platform ios --dev false --bundle-output main.jsbundle

Please let me know if any command not working some then it will need some modification. If it will work you need to check there will be a new file created named main.jsbundle

Nitish
  • 995
  • 7
  • 17
  • I used the command above, and it looked like it created and saved the bundle, but the signed app cannot access it for some reason. Here is the path to the bundle: android/app/build/intermediates/assets/release/index.android.bundle – Jim Mirzakhalov Jan 17 '19 at 13:51
  • But I don't see any main.jsbundle file here. Also, here is the path to android assets android/app/src/main/assets. I will share the index.js file code, but it is only like 5 lines. – Jim Mirzakhalov Jan 17 '19 at 13:59
  • 1. Your bundle should be in the assets folder not any other place. android/app/src/main/assets/index.android.bundle 2. I don't need index.js code I want it's path and there should be a assets folder at below path. android/app/src/main/assets 3. Also after bundle command complete your assets will automatically copy to your android res folders with some new name. 4. Then you need to create APK file.(Either sighed or not but release build) 5. Stop your npm server at the time of released APK testing. – Nitish Jan 18 '19 at 06:40
  • You need to run your bundle command at same level where you run `npm start` or `yarn start` command. – Nitish Jan 18 '19 at 07:00
0

Set shrinkResources to false will work in this case. Gradle can automatically remove resources(unused) on your behalf if you enable shrinkResources in your app's build.gradle file.

release {
            ..
            minifyEnabled true
            shrinkResources false    <-- set this false
            proguardFiles getDefaultProguardFile()
        }
Kumar Parth
  • 439
  • 5
  • 7