Rohit kumar
Rohit kumar

Reputation: 31

ClassNotFoundException while opening webview in react-native

I am trying to open a webview in react native with below code:

render() {
    console.log("URL in webview:" +this.props.navigation.state.params.url);
    return <WebView source={{ uri: this.props.navigation.state.params.url }} />;
}

But when I try to open a URL, it gives:

Rejecting re-init on previously-failed class java.lang.Class: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/webkit/TracingController; 
    at java.lang.Class java.lang.Class.classForName!(java.lang.String, boolean, java.lang.ClassLoader) (Class.java:-2)
    at java.lang.Class java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (Class.java:400)
    at java.lang.Class android.webkit.WebViewFactory.getProviderClass() (WebViewFactory.java:349)
    at android.webkit.WebViewFactoryProvider android.webkit.WebViewFactory.getProvider() (WebViewFactory.java:194)
    at android.webkit.WebViewFactoryProvider android.webkit.WebView.getFactory() (WebView.java:2331)
    at void android.webkit.WebView.ensureProviderCreated() (WebView.java:2326)
    at void android.webkit.WebView.setOverScrollMode(int) (WebView.java:2385)
    at void android.view.View.(android.content.Context) (View.java:4007)
    at void android.view.View.(android.content.Context, android.util.AttributeSet, int, int) (View.java:4126)
    at void android.view.ViewGroup.(android.content.Context, android.util.AttributeSet, int, int) (ViewGroup.java:578)
    at void android.widget.AbsoluteLayout.(android.content.Context, android.util.AttributeSet, int, int) (AbsoluteLayout.java:55)
    at void android.webkit.WebView.(android.content.Context, android.util.AttributeSet, int, int, java.util.Map, boolean) (WebView.java:627)
    at void android.webkit.WebView.(android.content.Context, android.util.AttributeSet, int, int) (WebView.java:572)
    at void android.webkit.WebView.(android.content.Context, android.util.AttributeSet, int) (WebView.java:555)
    at void android.webkit.WebView.(android.content.Context, android.util.AttributeSet) (WebView.java:542)
    at void android.webkit.WebView.(android.content.Context) (WebView.java:532)
    at void com.facebook.react.views.webview.ReactWebViewManager$ReactWebView.(com.facebook.react.uimanager.ThemedReactContext) (ReactWebViewManager.java:248)
    at com.facebook.react.views.webview.ReactWebViewManager$ReactWebView com.facebook.react.views.webview.ReactWebViewManager.createReactWebViewInstance(com.facebook.react.uimanager.ThemedReactContext) (ReactWebViewManager.java:357)
    at android.webkit.WebView com.facebook.react.views.webview.ReactWebViewManager.createViewInstance(com.facebook.react.uimanager.ThemedReactContext) (ReactWebViewManager.java:362)
    at android.view.View com.facebook.react.views.webview.ReactWebViewManager.createViewInstance(com.facebook.react.uimanager.ThemedReactContext) (ReactWebViewManager.java:86)
    at android.view.View com.facebook.react.uimanager.ViewManager.createView(com.facebook.react.uimanager.ThemedReactContext, com.facebook.react.touch.JSResponderHandler) (ViewManager.java:44)
    at void com.facebook.react.uimanager.NativeViewHierarchyManager.createView(com.facebook.react.uimanager.ThemedReactContext, int, java.lang.String, com.facebook.react.uimanager.ReactStylesDiffMap) (NativeViewHierarchyManager.java:224)
    at void com.facebook.react.uimanager.UIViewOperationQueue$CreateViewOperation.execute() (UIViewOperationQueue.java:153)
    at void com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.dispatchPendingNonBatchedOperations(long) (UIViewOperationQueue.java:1006)
    at void com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(long) (UIViewOperationQueue.java:977)
    at void com.facebook.react.uimanager.GuardedFrameCallback.doFrame(long) (GuardedFrameCallback.java:31)
    at void com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(long) (ReactChoreographer.java:136)
    at void com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(long) (ChoreographerCompat.java:107)
    at void android.view.Choreographer$CallbackRecord.run(long) (Choreographer.java:871)
    at void android.view.Choreographer.doCallbacks(int, long) (Choreographer.java:685)
    at void android.view.Choreographer.doFrame(long, int) (Choreographer.java:618)
    at void android.view.Choreographer$FrameDisplayEventReceiver.run() (Choreographer.java:859)
    at void android.os.Handler.handleCallback(android.os.Message) (Handler.java:754)
    at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:95)
    at void android.os.Looper.loop() (Looper.java:165)
    at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6365)
    at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
    at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:883)
    at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:773)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.webkit.TracingController" on path: DexPathList[[zip file "/data/app/com.android.chrome-2/base.apk"],nativeLibraryDirectories=[/data/app/com.android.chrome-2/lib/arm,  /data/app/com.android.chrome-2/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]] ...

The code works with API level 28, but throw above error in API level 24. I searched that the class TracingController was introduced in API level 28, and i am trying to open webview in API 24, but i dont know how i can i configure it to open in API level 24.

My build.gradle file:

defaultConfig {
        minSdkVersion 21
        targetSdkVersion com.amazon.brazil.android.SDK.platformVersion.toInteger()

Any hint on what to do to open WebView, or how can i open webview in API level 24? If I am running on API level 24, why is it trying to access a file introduced in API level 28?

Upvotes: 3

Views: 4169

Answers (1)

LBC
LBC

Reputation: 471

You are likely seeing the same issue addressed in this particular SO answer.

Basically, according to Google, it was introduced in WebView changes for O+ and triggers this message to be improperly logged within the WebView code on <=N devices. It is not an actual error so you can ignore it.

I get the exact same NCDFE for TracingController in my webview code and can confirm it has no ill effects. Unfortunately, it spams the log messages so hopefully they fix it soon.

Upvotes: 2

Related Questions