0

enter image description herethis is the xml file for the webview

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.testing.WebViewExample">

    <WebView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/webView"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>  

and this code is for Webview.java

      public class MainActivity extends AppCompatActivity {
      @Override  
      protected void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
        setContentView(R.layout.activity_main);  
        WebView mywebview = (WebView) findViewById(R.id.webView);  
        
        mywebview.loadUrl("https://www.google.com/");  
  
      
    }  
}  

But the problem is I am not able to view the google and it show an error as webpage not available

the webpage at https://www.google.com/ could not be loaded because:

net::ERR_CACHE_MISS

ACHU
  • 58
  • 9

1 Answers1

1

You may need to add the INTERNET permission to your manifest file:

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

Another Reference: loadUrl() in Android Webview fails with net::ERR_CACHE_MISS

macrofox
  • 86
  • 7
  • After giving permission new error come webpage is not available webpage is not available the webpage at https://www.google.com/ could not be loaded because: net::ERR_CLEARTEXT_NOT_PERMITTED – ACHU Apr 22 '21 at 10:18
  • Are you still going to HTTPS://www.google.com? Or some variation on that? Can you please post an image or log of the whole error? (Warnings/Errors/Stack Trace, etc...) – macrofox Apr 22 '21 at 12:26
  • added image of error .I use my phone for debugging...I give permission and data/internet on in my mobile also – ACHU Apr 23 '21 at 05:45
  • Its worked .please close the question/stop accepting answer.Thanks – ACHU Apr 26 '21 at 07:57
  • Answer is in comment can I mark above answer as answer.Is there any problem doing like so.. – ACHU Apr 27 '21 at 04:38