[SOLVED] Android webView - loading issue

Dear all

my App is running fine under Chome - no issues / no bugs.

I am just moving to Android (Android Studio and an bug occurs when I try to load framework7:

Uncaught TypeError: Object.assign is not a function", source: file:///android_asset/www/shoma/js.vendor/framework7-4.1.0.min.js

Code for the webview:

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

WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setDatabaseEnabled(true);
webSettings.setDomStorageEnabled(true);
webSettings.setAllowFileAccessFromFileURLs(true);
webSettings.setAllowUniversalAccessFromFileURLs(true);

myJSInterface = new jsInterface(this, appContext);

webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
webView.setBackgroundColor(Color.parseColor("#000000"));
webView.loadUrl("file:///android_asset/www/shoma/index.html");

Any ideas?

BR
Andreas

Вы не поверите, но вбив в гугл “Object.assign is not a function” сразу дает ссылку на этоhttps://stackoverflow.com/questions/31764414/object-assign-is-not-a-function где говорится, что “As I suspect you already know, Google Chrome uses V8, which supports ECMAScript 5th edition. Object.assign is introduced in ECMAScript 6th edition.”

Теперь вбиваем в гугл “ECMAScript 6th android chrome support” и узнаем, что это поддерживается только в Android >=5

Framework7 v4 is not supported in Android 4. Only from Android 5. You can also try to add this polyfill https://github.com/christiansany/object-assign-polyfill but the rest of things still may not work

Dear both,

many thanks.
But actually, I am already using as “min SDK Version” 21 … This means android 5.0…
And in the Android Simulator I am using a Nexus 5 (API Level 23).

In the log it is stated
Loading com.android.webview version 44.0.2403.119 (code 246011960)

Regards
Andreas

Solved…

With Android 5.0 the webView is an external application (apk). Solution: Use a different emulated device using a different (sufficient) webView version.

https://developer.chrome.com/multidevice/webview/overview

1 Like

framework v4 поддерживает 6 андроид ? просто я через браузер андроида заходил в демо версию ui компонентов и ничего не работало, на 7 версии все отрабатывает

Только что проверил на 6м

хм, завтра или в понедельник проверю, скрины сброшу, у меня на одном из устройств просто белый лист, на другом ломает календари и списки не выводит list viewandroid6 android 6

всё перепроверил, обновил webview работает :star_struck:

Dear all,

comming back to the original question & answers from shastox/nolimits4web: How to figure out if the correct version of the webview is installed. Since it is a separate apk it is not 100% sure that all Android devices >=5.0 will support ECMA v6 (and therefore FW7.v4 can be used).

At leas there should be a popup to inform the customer. Otherwise the App will not start (blank screen) and there is a bad rating in the app store.

So, idea would be

  • check webview version before (how? which version is required)?
  • or (very likely not sufficient): if (Object.assign == undefined)…

Any idea?

Best regards
Andreas

1 Like

This plugin can help: