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

App crashes immediately (Android) #22

Closed
tstkenny opened this issue Dec 22, 2018 · 6 comments
Closed

App crashes immediately (Android) #22

tstkenny opened this issue Dec 22, 2018 · 6 comments

Comments

@tstkenny
Copy link

I am quite new to the repo and I cannot make it work on API 23 emulator or a physical Android 5 device. The app crashes once loaded, without any react native red background error. Would appreciate if you can take a look. Remote debugger shows nothing since the RN is not loaded yet I suspect.

react-native run-android completes without any error in console though.

React Native Environment Info:
System:
OS: Windows 10
CPU: x64 Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
Memory: 7.60 GB / 15.96 GB
Binaries:
Yarn: 1.9.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 5.3.0 - C:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: Version 3.1.0.0 AI-173.4907809

@tstkenny
Copy link
Author

I got some progress.. if u do NOT rename the project by yarn, you can actually see RN's red background error screen with "Unable to connect with remote debugger"

@tstkenny
Copy link
Author

I found that the gradle API level is 26 so make sure your environment complies.

Next step is to press Ctrl-M in android emulator -> Dev settings, put localhost:8081, then close all cmd boxes and restart.

Viola! It's working!

@Zefau
Copy link

Zefau commented Mar 4, 2019

I'm facing the same issues renaming the project using yarn rename:

$ react-native-rename xxxxx
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
\android\app\src\main\res\values\strings.xml MODIFIED
\index.js MODIFIED
\package.json MODIFIED
\app.json MODIFIED
\android\settings.gradle MODIFIED
\app.json MODIFIED
The system cannot find the path specified.
\android\app\BUCK MODIFIED
\android\app\build.gradle MODIFIED
\android\app\src\main\AndroidManifest.xml MODIFIED
Done removing previous bundle directory.
Done removing builds.
APP SUCCESSFULLY RENAMED TO "xxxxx"! 🎉 🎉 🎉

With this, the app crashes immediately at startup.

@JeremyDolle
Copy link
Collaborator

Hi @Zefau ! Please check if all occurences are successfully renamed in :

Commun

  • App/index.js:
...
AppRegistry.registerComponent('XXXXXX', () => App)
  • App/app.json :
{
  "name": "XXXXXX",
  "displayName": "XXXXXX"
}

Android

  • /android/settings.gradle :
rootProject.name = 'XXXXXX'
...
  • /android/app/src/main/java/com/[yourprojectname]/MainActivity.java:
...
/**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
    @Override
    protected String getMainComponentName() {
        return "XXXXXX";
    }
...

iOS

  • app/ios/[YourProjectName]/Info.plist :
...
<key>CFBundleDisplayName</key>
<string>XXXXXX</string>
...
  • app/ios/[YourProjectName]/AppDelegate.m :
...
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"XXXXXX"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
...

Make sure that you restart your Metro Bundler and rebuild the App.

@Zefau
Copy link

Zefau commented Mar 5, 2019

The project name is updated in the following files

  • App/index.js
  • App/app.json
  • /android/settings.gradle

But the file MainActivity.java gets deleted once renaming the project. Thus /android/app/src/main/java/com/[yourprojectname]/MainActivity.java does not exist.

When I copy and edit the files manually, it works.
Edit: Shall I create an issue for this?

@AurelGit
Copy link
Collaborator

AurelGit commented Mar 5, 2019

Thanks for the PR ! ❤️

Yes can you please create a dedicated issue to this problem ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants