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