2021年4月2日星期五

WebView doesnt appear when compiling for API 29

I developed a JAVA app for Android 9 (API 28). When i tried putting it in the play store google demanded it must be API 29 and above. So i recompiled for API 29, when i tested it at API 29, the WebView im using in the app stopped working, it worked perfectly for API 28.

Im simply using the webview for displaying simple locally generated HTML text string containing a text table and a jpg, but with API 29 it doesnt even show up on the screen, or is blank.

Here is the XML

<?xml version="1.0" encoding="utf-8"?>  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"      xmlns:tools="http://schemas.android.com/tools"      xmlns:app="http://schemas.android.com/apk/res-auto"      android:layout_width="match_parent"      android:layout_height="match_parent"      android:orientation="vertical"      android:weightSum="1"      android:background="@drawable/blue_gradient_rect"      style="@style/MyLayoutBackground">        <LinearLayout          android:layout_width="match_parent"          android:layout_height="match_parent"          android:orientation="vertical"          android:layout_margin="8dp">            <WebView              android:id="@+id/webView"              android:layout_width="match_parent"              android:layout_height="wrap_content"              android:fillViewport="true"              android:focusable="true"              android:isScrollContainer="false"              android:visibility="visible" />       </LinearLayout>  </LinearLayout>  

Here is the code snippet (most of irrelevant stuff removed)

 public WebView webView;   webView= (WebView) convertView.findViewById(com.app.mine.R.id.webView);   string html="<HTML><BODY><TABLE>....</TABLE></BODY></HTML>"; // just a sample of the real table   webView.loadData(html, "text/html", "UTF-8");  

There were no code changes from version 28 to 29, i dont know what caused the WebView to stop working. I spent the whole day trying to figure it out.

I read that google changed the WebView implementation from chrome to TriChrome in Android 10, dont know if that's causing it. I also read somewhere that google had a bug in their chrome update which caused the browser to crash, so I uninstalled that update from my phone but still my WebView doesnt work in 29.

The phone im using is android 10 by the way and it doesnt work on that. But if i compile the same code for API 28 it works, but google refuses API 28 for play store apps. So that means i cant publish the app because they demand 29 but it only works on 28 for some reason.

Does anybody have any ideas?

Thanks

https://stackoverflow.com/questions/66926807/webview-doesnt-appear-when-compiling-for-api-29 April 03, 2021 at 08:50AM

没有评论:

发表评论