React-native android project with many error: Could not find class 'android.XXX'

本秂侑毒 提交于 2020-01-25 06:38:33

问题


I have a react-native project which should support minimum SDK version of 16 and is androidX but I get these errors using android studio logcat:

 E/dalvikvm: Could not find class 'android.os.UserManager', referenced from method androidx.core.os.UserManagerCompat.isUserUnlocked
 12-21 16:19:25.003 12695-12695/? E/dalvikvm: Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.common.wrappers.PackageManagerWrapper.zzb
 12-21 16:19:25.153 12695-12719/? E/dalvikvm: Could not find class 'android.app.AppOpsManager', referenced from method androidx.core.app.AppOpsManagerCompat.noteOp
 12-21 16:19:25.153 12695-12719/? E/dalvikvm: Could not find class 'android.app.AppOpsManager', referenced from method androidx.core.app.AppOpsManagerCompat.noteOpNoThrow
 12-21 16:19:25.153 12695-12719/? E/dalvikvm: Could not find class 'android.app.AppOpsManager', referenced from method androidx.core.app.AppOpsManagerCompat.noteProxyOp
 12-21 16:19:25.153 12695-12719/? E/dalvikvm: Could not find class 'android.app.AppOpsManager', referenced from method androidx.core.app.AppOpsManagerCompat.noteProxyOpNoThrow
 12-21 16:19:25.213 12695-12695/? E/dalvikvm: Could not find class 'com.crashlytics.android.ndk.CrashlyticsNdk', referenced from method com.crashlytics.android.CrashlyticsInitProvider.createCrashlyticsKits
 12-21 16:19:25.464 12695-12735/com.myProject.demo E/dalvikvm: Could not find class 'android.os.UserManager', referenced from method com.google.android.gms.common.GooglePlayServicesUtilLight.isRestrictedUserProfile
 12-21 16:19:25.884 12695-12735/com.myProject.demo E/Fabric: Settings request failed.
 12-21 16:19:25.894 12695-12736/com.myProject.demo E/Answers: Failed to retrieve settings

I searched a lot and the only related thing I found was this, which is not solving my problem.

I don't know if this helps or not these are dependencies in my app/build.gradle. Maybe one of these or not compatible with API version 16

// Firebase dependencies
implementation "com.google.android.gms:play-services-base:17.1.0"
implementation 'com.google.firebase:firebase-analytics:17.2.1'
implementation "com.google.firebase:firebase-core:17.2.1"
implementation "com.google.firebase:firebase-config:19.0.4"
implementation 'com.google.firebase:firebase-perf:19.0.3'
implementation "com.google.firebase:firebase-messaging:20.1.0"
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'

// Android X
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha03'
implementation 'androidx.multidex:multidex:2.0.1'

回答1:


the UserManager is added in SDK version of 17, so it can not find it. you can see this link for details.

if you want to use it, you have to in the android native add support library. the com.android.support:support-compat:28.0.0-alpha1 has it.

if you have added the androidX library, you should change the class to UserManagerCompat. for details, you can go into this link it is located in androidX.core. add the following at android/app/build.gradle

def core_role_version = "1.0.0-alpha01"
implementation "androidx.core:core-role:$core_role_version"


来源:https://stackoverflow.com/questions/59436439/react-native-android-project-with-many-error-could-not-find-class-android-xxx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!