Go back to debugging after created release version

2020-07-22 09:33发布

问题:

So I have created my Application using React native and just produced my first release-build. My problem now is that I can't get back to react natives debug-mode.

By following the documentation, this is what i did.

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

This code generated the bundled index.android.bundle and index.android.bundle.meta

Now every time I execute react-native run-android, the javascript code-base wont update the application and I am not able to access the development(shake) menu in my app.

If I run react-native bundle again, the code will update.

I guess this is a simple issue, but can't find any information how to return so the app isn't using the bundled version anymore.

回答1:

  • Delete assets folder in app/src/main/
  • Remove this import line if exist : "import com.facebook.react.BuildConfig;" in MainApplication.java
  • Run "react-native run-android"

And boom!



回答2:

My quickest way is openning the file: $projectRoot\android\app\src\main\java\com\movies\MainApplication.java, going to the code like:

public boolean getUseDeveloperSupport() {
 return false; //it was changed to false from BuildConfig.DEBUG when released
}

then changing the false to true to make the debug menu available again.



回答3:

It happens with wrong import statement in MainApplication.java, You have to check if any statement like import com.facebook.react.BuildConfig; is in the imports. If so, remove that and run react-native run-android

No need to delete assets folder