question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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 #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:closed
  • Created 6 years ago
  • Reactions:25
  • Comments:11

github_iconTop GitHub Comments

8reactions
nikolaikcommented, 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.

3reactions
jordanmkonczcommented, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change package name for Android in React Native
Change package name for Android in React Native · Left click on package name and go for Refactor--> Rename option to rename package...
Read more >
Getting started with React Native apps - Bitrise Docs
Get started on Bitrise by signing up via email or a Git provider, connecting a repository, and running the first build for your...
Read more >
React Native - Branch Help
The react-native-git-upgrade tool from NPM may be used to update dependencies as well as project settings. On Android, when using Proguard in release...
Read more >
Communication between native and React Native
In Integrating with Existing Apps guide and Native UI Components guide we learn how to embed React Native in a native component and...
Read more >
Advertising ID - Play Console Help - Google Support
Additionally, when apps update their target to Android 13 or above will need ... if you don't explicitly declare the permission in your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found