RN Exception: Unable to get provider com.reactnativecommunity.webview.RNCWebViewFileProvider

异常
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)
  }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值