Java 我的Android应用程序不支持Android版本9
我制作了一个使用webView的android应用程序。一切都很好,直到我在安卓P上尝试我的应用程序。在安卓“P”上,该应用程序直接显示错误页面,该应用程序无法使用互联网连接,即使它已打开 Android清单文件:Java 我的Android应用程序不支持Android版本9,java,android,xml,webview,version,Java,Android,Xml,Webview,Version,我制作了一个使用webView的android应用程序。一切都很好,直到我在安卓P上尝试我的应用程序。在安卓“P”上,该应用程序直接显示错误页面,该应用程序无法使用互联网连接,即使它已打开 Android清单文件: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.xxx.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xxx.xxxxx.xxxxx">
<!-- android:roundIcon="@mipmap/ic_launcher_round" -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<application
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:hardwareAccelerated="true"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name="com.xxxxx.xxxxx.xxxxxx.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
在Android p中出现错误时,直接访问此部分:
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
// You can redirect to your own page instead getting the default error page
super.onReceivedError(view, errorCode, description, failingUrl);
String path = Uri.parse("file:///android_asset/error.html").toString();
webView.loadUrl("about:blank");
view.loadUrl(path);
}
我不是安卓专家,但您已经告诉Gradle,您不想在Gradle文件中支持早于版本19的安卓 将其更改为与您真正想要支持和重建应用程序的最低版本相匹配。您可能会遇到构建错误,指出不应该使用的API,以及其他可移植性问题。纠正他们 参考:
- 我发现了错误,net:ERR\u CLEARTEXT\u不允许
解决方案为1。没有足够的错误信息。请编辑您的问题以包含生成的错误。2) 我会试试
file:///android_asset/error.html
作为一个没有Uri.parse()的普通字符串。谢谢,我删除了.html文件以查看确切的错误。可能是
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
// You can redirect to your own page instead getting the default error page
super.onReceivedError(view, errorCode, description, failingUrl);
String path = Uri.parse("file:///android_asset/error.html").toString();
webView.loadUrl("about:blank");
view.loadUrl(path);
}