0

I'm trying to generate release apk for Android on my React Native project. I followed all the steps in the official Facebook's React Native publish documentation.

When I upload the generated apk in the play console, download and run it on my device I don't see any of the changes I made after the last apk publish. (means I see older apk with older features and not the new features)

I also tried to run react-native run-android --variant=release before publish, I get the same older version of apk. But I can see all the new features working when running in debug, without the release flag.

Tried other solutions like below found on here, but those result in "Duplicate errors".

react-native run-android builds an old version of the code onto device

UPDATE: Hope this helps someone who has the same problem and is trying to find the solution.

I got it to work this way. I don't know how advisable this is, but this works for me for now. I found the solution on the official react-native github issues page. This is the link to the actual solution and also a quick look at the solution. I had to edit the react.gradle file with the below code just after doFirst code block. The file can be found under node-modules > react-native folder.

doLast {
        def moveFunc = { resSuffix ->
            File originalDir = file("$buildDir/generated/res/react/release/drawable-${resSuffix}");
            if (originalDir.exists()) {
                File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}");
                ant.move(file: originalDir, tofile: destDir);
            }
        }
        moveFunc.curry("ldpi").call()
        moveFunc.curry("mdpi").call()
        moveFunc.curry("hdpi").call()
        moveFunc.curry("xhdpi").call()
        moveFunc.curry("xxhdpi").call()
        moveFunc.curry("xxxhdpi").call()
        }

Then I ran below commands:

cd android
./gradlew bundleRelease
cd..
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

Then I ran the build command with release variant and it worked. Got all the latest changes and generated a new apk. Tried multiple times and works.

react-native run-android --variant=release

1 Answers1

1

When you run "react-native run-android --variant=release", did you delete your app on your device before ? (I have some trouble if I don't do that before).

For the play store part, did you increase the build version of your react project ? ("version" on your package.json, "defaultConfig > versionCode and versionName" in android>app>build.gradle, info.plist for ios).

rphlmr
  • 838
  • 6
  • 12
  • Thanks for your response. Answer to your first question: Yes, I did uninstall all the previous app instances before running the command. Answer to your second question: I did bump up the versionCode and versionName in the build.gradle file for android. – Pavan Akshay Abhange Aug 09 '19 at 17:44
  • Sorry it not helps :/ When you build a release, does the apk creation time updates ? – rphlmr Aug 09 '19 at 18:36