Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Webview access denied

Tags:

android

On Android 9 (Api 29) am trying to load a url and i get the error "The webpage at url could not be loaded because: net::ERR_ACCESS_DENIED".

I have internet the internet permission in the AndroidManifest.xml files

<uses-permission android:name="android.permission.INTERNET" />

From logcat, i can see the the following error as well :

E/chromium: [ERROR:socket_posix.cc(94)] CreatePlatformSocket() failed: Operation not permitted (1)

My code is as follows :

WebView webView = findViewById(R.id.webView);
webView.loadUrl("https://andela.com/alc/");

I later added the following code to get more detail :

webView.setWebViewClient(new WebViewClient(){
    @Override
    public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
        super.onReceivedError(view, request, error);
        Log.d("TAG", error.getDescription().toString());
        // handler.proceed(); This line wont make a different on API 29, Webview still bank
    }
});

The Webview loads the url properly when using an emulator running API 25. Also tested on API 28 and it works fine. Only doesn't work on API 29.

like image 305
Joseph Avatar asked Jul 15 '19 14:07

Joseph


People also ask

Why is my WebView not working?

You might often face issues in updating the chrome and Android System Webview. To fix this problem, you can reboot your device, check your internet connection, stop auto-updating all apps, clear Google Playstore cache, and storage, leave the beta testing program, and manually update Android WebView app from Playstore.

What is alternative of WebView in android?

Alternatives to WebView If you want to send users to a mobile site, build a progressive web app (PWA). If you want to display third-party web content, send an intent to installed web browsers. If you want to avoid leaving your app to open the browser, or if you want to customize the browser's UI, use Custom Tabs.

How can I solve the error net Err_unknown_url_scheme in Android WebView?

You may get this "ERR_UNKNOWN_URL_SCHEME error" during mailto: or tel: links inside an iframe. To solve it, try to add target="_blank" in your URL Scheme/Code.


2 Answers

just uninstall the app and once again install it.That work 100%

like image 61
Abhishek Kumar Avatar answered Sep 19 '22 13:09

Abhishek Kumar


In my case the web page becomes loading correctly (without ERR_ACCESS_DENIED) after changing applicationId in build.gradle (and run the app, of-course). After that you may return the old applicationId.

like image 39
Ievgen Avatar answered Sep 18 '22 13:09

Ievgen