react-native cannot get updated apk

Viewed 2780

I use last version of react and react-native on Windows 10 OS.

I have a strange behavior when i try to run my code on phone or to compile debug apk.

1. Run on the phone

> react-native run-android

the process run gradlew building (i think) , i get on the phone an OLD version of my code while this step is not finished

enter image description here

When it finished another console with node automatically open with loading dependency graphand a bundling step is done ( Bundling index.android.js [development, non-minified] 100.0% (960/960), done.) after that my apps on the phone get refreshed with latest code .

enter image description here

maybe it is the regular senario case i don't know.


2. Compile APK

i run > react-native bundle --dev false --platform android --entry-file index.android.js --bundle-output ./android/app/build/intermediates/assets/debug/index.android.bundle --assets-dest ./android/app/build/intermediates/res/merged/debug

> cd android/

> ./gradlew assembleDebug

i get the apk android\app\build\outputs\apk\app-x86-debug.apk I install it on the phone or virtual emulator , but i get THE OLD version of my code and note the latest so cannot send it to other tester.

What i'm doing wrong ?

PS : I try to clean with gradlew >cd android ; ./gradlew clean ; before compiling. same results

4 Answers

If you have already compiled APK on your device, you don't need to recompile (do the react-native run-android) again from your computer. In case you updated the JAVA source code, you need to recompile it.

To update the app, simply press RELOAD on debugging menu in your app. See this for more information: https://facebook.github.io/react-native/docs/debugging.html

On react-native we also have HOT RELOADING, which can update your UI instantly after you save the code.

First of all, close all terminals running React server.

1 Go to Android Folder and Delete Build folder.

2 Delete watchman cache if you are using watchman - watchman watch-del-all

3 Clean npm cache - npm start -- --reset-cache

After this, ensure you have enable Debug JS Remotely in the React native's menu.

It happened to me and that is what I remember what I did. I hope it works!

I had to upgrade Expo CLI and run exp publish before each gradlew assembleRelease.

I had the same issue.If cd android && ./gradlew assembleRelease is not working. Check this file android/app/build.gradle. If this key "signingConfigs" exist or not if not add it. See here- https://facebook.github.io/react-native/docs/signed-apk-android and run command- react-native start --reset-cache and cd android && ./gradlew assembleRelease

Related