Skip to content

When app starts, app crashed on android [React Navigation 5.0.0 Alpha]. #6267

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

Closed
burhanyilmaz opened this issue Sep 6, 2019 · 16 comments
Closed

Comments

@burhanyilmaz
Copy link

Current Behavior

When my app starts, app crashed on Android.
The app is working on IOS.

Expected Behavior

The app is working on Android and IOS.

Error Log

AndroidRuntime	FATAL EXCEPTION: mqt_native_modules
Process: com.rnnext, PID: 24380
java.lang.NoClassDefFoundError: com.facebook.react.views.swiperefresh.ReactSwipeRefreshLayout
	at libcore.reflect.InternalNames.getClass(InternalNames.java:55)
	at java.lang.Class.getDexCacheType(Class.java:2551)
	at java.lang.reflect.AbstractMethod.getParameterTypes(AbstractMethod.java:169)
	at java.lang.reflect.Method.getParameterTypes(Method.java:193)
	at java.lang.Class.getDeclaredMethods(Class.java:1812)
	at com.facebook.react.uimanager.ViewManagersPropertyCache.extractPropSettersFromViewManagerClassDefinition(ViewManagersPropertyCache.java:446)
	at com.facebook.react.uimanager.ViewManagersPropertyCache.getNativePropSettersForViewManagerClass(ViewManagersPropertyCache.java:341)
	at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackViewManagerSetter.<init>(ViewManagerPropertyUpdater.java:124)
	at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackViewManagerSetter.<init>(ViewManagerPropertyUpdater.java:118)
	at com.facebook.react.uimanager.ViewManagerPropertyUpdater.findManagerSetter(ViewManagerPropertyUpdater.java:81)
	at com.facebook.react.uimanager.ViewManagerPropertyUpdater.getNativeProps(ViewManagerPropertyUpdater.java:68)
	at com.facebook.react.uimanager.ViewManager.getNativeProps(ViewManager.java:230)
	at com.facebook.react.uimanager.UIManagerModuleConstantsHelper.createConstantsForViewManager(UIManagerModuleConstantsHelper.java:148)
	at com.facebook.react.uimanager.UIManagerModuleConstantsHelper.createConstants(UIManagerModuleConstantsHelper.java:95)
	at com.facebook.react.uimanager.UIManagerModule.createConstants(UIManagerModule.java:274)
	at com.facebook.react.uimanager.UIManagerModule.<init>(UIManagerModule.java:181)
	at com.facebook.react.uimanager.UIManagerModule.<init>(UIManagerModule.java:142)
	at com.facebook.react.CoreModulesPackage.createUIManager(CoreModulesPackage.java:187)
	at com.facebook.react.CoreModulesPackage.getModule(CoreModulesPackage.java:155)
	at com.facebook.react.TurboReactPackage$ModuleHolderProvider.get(TurboReactPackage.java:123)
	at com.facebook.react.TurboReactPackage$ModuleHolderProvider.get(TurboReactPackage.java:111)
	at com.facebook.react.bridge.ModuleHolder.create(ModuleHolder.java:189)
	at com.facebook.react.bridge.ModuleHolder.getModule(ModuleHolder.java:154)
	at com.facebook.react.bridge.NativeModuleRegistry.getModule(NativeModuleRegistry.java:148)
	at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:429)
	at com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:38)
	at com.facebook.react.ReactInstanceManager.attachRootViewToInstance(ReactInstanceManager.java:1049)
	at com.facebook.react.ReactInstanceManager.setupReactContext(ReactInstanceManager.java:1008)
	at com.facebook.react.ReactInstanceManager.access$1300(ReactInstanceManager.java:124)
	at com.facebook.react.ReactInstanceManager$5$2.run(ReactInstanceManager.java:969)
	at android.os.Handler.handleCallback(Handler.java:751)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
	at android.os.Looper.loop(Looper.java:154)
	at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:232)
	at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.ClassNotFoundException: com.facebook.react.views.swiperefresh.ReactSwipeRefreshLayout
	at java.lang.VMClassLoader.findLoadedClass(Native Method)
	at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:742)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:362)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
	at libcore.reflect.InternalNames.getClass(InternalNames.java:53)
	... 35 more
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/swiperefreshlayout/widget/SwipeRefreshLayout;

How to reproduce

package.json

{
  "name": "rnnext",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint .",
    "postinstall": "jetifier"
  },
  "dependencies": {
    "@react-native-community/masked-view": "^0.1.1",
    "@react-navigation/core": "^5.0.0-alpha.8",
    "@react-navigation/native": "^5.0.0-alpha.7",
    "@react-navigation/stack": "^5.0.0-alpha.15",
    "react": "16.8.6",
    "react-native": "0.60.5",
    "react-native-gesture-handler": "^1.4.1",
    "react-native-reanimated": "^1.2.0",
    "react-native-screens": "^2.0.0-alpha.1"
  },
  "devDependencies": {
    "@babel/core": "^7.5.5",
    "@babel/runtime": "^7.5.5",
    "@react-native-community/eslint-config": "^0.0.5",
    "babel-jest": "^24.9.0",
    "eslint": "^6.3.0",
    "jest": "^24.9.0",
    "metro-react-native-babel-preset": "^0.56.0",
    "react-test-renderer": "16.8.6"
  },
  "jest": {
    "preset": "react-native"
  }
}

App.js

import * as React from 'react';
import { View, Text } from 'react-native';
import { NavigationNativeContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import { TouchableOpacity } from 'react-native-gesture-handler';

function HomeScreen({ navigation: { navigate } }) {
  return (
    <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
      <Text>Home Screens</Text>
      <TouchableOpacity onPress={() => navigate('Home1')}>
        <Text>Go to Home1 </Text>
      </TouchableOpacity>
    </View>
  );
}

function HomeScreen1() {
  return (
    <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
      <Text>Home Screens</Text>
    </View>
  );
}

const Stack = createStackNavigator();

function App() {
  return (
    <NavigationNativeContainer>
      <Stack.Navigator>
        <Stack.Screen name="Home" component={HomeScreen} />
        <Stack.Screen name="Home1" component={HomeScreen1} />
      </Stack.Navigator>
    </NavigationNativeContainer>
  );
}

export default App;

Your Environment

software version
react-navigation 5 Alpha
react-native 0.60.5
react-native -cli 2.0.1
node 12.3.1
yarn 1.16.0
@Martian2Lee
Copy link

Martian2Lee commented Sep 6, 2019

Same issue!

{
  "name": "paper",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint .",
    "sim": "open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app",
    "ios": "react-native run-ios",
    "android": "react-native run-android",
    "precommit": "lint-staged"
  },
  "dependencies": {
    "react": "16.8.6",
    "react-native": "0.60.5",
    "react-native-gesture-handler": "^1.4.1",
    "react-native-reanimated": "^1.2.0",
    "react-native-screens": "^2.0.0-alpha.1",
    "react-navigation": "^4.0.0",
    "react-navigation-stack": "^1.5.1"
  },
  "devDependencies": {
    "@babel/core": "^7.5.5",
    "@babel/runtime": "^7.5.5",
    "@react-native-community/eslint-config": "^0.0.5",
    "@types/jest": "^24.0.18",
    "@types/prettier": "^1.18.2",
    "@types/react": "^16.9.2",
    "@types/react-native": "^0.60.11",
    "@types/react-navigation": "^3.0.8",
    "@types/react-test-renderer": "^16.9.0",
    "babel-jest": "^24.9.0",
    "eslint": "^6.3.0",
    "husky": "^3.0.5",
    "jest": "^24.9.0",
    "lint-staged": "^9.2.5",
    "metro-react-native-babel-preset": "^0.56.0",
    "prettier": "^1.18.2",
    "react-test-renderer": "16.8.6",
    "typescript": "^3.6.2"
  },
  "jest": {
    "preset": "react-native"
  },
  "lint-staged": {
    "*.{js,jsx,ts,tsx}": [
      "prettier --single-quote none --write",
      "git add"
    ]
  }
}

@mustafakemalelma
Copy link

I am also having this same issue on version 4.0.0

@burhanyilmaz
Copy link
Author

burhanyilmaz commented Sep 6, 2019

@Martian2Lee @mustafakemalelma
I found a solution. Problem is related to react-native-screens.

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'

https://github.com/kmagiera/react-native-screens#usage-with-react-navigation-without-expo

burhanyilmaz pushed a commit to burhanyilmaz/react-navigation.github.io that referenced this issue Sep 6, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
if not added this two lines code, the app crashed on android.
Related to this issue react-navigation/react-navigation#6267.
@satya164
Copy link
Member

Closing since the solution is posted

@t-fritsch
Copy link

Hello
thank you @burhanyilmaz !
Shouldn't this be mentioned in the Getting Started section as it was in v4.x documentation ? Any reason why it was not brought back in v5 doc ?
https://reactnavigation.org/docs/en/4.x/getting-started.html#installing-dependencies-into-a-bare-react-native-project

@Qusain
Copy link

Qusain commented Feb 19, 2020

implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'
thanku so much , i solved my problem after 12 hour

@FrozenIce0617
Copy link

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

Thank you very much, it is very helpful.

@ykws
Copy link

ykws commented Mar 19, 2020

Now stable version

implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0'

🔖 https://mvnrepository.com/artifact/androidx.appcompat/appcompat
🔖 https://mvnrepository.com/artifact/androidx.swiperefreshlayout/swiperefreshlayout

@t-fritsch
Copy link

Hello
thank you @burhanyilmaz !
Shouldn't this be mentioned in the Getting Started section as it was in v4.x documentation ? Any reason why it was not brought back in v5 doc ?
https://reactnavigation.org/docs/en/4.x/getting-started.html#installing-dependencies-into-a-bare-react-native-project

Hello @satya164
sorry to insist but do you have any idea why this step isn't mentioned anymore in docs ? Shouldn't this be written back before closing this issue ?

@ykws thank you for version bump but are you sure swiperefreshlayout@1.0.0 is ok ? previous workaround from @burhanyilmaz used 1.1.0-alpha02 and the link you provided shows there is now a 1.1.0-beta01 version.

@satya164
Copy link
Member

satya164 commented Mar 26, 2020

@tfritsch-km Hello @satya164 sorry to insist but do you have any idea why this step isn't mentioned anymore in docs ? Shouldn't this be written back before closing this issue ?

It's not needed as of the latest version of react-native-screens. Make sure you have upgraded to the latest versions and rebuilt your app.

@t-fritsch
Copy link

thank you for the quick feedback :) I'll try that

@d8en
Copy link

d8en commented Nov 26, 2020

FWIW I had android app crashes on launch and deleteing the 'build' folder and running npx react-native run-android fixed my problem. It took my hours to find someone who suggested that (in addition to the above dependencies suggestion). Maybe I had other issues with my build directory...

@jaquinocode
Copy link

@Martian2Lee @mustafakemalelma I found a solution. Problem is related to react-native-screens.

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'

https://github.com/kmagiera/react-native-screens#usage-with-react-navigation-without-expo

This comment's link is now outdated. The link is here now: https://github.com/software-mansion/react-native-screens/tree/2.3.0#usage-with-react-navigation-without-expo

@github-actions
Copy link

Hey! This issue is closed and isn't watched by the core team. You are welcome to discuss the issue with others in this thread, but if you think this issue is still valid and needs to be tracked, please open a new issue with a repro.

mccoyplayer pushed a commit to mccoyplayer/navigation that referenced this issue Feb 9, 2024
if not added this two lines code, the app crashed on android.
Related to this issue react-navigation/react-navigation#6267.
Dmytrozaiets81 added a commit to Dmytrozaiets81/navigation.github.io that referenced this issue Feb 27, 2025
if not added this two lines code, the app crashed on android.
Related to this issue react-navigation/react-navigation#6267.
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

11 participants