简体   繁体   中英

React-native app is not running on Android 4.3

My react-native app has following package.json

{
  "name": "Seller",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint .",
    "cleanA": "cd android && ./gradlew clean && cd ..",
    "apk": "cd android && ./gradlew assembleRelease && cd .."
  },
  "dependencies": {
    "@react-native-community/async-storage": "^1.10.3",
    "@react-native-community/geolocation": "^2.0.2",
    "@react-native-community/masked-view": "0.1.6",
    "@react-native-community/picker": "^1.4.0",
    "@react-native-firebase/app": "^6.7.1",
    "@react-native-firebase/auth": "^6.7.1",
    "@react-native-firebase/messaging": "^6.7.1",
    "@react-navigation/bottom-tabs": "^5.3.3",
    "@react-navigation/drawer": "^5.6.3",
    "@react-navigation/material-top-tabs": "^5.1.14",
    "@react-navigation/native": "^5.2.3",
    "@react-navigation/stack": "^5.2.18",
    "react": "16.11.0",
    "react-native": "0.62.2",
    "react-native-chart-kit": "^5.5.0",
    "react-native-elements": "^2.0.0",
    "react-native-gesture-handler": "~1.6.0",
    "react-native-image-picker": "^2.3.1",
    "react-native-reanimated": "~1.7.0",
    "react-native-safe-area-context": "0.7.3",
    "react-native-screens": "~2.2.0",
    "react-native-svg": "^12.1.0",
    "react-native-tab-view": "^2.14.0",
    "react-native-vector-icons": "^6.6.0",
    "react-redux": "^7.2.0",
    "redux": "^4.0.5",
    "redux-devtools-extension": "^2.13.8",
    "redux-thunk": "^2.3.0"
  },
  "devDependencies": {
    "@babel/core": "^7.6.2",
    "@babel/runtime": "^7.6.2",
    "@react-native-community/eslint-config": "^0.0.5",
    "babel-jest": "^24.9.0",
    "eslint": "^6.5.1",
    "jest": "^24.9.0",
    "metro-react-native-babel-preset": "^0.58.0",
    "react-test-renderer": "16.11.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

It is running fine on Android 5.0 and above. Min SDK version is 16. However, it is not running on Android 4.3

Exception trace is given below:

FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: org.reactnative.maskedview.RNCMaskedViewPackage
    at com.facebook.react.PackageList.getPackages(PackageList.java:87)
    at com.khareeddari.seller.MainApplication$1.getPackages(MainApplication.java:27)
    at com.facebook.react.ReactNativeHost.createReactInstanceManager(ReactNativeHost.java:77)
    at com.facebook.react.ReactNativeHost.getReactInstanceManager(ReactNativeHost.java:39)
    at com.khareeddari.seller.MainApplication.onCreate(MainApplication.java:48)
    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4684)
    at android.app.ActivityThread.access$1400(ActivityThread.java:159)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1376)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:176)
    at android.app.ActivityThread.main(ActivityThread.java:5419)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
    at dalvik.system.NativeStart.main(Native Method)

I tried to change compileSdkVersion in android/build.gradle . However after that, I am getting compiler in dependent packages as they are not getting compiled with Java 1.6.

What are the steps to resolve this problem?

This could be a multidex issue, as multidex is enabled by default on android 5.0 and above. If your running APK < 21 and your application has more than 64,000 methods you need to enable multidex in android. Refer to the following docs -

https://developer.android.com/studio/build/multidex

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM