How to update version number in react native?
You need to update version and versionCode in order to successfully publish update of your app. If you don’t update them, google play console won’t let you upload your update. So, in this article, we are going to see two methods to update your version numbers.
Update version in app json
Changing or updating your app’s version number is very straightforward in app.json() file. All you need to do add following lines of code in your app.json file.
"expo": {
...
"version": "1.0.6",
...
"android": {
"versionCode": 7,
...
}
Doing just this will allow you to update your app’s version number in built file, so you can upload it to the play store.
Update version in android folder
If you have ejected your app, and you have an android folder within your app, you will also need to update it there as well. Failure to do so, Google play console will notify you with an error, stating that the version is previously used. So, you will need to update their as well.
Go to android -> app -> build.gradle. Find versionCode and versionName and update as you did in app.json(). Make sure to keep them same in both app.json and in android folder.
android {
...
defaultConfig {
...
versionCode 7
versionName "1.0.6"
After doing this, you can build your app, and upload it to the playstore.
Conclusion
In this short article, we saw how easy it is to update your version numbers for your app updates in React Native. Once you have these updated, you can build and upload your app to Google play console with no issues, hopefully.
Have you ever ejected your app or just do everything without ejecting. This was my first time doing that but all went well. I came across this issue, when I struggled to upload my app to Google play console, stating that version is already in use. So, I had to dig around and finally found something that fixes this issue. And all I had to do was to update in the android folder, as well as in the app.json().