简体   繁体   English

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

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

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:我有一个 react-native 项目,它应该支持 16 的最低 SDK 版本并且是 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

I searched a lot and the only related thing I found was this , which is not solving my problem.我搜索了很多,我发现的唯一相关的事情是this ,这并没有解决我的问题。

I don't know if this helps or not these are dependencies in my app/build.gradle.我不知道这是否有帮助,这些是我的 app/build.gradle 中的依赖项。 Maybe one of these or not compatible with API version 16也许其中之一或与 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'

the UserManager is added in SDK version of 17, so it can not find it. 17的SDK版本增加了UserManager,所以找不到。 you can see this link for details.您可以查看此 链接了解详情。

if you want to use it, you have to in the android native add support library.如果你想使用它,你必须在android原生添加支持库。 the com.android.support:support-compat:28.0.0-alpha1 has it. com.android.support:support-compat:28.0.0-alpha1有它。

if you have added the androidX library, you should change the class to UserManagerCompat .如果您添加了 androidX 库,您应该将类​​更改为UserManagerCompat for details, you can go into this link it is located in androidX.core .有关详细信息,您可以进入它位于androidX.core 链接 add the following at android/app/build.gradleandroid/app/build.gradle添加以下android/app/build.gradle

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android工作室很多错误:找不到类'android.XXX' - Android studio many error: Could not find class 'android.XXX' react-native android 项目未找到错误 - react-native android project not found error React-native 项目构建失败:找不到 com.android.tools.lint ,无法确定任务 ':app:lintVitalRelease' 的依赖关系 - React-native project Build failed: Could not find com.android.tools.lint , Could not determine the dependencies of task ':app:lintVitalRelease' React-Native Android Windows 错误:找不到 com.facebook.react:react-native-gradle-plugin: - React-Native Android Windows error: Could not find com.facebook.react:react-native-gradle-plugin: 尝试运行android react-native项目时出错 - Getting error when try to run android react-native project 尝试为 React-Native Android 项目启动 logKitty 时出错 - Error when trying to start logKitty for React-Native Android Project React-native项目构建失败:找不到com.android.tools.lint:lint-gradle:26.1.0 - React-native project Build failed: Could not find com.android.tools.lint:lint-gradle:26.1.0 发布React-Native Android应用:找不到com.android.support:multidex-instrumentation:27.1.1 - Release React-Native Android app: Could not find com.android.support:multidex-instrumentation:27.1.1 安装新的 react-native 项目时找不到 swiperefreshlayout-1.0.0.aar 错误 - Could not find swiperefreshlayout-1.0.0.aar error when installing new react-native project 在现有项目React-Native中添加现有的本机项目Android - Add existing native project Android in exist project React-Native
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM