美文网首页
RN Exception: Unable to get prov

RN Exception: Unable to get prov

作者: _凌浩雨 | 来源:发表于2020-04-15 16:10 被阅读0次

    异常

    04-15 11:25:40.920 15594-15594/com.mazaiting.xxx E/AndroidRuntime: FATAL EXCEPTION: main
        Process: com.mazaiting.xxx, PID: 15594
        java.lang.RuntimeException: Unable to get provider com.reactnativecommunity.webview.RNCWebViewFileProvider: java.lang.ClassNotFoundException: Didn't find class "com.reactnativecommunity.webview.RNCWebViewFileProvider" on path: DexPathList[[zip file "/data/app/com.mazaiting.xxx-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.mazaiting.xxx-1, /vendor/lib, /system/lib]]
            at android.app.ActivityThread.installProvider(ActivityThread.java:5182)
            at android.app.ActivityThread.installContentProviders(ActivityThread.java:4753)
            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4686)
            at android.app.ActivityThread.access$1500(ActivityThread.java:174)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1458)
            at android.os.Handler.dispatchMessage(Handler.java:110)
            at android.os.Looper.loop(Looper.java:229)
            at android.app.ActivityThread.main(ActivityThread.java:5493)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:676)
            at dalvik.system.NativeStart.main(Native Method)
         Caused by: java.lang.ClassNotFoundException: Didn't find class "com.reactnativecommunity.webview.RNCWebViewFileProvider" on path: DexPathList[[zip file "/data/app/com.mazaiting.xxx-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.mazaiting.xxx-1, /vendor/lib, /system/lib]]
            at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
            at android.app.ActivityThread.installProvider(ActivityThread.java:5167)
            at android.app.ActivityThread.installContentProviders(ActivityThread.java:4753) 
            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4686) 
            at android.app.ActivityThread.access$1500(ActivityThread.java:174) 
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1458) 
            at android.os.Handler.dispatchMessage(Handler.java:110) 
            at android.os.Looper.loop(Looper.java:229) 
            at android.app.ActivityThread.main(ActivityThread.java:5493) 
            at java.lang.reflect.Method.invokeNative(Native Method) 
            at java.lang.reflect.Method.invoke(Method.java:515) 
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:676) 
            at dalvik.system.NativeStart.main(Native Method) 
    

    解决方法

    • 添加 multidex 库
    implementation 'androidx.multidex:multidex:2.0.1'
    
    • 配置 app/build.gradle
    android {
        compileSdkVersion rootProject.ext.compileSdkVersion
    
        defaultConfig {
            // ...
            multiDexEnabled true
        }
    }
    
    • 在 MainApplication 中添加如下代码
      override fun attachBaseContext(base: Context?) {
        super.attachBaseContext(base)
        MultiDex.install(this)
      }
    

    相关文章

      网友评论

          本文标题:RN Exception: Unable to get prov

          本文链接:https://www.haomeiwen.com/subject/enwcvhtx.html