6

There is a flutter in-appwebview issue if any one know the solution please help

`C:\src\flutter.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.4.3+7\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\in_app_webview\InAppWebView.java:280: error: cannot find symbol settings.setAppCachePath(options.appCachePath); ^ symbol: method setAppCachePath(String) location: variable settings of type WebSettings C:\src\flutter.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.4.3+7\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\in_app_webview\InAppWebView.java:494: error: cannot find symbol settings.setAppCacheEnabled(false); ^ symbol: method setAppCacheEnabled(boolean) location: variable settings of type WebSettings C:\src\flutter.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.4.3+7\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\in_app_webview\InAppWebView.java:504: error: cannot find symbol settings.setAppCacheEnabled(true); ^ symbol: method setAppCacheEnabled(boolean) location: variable settings of type WebSettings C:\src\flutter.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.4.3+7\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\in_app_webview\InAppWebView.java:515: error: cannot find symbol settings.setAppCachePath(ctx.getCacheDir().getAbsolutePath()); ^ symbol: method setAppCachePath(String) location: variable settings of type WebSettings C:\src\flutter.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.4.3+7\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\in_app_webview\InAppWebView.java:517: error: cannot find symbol settings.setAppCacheEnabled(true); ^ symbol: method setAppCacheEnabled(boolean) location: variable settings of type WebSettings C:\src\flutter.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.4.3+7\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\in_app_webview\InAppWebView.java:521: error: cannot find symbol settings.setAppCacheEnabled(false); ^ symbol: method setAppCacheEnabled(boolean) location: variable settings of type WebSettings C:\src\flutter.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.4.3+7\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\in_app_webview\InAppWebView.java:767: error: cannot find symbol settings.setAppCachePath(newOptions.appCachePath); ^ symbol: method setAppCachePath(String) location: variable settings of type WebSettings Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 7 errors

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':flutter_inappwebview:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 11s Exception: Gradle task assembleDebug failed with exit code 1 `

3 Answers3

3

Such Methods are remove, you can see Android Developer Document

Now Only LOAD_DEFAULT is enough set this code

viewer.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT)
Sanjay
  • 574
  • 6
  • 16
0

I recommend to use webview_flutter_plus package. It's simple and easy to implement. I provide an example code for you.

First of all, you need to install the package: flutter pub add webview_flutter_plus

Then you need to import it: import 'package:webview_flutter_plus/webview_flutter_plus.dart';

And there is the example code that you can modify:

WebViewPlus(
  onWebViewCreated: (controller) {
    controller.loadUrl('https://example.com'); // the URL that you want to load
  },
),

And if you build to android you need to set minSdkVersion to 19

Then you need to add these lines to your android manifest file:

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

If you use HTTP domains you need to add this line to your application section in in your manifest file like this:

<application
       ...
       android:usesCleartextTraffic="true">
       ...
</application>

I hope it helped.

0

Update flutter_inappwebview version to latest. It works for me.

flutter_inappwebview: ^5.7.2+2
logi-kal
  • 7,107
  • 6
  • 31
  • 43