Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-native-git-upgrade does not respect android package name #16217

Closed
nikolaik opened this issue Oct 5, 2017 · 11 comments
Closed

react-native-git-upgrade does not respect android package name #16217

nikolaik opened this issue Oct 5, 2017 · 11 comments
Labels
Platform: Android Android applications. Ran Commands One of our bots successfully processed a command. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@nikolaik
Copy link

nikolaik commented Oct 5, 2017

Is 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

  1. Run react-native init MyProject --version 0.48.3
  2. Rename your com.myproject package / applicationId to com.my.new.project according to this SO answer: https://stackoverflow.com/a/37390022/543864
  3. Run react-native-git-upgrade to upgrade to 0.49.1 (or higher) which failes silently like described in react-native-git-upgrade changes nothing #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.

@richardgirges
Copy link

I just ran into this same issue. I had to rename my android package to make react-native-git-upgrade happy, do the upgrade, then rename it back. Not a recommended solution.

@seratonik
Copy link

Same issue here, attempted a manual upgrade and having some troubles. Will try @richardgirges's workaround.

@nikolaik
Copy link
Author

nikolaik commented Oct 5, 2017

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.

@SirNeuman
Copy link

yeah... @nikolaik's workaround worked for me. Not sure where react-native-git-upgrade is getting the old package name from. I couldn't find any references to the old name of my package anywhere in my code

@jordanmkoncz
Copy link

jordanmkoncz commented Nov 14, 2017

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 form com.appname that react-native init generates.

@SirNeuman react-native-git-upgrade gets the package name by looking at the name value in your package.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 your android/app/src/main/AndroidManifest.xml file since the location of that file does not change (unlike the location of the MainApplication.java file) and the manifest node has a package attribute with the correct value of the Android package name.

In the meantime, I was also able to use the workaround posted by @nikolaik.

@stale
Copy link

stale bot commented Jan 13, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 13, 2018
@nikolaik
Copy link
Author

This will keep affecting people for every update of the MainApplication.java template file. I like @jordanmkoncz 's approach.

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 13, 2018
@jordanmkoncz
Copy link

Yeah this issue should definitely remain open. It seems like it should be fairly easy/straightforward to fix (at least with my suggested solution of inspecting android/app/src/main/AndroidManifest.xml) and would save people from having to do these annoying workarounds every time they upgrade React Native.

@hramos hramos added the Android label Mar 8, 2018
@react-native-bot react-native-bot added CLI 💻 Ran Commands One of our bots successfully processed a command. labels Mar 14, 2018
@react-native-bot react-native-bot added Platform: Android Android applications. Ran Commands One of our bots successfully processed a command. labels Mar 18, 2018
@noahtallen
Copy link

Is there a place someone could submit a PR to try to fix this issue?

@stale
Copy link

stale bot commented Aug 20, 2018

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Aug 20, 2018
@stale
Copy link

stale bot commented Sep 6, 2018

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Sep 6, 2018
@facebook facebook locked as resolved and limited conversation to collaborators Sep 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Platform: Android Android applications. Ran Commands One of our bots successfully processed a command. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

9 participants