Changing ReactNative ArtifactID
Categories: programming
Tags: react-native android
At this point I am ready to release my Android application written via ReactNative. Not because it really hits any major product objectives points than it did. More along the lines of easier release cycles to the two other people who use it. First step is updating the artifact IDs to match what will be deployed in the Google Play Store.
According to StackOverflow
According to StackOverflow this looks like it might just be a slog through some files. Let us see how well it goes.
Renaming Packages
A number of Android artifacts are generated and overlayed into the class path. You will get multiple symbol errors if you do not rename the packages. I chose to rename them via Android Studio since it has a better understanding of Java and Android than WebStorm. Although it took a significant period of time to load the project the first time.
android/app/build.gradle
The android/defaultconfig
block has allows you to set the default applicationId
as one would in with any Android
application. By default, ReactNative uses applicationId
to locate bundle resources. However, the technique I am using
for duel deployment
requires telling ReactNative the default build type applicationId
under android/buildTypes/debug/resValue
with the
key build_config_package
.
android/app/_BUCK
The StackOverflow Post refers to a BUCK
however that file did not exist. _BUCK
seems to have similar keys for
android_build_config/package
and android_resource/package
to the new package name.
android/app/src/main/AndroidManifest.xml
Node /manifest[@package]
should be updated to your applicationId
.
Results
Run ./gradlew clean
. Afterwards, running yarn android dev --variant=Debug --appIdSuffix=debug
resulted in a working
application…the second time :-D.
Problems and potential solutions
- Old
applciationId
is being launched viayarn android dev
: Check your manifest file. ReactNative extracts the applicationId from this file. - Java compiler produces a number of
cannot find symbol
errors related toBuildConfig
: Ensure you renamed your java packages to match yourapplicationId
. react-native-screens
was throwing a bunch of warning messages seemingly related to changes in Kotlin. Cheating after pursingyarn outdated
by runningyarn upgrade
…which fixed that issue but not others :-).
Branding Clean Up
App now works under the new branding from the technical side. Last set of steps is to make it feel like the new name.
Application Name: android/app/src/main/res/values/strings.xml
The node /resources/string[@name='app_name']
should be updated to the new human visible name. For other build types
and variants you should update those as well.