Ashok Sinh Ashok Sinh - 2 months ago 17
Android Question

Implement Library in Android

I am learning Android still in basic step. I am trying to implement WebView in one of my basic application located here.

There no any details for how to use it. I have checked sample application. I have copied WebViewTester.java as given detail in instruction. I am now trying to use it in my application like below code.

public class ShowContentActivity extends AppCompatActivity {

private WebView webView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_show_content);

webView = (WebView) findViewById(R.id.wvSample);

// Enable javascript
webView.getSettings().setJavaScriptEnabled(true);

webView.setWebViewClient(WebViewTester());

webView.loadUrl("file:///android_asset/index.html");

}
}


Now I am getting error in this line

webView.setWebViewClient(new TesterWebViewClient());


like

TesterWebViewClient cannot be resolved to a type


What's the issue? Can anybody please correct me? Sorry for basic questions. I am still learning.

Answer

There no any details for how to use it. I have checked sample application

Really?

sampleapp/build.gradle

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(path: ':webviewtester')
}

The README also says how to use it. You add this to your app/build.gradle

Download

Library dependency

dependencies {
  compile 'com.azimolabs.webviewtester:webviewtester:0.1'
}

OR you could have copied it,

Now I am getting error in this line

webView.setWebViewClient(new TesterWebViewClient());

And that makes sense because the class name is actually WebViewTester

Comments