2

I am making an app using react native detached, I was able to successfully build my app and generated apk release for android, the problem is after that I added few more features, some more code I am not able to see these features on my phone it takes the old .apk.

Question: What do I need to do in order so I get a new release .apk with the latest changes. Do I have to do anything from react prespective or just from Android Studio?

I have tried to clean, rebuild and generate new signed apk, but I am still unable to see the new changes on the app on phone, looks like Android Studio is not generating a new apk with latest changes, it somehow generates the old one cached or idk.

Anyone can help on this?

Mizlul
  • 1
  • 7
  • 41
  • 100
  • Possible duplicate of [Release APK Not Updating With JavaScript Code](https://stackoverflow.com/questions/45441217/release-apk-not-updating-with-javascript-code) – chenop Aug 03 '18 at 18:09
  • @mizlul did you find any solution for this problem, i am facing same problem but none of the solution is worked for me – Chandler Bing Jan 22 '21 at 15:03
  • I am also facing same issue but get solution from there https://stackoverflow.com/a/45441548/6849012 – Anand Ramachandran Apr 10 '21 at 16:44

5 Answers5

3

Generating Release Apk Steps:

1.Delete (index.android.bundle) files inside directory android/app/src/main/assets.

2.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

3.Delete folders (drawable,drawable-hdpi,drawable-mdpi,drawable-xhdpi,drawable-xxhdpi,drawable-xxxhdpi,raw)

4.run $ react-native run-android --variant=release

Nagesh Fultambkar
  • 546
  • 1
  • 7
  • 22
1

What worked for me was the following:

cd android
gradlew clean
gradlew assembleRelease
chenop
  • 4,743
  • 4
  • 41
  • 65
0

Are you sure that the new application is different from the previous ? Please compare the size of the first APK you created with the second APK (the one with the changes)

If the size is not the same then suppress cache file of your applciation on your phone and reinstall it

If it is the same size then try :

  • to add android.enableBuildCache=true to your gradle.properties

or

  • In Android Studio, go to Run > Edit Configuration. Under Before launchAdd add Gradle-aware Make and leaving Task empty.
Arnauld Alex
  • 339
  • 1
  • 3
  • 13
  • I am sure its different, since I have been adding quite code within my react native components! will try to add android.enableBuildCache=true – Mizlul Apr 25 '18 at 15:24
  • I am getting FAILURE: Build failed with an exception. * What went wrong: Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed) after 97% completed! – Mizlul Apr 26 '18 at 13:46
  • I am checking logs and it says There is insufficient memory for the Java Runtime Environment to continue. – Mizlul Apr 26 '18 at 13:48
  • oh, so you may need to add more RAM to your VM if you are using one.. otherwise add more RAM to your PC. And I am afraid I could not help you more than that. – Arnauld Alex Apr 26 '18 at 13:58
  • It has succesfully complted this time by closing some other apps. but the thing is I get unesigned apk, how do I get signed apk? – Mizlul Apr 26 '18 at 14:07
0

For everyone that needs to know this: in fact when you make changes to react native app, you have to publish through expo kit to build bundle.js and publisht it, so apk will have the latest bundle changes of your app. Basically you only need to build new apk from Android Studio only when you change native features, like if you using some native features for push notification or smth which makes changes on the java code!

Mizlul
  • 1
  • 7
  • 41
  • 100
0

Updating index.android.bundle solved my 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/

I was also struggling with this issue and after searching over the internet and applying many solutions, this helps me link.

Alok Ramteke
  • 123
  • 4
  • 11