저는 Ionic
애플리케이션을 제작 중이며 사용자 정의 Android wrapper
에 포장해야합니다. 기본적으로 다운로더에 연결된 간단한 WebView
입니다. 가능할 때마다 앱은 업데이트가 있는지 확인하고 Ionic souces
을 로컬 디렉토리에 다운로드합니다.이오닉 - 맞춤 Android 래퍼
다운로더는 완벽하게 작동하지만 WebView
에 로컬 웹 사이트를로드해야 할 때 문제가 발생합니다. 지금까지, 여기에 내 코드입니다 : 흰색 페이지
WebSettings webSettings = webview.getSettings();
webSettings.setDatabaseEnabled(true);
webSettings.setGeolocationEnabled(true);
webSettings.setJavaScriptEnabled(true);
webSettings.setSupportMultipleWindows(false);
webSettings.setRenderPriority(RenderPriority.HIGH);
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT)
{
webSettings.setDatabasePath(getFilesDir().getPath() + "databases/");
}
if (Build.VERSION.SDK_INT >= 11)
{
webview.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
webview.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
// Attach listeners
webview.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
if (Uri.parse(url).getHost().contains(Constants.END_POINT) || Uri.parse(url).getScheme().contains("file")) return false;
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
return true;
}
@Override
public void onPageFinished(WebView view, String url)
{
super.onPageFinished(view, url);
layout_progress.setVisibility(View.GONE);
webview.setVisibility(View.VISIBLE);
}
});
webview.setWebChromeClient(new WebChromeClient() {
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback)
{
callback.invoke(origin, true, false);
}
});
// Attach javascript interface
webview.addJavascriptInterface(new WrapperJSInterface(this, webview), "Wrapper");
// Load index
String index = "/data/data/com.my.wrapper/files/#"
webview.loadUrl("file://" + index);
WebView
로드하지만 이와 같은 몇 가지 오류가 발생합니다 : 저도 같은 문제가 발생했을 사람들을 조사하고 발견했습니다
12-01 15:26:47.793: E/Web Console(8931): Uncaught ReferenceError: start is not defined at file:///data/data/com.my.wrapper/files/#/app/feed:1
12-01 15:26:47.808: E/Web Console(8931): Uncaught ReferenceError: addRow is not defined at file:///data/data/com.my.wrapper/files/#/app/feed:2
12-01 15:26:47.808: E/Web Console(8931): Uncaught ReferenceError: addRow is not defined at file:///data/data/com.my.wrapper/files/#/app/feed:3
12-01 15:26:47.808: E/Web Console(8931): Uncaught ReferenceError: addRow is not defined at file:///data/data/com.my.wrapper/files/#/app/feed:4
12-01 15:26:47.808: E/Web Console(8931): Uncaught ReferenceError: addRow is not defined at file:///data/data/com.my.wrapper/files/#/app/feed:5
12-01 15:26:47.808: E/Web Console(8931): Uncaught ReferenceError: addRow is not defined at file:///data/data/com.my.wrapper/files/#/app/feed:6
을 . 그러나 나는 그것을 고칠 수 없었다. 이 도움이 될 수있는 경우 http://forum.ionicframework.com/t/uncaught-referenceerror-addrow-is-not-defined/9266
, 나는 어떤 방법으로 Cordova
를 사용 하지입니다.
도움 주셔서 감사합니다.
"웹 콘솔"오류가로드중인 파일에 자바 스크립트 오류가 있습니다에
String index = "/data/data/com.my.wrapper/files/#"
을 변경했습니다. 파일이 앱에 포함 된 것으로 판단되면 오류를 해결할 수있는 권한이 있어야합니다. – EJK
'Chrome 브라우저'또는 내 컴퓨터에서 앱을 직접 실행하는 중에 오류가 발생하지 않습니다. – Manitoba
'index'가'/'로 시작하고'file : /// data ... '의 결과를 위해'file : //'을 앞에 붙이는 것을 알고 계십니까? – 323go