带有很多错误的React-native android项目:找不到类“ android.XXX”

时间:2019-12-21 13:05:13

标签: android react-native versioning

我有一个React-native项目,该项目应支持最低SDK版本16,并且是androidX,但是我使用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

我进行了很多搜索,发现的唯一相关内容是this,这并不能解决我的问题。

我不知道这是否有帮助,这些是我的app / build.gradle中的依赖项。可能是其中之一,或者与API版本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 个答案:

答案 0 :(得分:0)

UserManager是在SDK版本17中添加的,因此找不到它。您可以查看此link了解详情。

如果要使用它,则必须在android native中添加支持库。 com.android.support:support-compat:28.0.0-alpha1拥有它。

如果您已添加androidX库,则应将类更改为UserManagerCompat。有关详细信息,您可以进入此link 它位于androidX.core中。在android/app/build.gradle

中添加以下内容
def core_role_version = "1.0.0-alpha01"
implementation "androidx.core:core-role:$core_role_version"