2

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?

Kara
  • 6,115
  • 16
  • 50
  • 57
topwik
  • 3,487
  • 8
  • 41
  • 65

2 Answers2

2

Fixed by commenting out ProGuard!

topwik
  • 3,487
  • 8
  • 41
  • 65
1

Hi i had same issue but now i resolved you need to generate a new key with your new keystore from which you are signing the APK for debug purpose you have to use your android debug.keystore but for production you have your own .keystore file, go to the android docs to "how to generate map api key.

Please refer this post for more detailed information Click here

Community
  • 1
  • 1
androidgeek
  • 3,440
  • 1
  • 15
  • 27
  • is this true even when I am using a Web View with a google map based web page loaded within? Please Note that I am NOT using the android map view control. thanks. – topwik Feb 28 '13 at 17:50
  • i just tried changing the url to something like google.com, err my main company webstie rather, built the APK and installed it on my device and it loads the page properly. so there may be some API key thing I am missing... – topwik Feb 28 '13 at 18:06
  • yes in you main company website url consists of API key so it is only for debug purpose , then u signed the apk so it is not valid you should generate new key using your Signed keystore then try it will work... – androidgeek Feb 28 '13 at 18:13
  • i'm not sure i follow you entirely. so if i load a regular website, like google.com in my webview, build my APK install it on my phone, the web page displays properly. if i load https://mysite.com/myWebApp/WebMap/Default.html it works in eclipse, without a key (i think...) but once I build APK, blank page. Where do I get the key? is it the same as the android map view key? – topwik Feb 28 '13 at 18:24
  • Ohhhhh!!!! – topwik Feb 28 '13 at 18:27
  • u think that key can be the same one i use for the google map view? gonna try it. thanks. i now have a good lead. – topwik Feb 28 '13 at 18:28
  • hmmm the api key i use for my android map view doesn't work. Google has disabled use of the Maps API for this application. The provided key is not a valid Google API Key, or it is not authorized for the Google Maps Javascript API v3 on this site. If you are the owner of this application, you can learn about obtaining a valid key here: – topwik Feb 28 '13 at 18:42
  • OK check the below links kit may useful [link](https://developers.google.com/maps/documentation/javascript/tutorial) – androidgeek Feb 28 '13 at 18:47
  • ok i've followed the link, i have an API key and using the key I can load my web page in firefox and chrome without the warning now. still, blank page in android web view! oh no. – topwik Feb 28 '13 at 19:37
  • the reports on my key are working when i view the reports in my console so the key is legit and the page is now workign with the key in my desktop browsers. it's not working in android web view... dag. :( – topwik Feb 28 '13 at 19:40
  • OK @towpse i will check but in my case i follow the above procedure it worked for me if any information related to this i will share you thanks........ – androidgeek Feb 28 '13 at 19:59