使用cordova-plugin-firebase时,我遇到了以下错误:
04-27 16:59:35.745 6859 6859 E AndroidRuntime: FATAL EXCEPTION: main
04-27 16:59:35.745 6859 6859 E AndroidRuntime: Process: com.XXXXXXXXXX.XXXXXXXXXXX, PID: 6859
04-27 16:59:35.745 6859 6859 E AndroidRuntime: java.lang.NoSuchMethodError: No static method isDeviceProtectedStorage(Landroid/content/Context;)Z in class Landroid/support/v4/content/ContextCompat; or its super classes (declaration of 'android.support.v4.content.ContextCompat' appears in /data/app/com.XXXXXXXXXX.XXXXXXXXXXX-1/base.apk)
04-27 16:59:35.745 6859 6859 E AndroidRuntime: at com.google.firebase.FirebaseApp.zza(Unknown Source)
04-27 16:59:35.745 6859 6859 E AndroidRuntime: at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
04-27 16:59:35.745 6859 6859 E AndroidRuntime: at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
04-27 16:59:35.745 6859 6859 E AndroidRuntime: at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
04-27 16:59:35.745 6859 6859 E AndroidRuntime: at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
04-27 16:59:35.745 6859 6859 E AndroidRuntime: at android.content.ContentProvider.attachInfo(ContentProvider.java:1751)
04-27 16:59:35.745 6859 6859 E AndroidRuntime: at android.content.ContentProvider.attachInfo(ContentProvider.java:1726)
04-27 16:59:35.745 6859 6859 E AndroidRuntime: at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
04-27 16:59:35.745 6859 6859 E AndroidRuntime: at android.app.ActivityThread.installProvider(ActivityThread.java:5855)
04-27 16:59:35.745 6859 6859 E AndroidRuntime: at android.app.ActivityThread.installContentProviders(ActivityThread.java:5447)
04-27 16:59:35.745 6859 6859 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5386)
04-27 16:59:35.745 6859 6859 E AndroidRuntime: at android.app.ActivityThread.-wrap2(ActivityThread.java)
04-27 16:59:35.745 6859 6859 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1546)
04-27 16:59:35.745 6859 6859 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
04-27 16:59:35.745 6859 6859 E AndroidRuntime: at android.os.Looper.loop(Looper.java:154)
04-27 16:59:35.745 6859 6859 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6121)
04-27 16:59:35.745 6859 6859 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
04-27 16:59:35.745 6859 6859 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
04-27 16:59:35.745 6859 6859 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
04-27 16:59:35.749 975 1021 W ActivityManager: Force finishing activity com.XXXXXXXXXX.XXXXXXXXXXX/.MainActivity
04-27 16:59:35.779 2358 6582 I PBSessionCacheImpl: Deleted sessionId[10372086956677829] from persistence.
04-27 16:59:35.795 2358 2358 W SearchService: Abort, client detached.
04-27 16:59:35.798 2358 2358 E WorkerRegistryImpl: getWorker() is called after WorkerRegistry disposal.
04-27 16:59:35.798 2358 2358 E WorkerRegistryImpl: getWorker() is called after WorkerRegistry disposal.
起初我认为这是因为android.support.v4.content.ContextCompat中的isDeviceProtectedStorage仅在API 24及更高版本中添加。但即使使用Android 7的新设备,也会出现相同的消息。
为什么找不到方法?是因为我没有安装一些库吗?
答案 0 :(得分:-1)
根据Android开发人员文档,在24.0.0中添加了“DeviceProtectedStorage”。如果您在此提及的API版本下运行应用程序,请检查它
if (Build.VERSION.SDK_INT >= 24){
//TODO: Do your stuff here.
}