React-native-navigation: Android application keeps stopping . Does not work react-native-navigation on Android

Created on 7 Apr 2018  路  49Comments  路  Source: wix/react-native-navigation

Issue Description

Does not work react-native-navigation on Android
Starting : Intent { 鈥ainActivity }.

Did everything as indicated in the documentation. I launch the Android Studio emulator.

image
On iOS, the same code works fine
index.ios.js
import App from './App';

index.android.js
import App from './App';

app.js:

   import { Navigation } from "react-native-navigation";
   import AuthScreen from "./src/screens/Auth/Auth";
   // Register Screens
   Navigation.registerComponent("awesome-places.AuthScreen", () => AuthScreen);

   // Start a App

   Navigation.startSingleScreenApp({
              screen: {
               screen: "awesome-places.AuthScreen",
               title: "Login"
            }
    });

auth.js:

import React, { Component } from 'react';
import { View, Text } from 'react-native';

class AuthScreen extends Component {
    render () {
        return (
            <View>
                <Text>Auth Screen</Text>
            </View>
        );
    }
}
export default AuthScreen;

settings.gradle
```
rootProject.name = 'rncourse'

include ':app'

include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir,
'../node_modules/react-native-vector-icons/android')

include ':react-native-navigation'
project(':react-native-navigation').projectDir = new File(rootProject.projectDir,
'../node_modules/react-native-navigation/android/app/')

**build.gradle**

dependencies {
compile fileTree(dir: "libs", include: [".jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+"
compile project(':react-native-vector-icons')
compile fileTree(dir: "libs", include: ["
.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+"
compile project(':react-native-navigation') // From node_modules
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}

project.ext.vectoricons = [
iconFontNames: [ 'Ionicons.ttf'] // Name of the font files you want to copy
]

apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

**MainActivity.java**

import com.reactnativenavigation.controllers.SplashActivity;

public class MainActivity extends SplashActivity {

}

**MainApplication.java**

package com.rncourse;

import android.app.Application;

import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.oblador.vectoricons.VectorIconsPackage;
import com.reactnativenavigation.NavigationApplication;

import java.util.Arrays;
import java.util.List;

public class MainApplication extends NavigationApplication {

 @Override
 public boolean isDebug() {
     // Make sure you are using BuildConfig from your own application
     return BuildConfig.DEBUG;
 }

 protected List<ReactPackage> getPackages() {
     // Add additional packages you require here
     // No need to add RnnPackage and MainReactPackage
     return Arrays.<ReactPackage>asList(
         new VectorIconsPackage()
     );
 }

 @Override
 public List<ReactPackage> createAdditionalReactPackages() {
     return getPackages();
 }

}
```
I tried to use the version of "react-native": "^ 0.49.5",
The same thing happens
Android does not work
IOS works


Environment

  • React Native Navigation version: "^1.1.434",
  • React Native version: "0.54.0",
  • Platform(s) : Android 8.1
  • Device info : Android Simulator
  • Android Studio version 3.1

Most helpful comment

The same issue after linking with react-native-firebase. No logs. It's just crashing on the physical device.

any solution for your problem, im new to react-native, i got the same problem after adding react-native-firebase

i just moved google() in android/build.gradle to the top, and it worked
``allprojects { repositories { google() mavenLocal() jcenter() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" } } }

All 49 comments

I am having a very similar issue. My project builds successfully, but a blank screen appears in the android emulator, and the developers menu cannot be accessed. I've posted my setup and screenshots in this similar thread. https://github.com/wix/react-native-navigation/issues/2687

Try this,
stop the packager.
adb reverse tcp:8081 tcp:8081
start the packager.

adb reverse tcp:8081 tcp:8081

Did not help

image

@sinevitch Open Logcat while you are opening the app, and look for crash log and share it here.

image

Same here :
Starting: Intent { cmp=com.XXX/.MainActivity }

and

"Unfortunately, Application has stopped" message on the emulator

trying adb logcat in terminal but can't locate the error source !!

any updates on the issue?

Facing the same issue. any fix?

Any update on this issue?

In android, changed react-native dependeny to
compile('com.facebook.react:react-native:0.51.1') { force = true }

Version should be exact same as in package.json
Cleaned and rebuilt project and it worked.

Any update on this issue?

The single crash log which was posted here has nothing to do with RNN. I'm closing as we really can't help you resolve this issue.

I am having this very same problem :(

The same issue after linking with react-native-firebase. No logs. It's just crashing on the physical device.

The same issue after linking with react-native-firebase. No logs. It's just crashing on the physical device.

any solution for your problem, im new to react-native, i got the same problem after adding react-native-firebase

I've got it. The problems lies in the _android/app/build.gradle_ dependency versions. Try to put there all the new one version numbers looking at (in this case for Android):

Then, the immediate shutting down should no longer appears. Then you probably see other exceptions but just follow any other tips.

The same issue after linking with react-native-firebase. No logs. It's just crashing on the physical device.

any solution for your problem, im new to react-native, i got the same problem after adding react-native-firebase

i just moved google() in android/build.gradle to the top, and it worked
``allprojects { repositories { google() mavenLocal() jcenter() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" } } }

@sinevitch

Try by changing your MainActivity.java to:

package com.rncourse; //<- App package name goes here

import com.reactnativenavigation.controllers.SplashActivity;

public class MainActivity extends SplashActivity {

}

Corriendo un app con react-native
tube el mismo problema, me estuvo saliendo el mensaje de App keep stopping, el emulador no me mostraba la app,, lo solucione con los siguientes pasos

  1. abrir el proyecto en android studio
  2. ejecutar el play o el emulador (aqui no me abre el proyecto sale app keep stopping)
  3. desde la terminal das react-native run-android

espero ayude

adb reverse tcp:8081 tcp:8081

Did not help

image

try to run from terminal, react-native run-android
but first you have to have open android studio with the project and runing a emulator,, probably the message will apear (app keep stopping),,then in terminal you run react-native run android

this worked for me

i hope it works for you

@potatokoosh It also didn't work for me, but my message is "myApp keeps stopping". Does anybody have any other solutions?

having the same error message for the Android release build.
"react": "16.6.3",
"react-native": "0.58.6",

Are there any tools to debug what is going on in the release build?

In my case the application loads when the phone is connected to the metro-builder, but once the phone is disconnect from the Metro-builder the application crashes.

I had the same problem. But I just fixed it by pressing Ctrl + M a few times. I do not know how it works.

I have the same problem. :|

I closed the app and relaunched it from the Android, it worked for me.

I had a similar problem, I fixed it by removing component from screen that I wanna navigate to it, and it was nativeBase Picker component

I had this problem with the lib react-native-pdf-lib.

With LogCat i figure it out, i had to ask for WRITE_EXTERNAL_STORAGE with PermissionsAndroid

Occurred to me as well, just like this without adding packages.
I was trying to find a solution, reading a lot, without luck.
I finally desperately wiped the Android Emulator and - tataaa - that was it. Worked for me.

I solved this issue (in my case) using this link: https://medium.com/@impaachu/react-native-android-release-build-crash-on-device-14f2c9eacf18.

I solved this issue (in my case) using this link: https://medium.com/@impaachu/react-native-android-release-build-crash-on-device-14f2c9eacf18.

It seems that there could be different reasons for this to happen and the best way to nail the cause is by using this method. I solved mine with this and for my case, it's because of a library that I installed. I solved it by uninstalling that library.

Maybe you don't have index.android.js and index.ios.js with import App from './App'; ?

I could not solve the problem but you can just '' react-native init '' and change app.js from the the old app.

Maybe you should restart Metro bundler

same here
"react": "16.8.3",
"react-native": "^0.60.4"
AndroidX

I could not solve the problem but you can just '' react-native init '' and change app.js from the the old app.

Does that solved the problem?

See that you don't have two react-native versions installed simultaneously. Do :
npm list --depth

If there are two RN versions, there will be a version mismatch and the app will keep stopping.

npm uninstall react-native@<the-version-you-want-to-uninstall>
Then run your code again.

build has been complete and emiulator is working then error "Keeps Stoping"

emilator

install
npm list --depth

check error and my be install
npm install eslint
my error remove run project

Debug/run the project in android studio where you will be able to see error logs. For my case, there are a lot of issues as haven't tested in android for a very long time.

In my case gradlew clean on Windows or ./gradle clean on Linux makes the emulator works again.

how can i remove this error..

2020-01-30 01:06:07.156 3396-3396/com.dotundo.androiddoctor E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.dotundo.androiddoctor, PID: 3396
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dotundo.androiddoctor/com.dotundo.androiddoctor.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2865)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2955)
at android.app.ActivityThread.-wrap12(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6747)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:449)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
at com.dotundo.androiddoctor.MainActivity.LoginFunction(MainActivity.java:54)
at com.dotundo.androiddoctor.MainActivity.onCreate(MainActivity.java:33)
at android.app.Activity.performCreate(Activity.java:7025)
at android.app.Activity.performCreate(Activity.java:7016)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1217)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2812)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2955)聽
at android.app.ActivityThread.-wrap12(Unknown Source:0)聽
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)聽
at android.os.Handler.dispatchMessage(Handler.java:106)聽
at android.os.Looper.loop(Looper.java:164)聽
at android.app.ActivityThread.main(ActivityThread.java:6747)聽
at java.lang.reflect.Method.invoke(Native Method)聽
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:449)聽
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)聽

For me the problem was I was following steps from react-native docs instead react-navigation official docs. The first one does not mention this step:


To finalize installation of react-native-screens for Android, add the following two lines to dependencies section in android/app/build.gradle:

implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'

I solved this error by updating the version of Android Studio.

I solved this error by updating the version of Android Studio.

Updating is what go me into this mess.

gradlew clean, uninstalling the app then yarn run android solved the problem on windows

@Cmion answer works in Ubuntu 20.4 as well

what solved it for me was cleaning the project, so it might work for you.
run
git clean -d -x -f

then just run
npm install or yarn

Assuming environment is set up correctly and you are not using Expo, run the following:

~ cd android
~ ./gradlew clean
~ cd ..
~ npm install
~ npm react-native start
~ npm react-native run-android

This worked for me.

I only met this problem on android 8 but it worked on android 7, 8.1 ,9 and 10

Was this page helpful?
0 / 5 - 0 ratings