Why release build works differently than debug? - react-native

I built a new APK after I added react-redux and persist. The debug build is working perfect but the release one seems it didn't get the new code cause its working like before.
I'm not sure, why it's happening?. I tried ./gradlew clean too but it didn't help.

Delete the build folder from the android/app directory. Delete Node Modules and do a fresh install. If this does not work then run metro bundler using the below command.
react-native start --reset-cache

The solution was to run 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/ and then building the apk again

Related

The release build apk is not reflecting the changes made in source code why ? -React native

I have made the changes in source code. when running it in debug mode it's working fine changes are. working there. After taking the release build changes are not reflecting in it. why ??? Android build
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle
run this command.. may be it's sounds weird but it's work for me
reference : https://stackoverflow.com/a/60015205/6654562
Before Trying to build APK run gradlew clean and clean the gradle folder this will remove all the previous builds. Then try to build the release APK

Metro bundler is not shown up after : npx react-native run-android

when I run my project I cannot see the bundler running, it just loads and builds successfully but then disconnects. what is the problem?
I recommend these steps:
make sure you have a compatible version of SDK build-tools, try to keep only one. (Also, SDK 11 might be better than SDK 14), Gradle version might have to be downgraded to 6.3, and start with Marshmellow (API 23), (that is what React Native page recommends).
Try this option if you cannot connect to the development server:
create assets folder if you cannot find it in:
cd android/app/src/main/assets
then cd to project folder and run:
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
some people say that react-native-cli might cause some issues, so try uninstalling it.

React native app keeps an old version in release

I have made many changes in my js code, when I run in debug mode I'm able to see all the changes but when I run the app in release mode or generate a release apk, the changes that were made and visible in debug mode are not visible.
What I have already tried?
react-native run-android --variant=release
Deleted the builds folder and android.bundle.js in assets
Run the below command before you run release variant in the project directory.
So command sequence will be first execute
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/
This may take little time to finsh.
Then execute your run command:
react-native run-android --variant=release

gradlew assembleDebug generates no changes

Problem
I have just finished making a few changes in my React Native app and on the android emulator when reloading ( R, R) then changes appear.
I then ran the command:
./gradlew assembleDebug
to generate a debug apk.
When I run it on the phone then changes aren't there, it still is an old version.
I have tried:
Deleting the apk in:
./app/build/outputs/apk
Deleting the whole:
./app/build directory
Tried the command:
./gradlew cleanBuildCache
Rebooting after cleaning the cache (3) and deleting the build directory (2)
Tried the command:
gradlew clean
However I still get an old version of the apk generated each time.
I think you must generate the bundle manually since you run the app on your real device.
Unable to load script from assets index.android.bundle on windows
Go to your project directory and check if this folder exists android/app/src/main/assets
If it exists then delete two files viz index.android.bundle and index.android.bundle.meta
If the folder assets don't exist then create the assets directory there.
From your root project directory do
cd android && ./gradlew clean
Finally, navigate back to the root directory and check if there is one single entry file calledindex.js
If there is only one file i.e. index.js then run following command 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
If there are two files i.e index.android.js and index.ios.js then run this 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
Now run react-native run-android

React native building release isn't reflecting changes that debug does (android)

I made some styling changes to my react native app. Everything looks good in debug so I tried to run the release variant using 'react-native run-android --variant=release' and none of that changes in debug show up. I made sure I wasn't crazy and removed the background image. The release variant didn't change at all. I then tried generating the signed apk and installing it manually. Same thing.
I can't seem to find anything on google. Has anyone had this problem before or have suggestions on what to try? I've combed through all the config files and everything seems right. I know its hard without being able to look at the code but I can't share it since its for internal company use only.
For anyone still struggling with this, updating index.android.bundle usually solves this issue:
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/
1 - Perform adb reverse..check below got to platform-tools in cmd
C:\Users\username\AppData\Local\Android\Sdk\platform-tools --> adb reverse tcp:8081 tcp:8081
2 - Then delete any bundle file if present in assets folder
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
3 - run --> react-native run-android --variant=release
or react-native run-android