Skip to content

Android Webview Error: 2ST #9740

@ivanhe123

Description

@ivanhe123

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

Basically, I tried to render this webpage: falibday.streamlit.app in Android Web View, and this error turns up, this is not because of my code tho, I tried a few other streamlit cloud webpages and it all ended up like this:

Error Image

Reproducible Code Example

import streamlit as st

st.write("BRU WHY")

Steps To Reproduce

  1. Create a Android app with manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

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

    <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:usesCleartextTraffic="true"
        android:theme="@style/Theme.WEbBrowse"
        tools:targetApi="31">
        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:id="@+id/main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <WebView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/web_view"/>

</RelativeLayout>

MainActivity.java

package com.example.webbrowse;

import android.os.Bundle;
import android.util.Patterns;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class MainActivity extends AppCompatActivity {
    WebView webView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        webView=findViewById(R.id.web_view);

        WebSettings webSettings = webView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setBuiltInZoomControls(true);
        webSettings.setDisplayZoomControls(false);

        webView.setWebViewClient(new MyWebViewClient());

        loadMyUrl("https://falibday.streamlit.app");


    }

    void loadMyUrl(String url){
        boolean matchUrl = Patterns.WEB_URL.matcher(url).matches();
        if (matchUrl){
            webView.loadUrl(url);
        }else{
            webView.loadUrl("https://falibday.streamlit.app");
        }
    }

    class MyWebViewClient extends WebViewClient{
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
            return false;
        }
    }
}
  1. Use the reporducible code above to send it onto cloud, and then render the url for ur deployed cloud using the android app code above.

Expected Behavior

I expect it to just render like on PC or on a normal Android phone browser.

Current Behavior

Error Message:

Error: Cannot read properties of null (reading 'getItem')
Code: 2ST

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit and Python version: Streamlit Cloud Default
  • Operating System: Android
  • Browser: Web View Android APK

Additional Information

I posted this on discuss.streamlit.io but no one noticed, this is very urgent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:frontendRelated to frontend aspectspriority:P3Medium prioritytype:bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions