-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error on Android 6 and 7 using plugin from master #386
Comments
Same issue here. Did you find a solution? Is there any other way to intercept document links other than using the master InAppBrowser with 'beforeload'? |
The problem begins at line 261:
inAppWebView.getWebViewClient() throws the error because the method getWebViewClient() was added in API level 26 (Android 7.1) as you can see in the Android Developers documentation So, the workaround I've came up with, is to actually make an API if:
Now, this is the main change, but the currentClient does not exist, so i've had to create this class property:
And on line 951, where we have this local object assign:
I've changed it to this:
Now what happens is, if you're on Android 7.1 or higher, nothing changes. But now, on Android 7 or lower, when the code needs to change the waitForBeforeload value of the InAppBrowserClient in use by the webview, you have access to that on the class scope, instead of the local only as it was before. It works for me =) |
Any plans on adding a PR for this? It looks to me that the master is still broken on Android 7 and lower. |
@caiocsl Made a PR based on your fixes. I implemented them and covered one additional case that throwed during testing. |
I'm using the code from master in my plugin, to get the 'beforeload' option in my application.
Running on Pocophone F1 with Android 9, it runs just fine, but the same app crashes on Androids 6 and 7 (couldn't test for Android 8 yet). The error thrown in the logcat is:
12-28 17:52:32.574 E/AndroidRuntime( 9825): FATAL EXCEPTION: main
12-28 17:52:32.574 E/AndroidRuntime( 9825): Process: io.cordova.onofreapp, PID: 9825
12-28 17:52:32.574 E/AndroidRuntime( 9825): java.lang.NoSuchMethodError: No virtual method getWebViewClient()Landroid/webkit/WebViewClient; in class Landroid/webkit/WebView; or its super classes (declaration of 'android.webkit.WebView' appears in /system/framework/framework.jar:classes2.dex)
12-28 17:52:32.574 E/AndroidRuntime( 9825): at org.apache.cordova.inappbrowser.InAppBrowser$2.run(InAppBrowser.java:265)
12-28 17:52:32.574 E/AndroidRuntime( 9825): at android.os.Handler.handleCallback(Handler.java:751)
12-28 17:52:32.574 E/AndroidRuntime( 9825): at android.os.Handler.dispatchMessage(Handler.java:95)
12-28 17:52:32.574 E/AndroidRuntime( 9825): at android.os.Looper.loop(Looper.java:154)
12-28 17:52:32.574 E/AndroidRuntime( 9825): at android.app.ActivityThread.main(ActivityThread.java:6776)
12-28 17:52:32.574 E/AndroidRuntime( 9825): at java.lang.reflect.Method.invoke(Native Method)
12-28 17:52:32.574 E/AndroidRuntime( 9825): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1518)
12-28 17:52:32.574 E/AndroidRuntime( 9825): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
Any ideas?
The text was updated successfully, but these errors were encountered: