react-native-git-upgrade does not respect android package name
See original GitHub issueIs this a bug report?
Yes
Have you read the Contributing Guidelines?
Yes
Environment
Environment:
OS: Linux 4.10
Node: 6.10.3
Yarn: 1.1.0
npm: 3.10.10
Watchman: 4.7.0
Error: unable to print environment info
{ Error: not found: xcodebuild
(snip stacktrace)
Steps to Reproduce
- Run
react-native init MyProject --version 0.48.3
- Rename your
com.myproject
package / applicationId tocom.my.new.project
according to this SO answer: https://stackoverflow.com/a/37390022/543864 - Run
react-native-git-upgrade
to upgrade to 0.49.1 (or higher) which failes silently like described in #12112
There is a similar issue #11163 from when MainApplication.java was introduced in 0.29.
Expected Behavior
Running react-native-git-upgrade in step 3 uses the current Android package name by either parsing AndroidManifest.xml or accepting the package name as a param (ie. react-native-git-upgrade --package com.my.new.project
and patches MainApplication.java in the correct path (ie. com/my/new/project
).
It looks like react-native init
took a package param in version 0.38 which was later removed. That code could be used as a basis for either a --package
option to react-native-git-upgrade or parsing AndroidManifest.xml. What is the best approach?
Actual Behavior
Running react-native-git-upgrade
in step 3 fails silently like described in #12112 because it tried to patch a file that is not in the git index. It tried to patch com/myproject/MainApplication.java
instead of com/my/new/project/MainApplication.java
.
Reproducible Demo
Follow the steps under Steps to Reproduce.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:25
- Comments:11
Top GitHub Comments
My workaround (this time) was to copy my existing MainApplication.java to the path react-native-git-upgrade expects, run the upgrade and then copy the file back to the correct path.
I’m experiencing the same issue as I changed my Android package name to be in the form
com.companyname.appname
instead of the default formcom.appname
thatreact-native init
generates.@SirNeuman
react-native-git-upgrade
gets the package name by looking at thename
value in yourpackage.json
. It assumes that this matches the name of your app, and then it also assumes that your Android package name is still in the form that it was when the project was generated, i.e.com.appname
.It seems like it should be possible to update
react-native-git-upgrade
so that it is able to figure out your actual package name; it could just pull this from yourandroid/app/src/main/AndroidManifest.xml
file since the location of that file does not change (unlike the location of theMainApplication.java
file) and themanifest
node has apackage
attribute with the correct value of the Android package name.In the meantime, I was also able to use the workaround posted by @nikolaik.