导出到已签名的APK后,Web视图不会加载页面 [英] web view not loading page after exporting to signed APK
问题描述
我有一个android应用程序,它使用web视图来加载一个网页,其中包含谷歌地图和一些javascript,android应用程序可以与之进行交互以绘制针脚并对信息框点击等进行操作。
b$ b
我通过https托管我的网页到现场制作服务器上。
所以我有我的web视图加载页面:
字符串mapViewUrl =https://mywebsite.com/mywebsite/MyMapApp/Default.html;
在OnCreate中:
webMapView =(WebView)findViewById(R.id.webMapView);
webMapView.getSettings()。setJavaScriptEnabled(true);
webMapView.addJavascriptInterface(new JavaScriptInterface(this),android);
webMapView.getSettings()。setPluginsEnabled(true);
webMapView.getSettings()。setDomStorageEnabled(true);
webMapView.getSettings()。setBuiltInZoomControls(true);
webMapView.getSettings()。setSupportZoom(true);
webMapView.getSettings()。setAllowFileAccess(true);
webMapView.getSettings()。setGeolocationEnabled(true);
final String centerURL =javascript:centerAt(+ lat +,+ lon +);
//等待页面加载,然后发送位置信息
webMapView.setWebViewClient(new WebViewClient(){
@Override
public void onPageFinished(WebView view ,String url){
webMapView.loadUrl(centerURL);
}
});
webMapView.loadUrl(mapViewUrl);
现在,当我通过eclipse和w / o degub运行应用程序时,它可以工作。 Web视图加载地图。交互工作。很好。
然后我输出一个签名的APK。将APK复制到我的设备。安装它。运行。没有地图。只是一个空白的白色web视图与我的android控制。是什么赋予了?
任何人都可以提供任何建议吗?
通过评论ProGuard修复!
I have an android app that uses a web view to load a web page that have a google map and some javascript that the android app can interact with to plot pins and do actions on info box clicks etc.
I'm hosting my page on a live production server over https.
So I have my web view load the page like so:
String mapViewUrl = "https://mywebsite.com/mywebsite/MyMapApp/Default.html";
in OnCreate:
webMapView = (WebView) findViewById(R.id.webMapView);
webMapView.getSettings().setJavaScriptEnabled(true);
webMapView.addJavascriptInterface(new JavaScriptInterface(this), "android");
webMapView.getSettings().setPluginsEnabled(true);
webMapView.getSettings().setDomStorageEnabled(true);
webMapView.getSettings().setBuiltInZoomControls(true);
webMapView.getSettings().setSupportZoom(true);
webMapView.getSettings().setAllowFileAccess(true);
webMapView.getSettings().setGeolocationEnabled(true);
final String centerURL = "javascript:centerAt(" + lat + "," + lon + ")";
//Wait for the page to load then send the location information
webMapView.setWebViewClient(new WebViewClient(){
@Override
public void onPageFinished(WebView view, String url){
webMapView.loadUrl(centerURL);
}
});
webMapView.loadUrl(mapViewUrl);
Now when I run the app through eclipse, with and w/o degub, it works. Web view loads the map. Interaction works. Nice.
I then export a signed APK. Copy the APK to my device. Install it. Run it. No map. Just a blank white web view with my android controls. What gives? Can anyone offer any advice?
Fixed by commenting out ProGuard!
这篇关于导出到已签名的APK后,Web视图不会加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!