[SOLVED] Android webView - loading issue


#1

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


#2

Вы не поверите, но вбив в гугл “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


#3

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


#4

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


#5

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


#6

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


#7

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


#8

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


#9

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


#10

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