native maps defaulting to openstreet on android, crashing on ios

24 views
Skip to first unread message

howud...@gmail.com

unread,
Sep 15, 2016, 11:03:11 AM9/15/16
to CodenameOne Discussions
I am using the googlemaps.MapContainer and testing on android and ios.  when I run in android it loads OSM instead of googlemaps, which means it's falling back.  On ios it just crashes.  What am I missing?

here are my build hints:
codename1.ios.appid=7WG765AP54.com.howudodat.testapp
codename1
.ios.release.provision=
codename1
.arg.java.version=8
codename1
.arg.ios.objC=true
codename1
.j2me.nativeTheme=nativej2me.res
codename1
.displayName=TESTAPP
codename1
.arg.ios.pods.platform=7.0
codename1
.android.keystoreAlias=
codename1
.ios.release.certificate=
codename1
.android.keystorePassword=
codename1
.ios.provision=
codename1
.arg.ios.glAppDelegateHeader=\n\#import "GoogleMaps/GoogleMaps.h"
codename1
.arg.android.includeGPlayServices=true
codename1
.languageLevel=5
codename1
.android.keystore=
codename1
.arg.ios.pods=,GoogleMaps
ios
.afterFinishLaunching=[GMSServices provideAPIKey\:@"MY_API_KEY_IS_HERE"];
codename1
.vendor=CodenameOne
codename1
.mainName=TESTAPP

codename1
.arg.ios.pods.sources=,https\://github.com/CocoaPods/Specs.git
codename1
.ios.release.certificatePassword=
codename1
.ios.debug.certificate=<MY_CERTIFICATE_IS_HERE>
libVersion
=127
codename1
.arg.android.xpermissions=<uses-permission android\:name\="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android\:name\="com.google.android.providers.gsf.permission.READ_GSERVICES"/><uses-feature         android\:glEsVersion\="0x00020000"         android\:required\="true"/>
android
.xapplication=<meta-data     android\:name\="com.google.android.maps.v2.API_KEY"     android\:value\="MY_API_KEY_IS_HERE"/>
codename1
.ios.debug.provision=<PATH REMOVED>

codename1
.rim.certificatePassword=
codename1
.version=1.0
codename1
.ios.certificate=
codename1
.icon=icon.png
codename1
.rim.signtoolCsk=
ios
.add_libs=libc++.dylib;libicucore.dylib;libz.dylib;CoreData.framework;CoreText.framework;GLKit.framework;ImageIO.framework;SystemConfiguration.framework
codename1
.rim.signtoolDb=



here is most of my UI code:
import com.codename1.googlemaps.MapContainer;
import com.codename1.maps.Coord;

import com.codename1.ui.*;


public class FrmHomes extends com.codename1.ui.Form {
 
   
public FrmHomes() {
       
this(com.codename1.ui.util.Resources.getGlobalResources());
   
}

   
   
public FrmHomes(com.codename1.ui.util.Resources resourceObjectInstance) {
        initGuiBuilderComponents
(resourceObjectInstance);
        initManualComponents
();
   
}
   
//-- DON'T EDIT BELOW THIS LINE!!!




// <editor-fold defaultstate="collapsed" desc="Generated Code">                          
   
private void initGuiBuilderComponents(com.codename1.ui.util.Resources resourceObjectInstance) {
        setLayout
(new com.codename1.ui.layouts.BorderLayout());
 
}// </editor-fold>



 
// -- DON'T EDIT ABOVE THIS LINE!!!
 
protected void initManualComponents() {
 
this.setScrollable(false);


 
final MapContainer cnt = new MapContainer();
       
this.addComponent(BorderLayout.CENTER, cnt);
       
this.addCommand(new Command("Move Camera") {
           
public void actionPerformed(ActionEvent ev) {
                cnt
.setCameraPosition(new Coord(-33.867, 151.206));
           
}
       
});
       
this.addCommand(new Command("Add Marker") {
 
public void actionPerformed(ActionEvent ev) {
 cnt
.setCameraPosition(new Coord(41.889, -87.622));
 
Image img = Resources.getGlobalResources().getImage("flag_red.png");
 cnt
.addMarker(EncodedImage.createFromImage(img, false), new Coord(41.889, -87.622), "Hi marker",
 
"Optional long description", new ActionListener() {
 
public void actionPerformed(ActionEvent evt) {
 
Dialog.show("Marker Clicked!", "You clicked the marker", "OK", null);
 
}
 
});
 
}
       
});
       
this.addCommand(new Command("Add Path") {
           
public void actionPerformed(ActionEvent ev) {
                cnt
.setCameraPosition(new Coord(-18.142, 178.431));
                cnt
.addPath(new Coord(-33.866, 151.195), // Sydney
                   
new Coord(-18.142, 178.431),  // Fiji
                   
new Coord(21.291, -157.821),  // Hawaii
                   
new Coord(37.423, -122.091)  // Mountain View
               
);
           
}
       
});
       
this.addCommand(new Command("Clear All") {
           
public void actionPerformed(ActionEvent ev) {
                cnt
.clearMapLayers();
           
}
       
});    
   
}


and here is the project showing the library is included:


Shai Almog

unread,
Sep 16, 2016, 1:34:00 AM9/16/16
to CodenameOne Discussions, howud...@gmail.com
It fallsback to OSM in case of an error loading the map. Check your keys, SHA1 etc.
If you connect the device to DDMS you can see Googles error message printed.

howud...@gmail.com

unread,
Sep 16, 2016, 10:22:59 AM9/16/16
to CodenameOne Discussions, howud...@gmail.com
The error I am getting is:
09-16 07:17:24.657: I/Google Maps Android API(30787): Google Play services client version: 6587000
09-16 07:17:24.660: I/Google Maps Android API(30787): Google Play services package version: 9452236
09-16 07:17:24.664: I/System.out(30787): Failed to initialize, google play services not installed: java.lang.RuntimeException: API key not found.  Check that <meta-data android:name="com.google.android.geo.API_KEY" android:value="your API key"/> is in the <application> element of AndroidManifest.xml
09-16 07:17:24.664: W/System.err(30787): java.lang.RuntimeException: API key not found.  Check that <meta-data android:name="com.google.android.geo.API_KEY" android:value="your API key"/> is in the <application> element of AndroidManifest.xml
09-16 07:17:24.664: W/System.err(30787): at maps.y.k.a(Unknown Source)
...

However I have the application key set in the properties.  
codename1.arg.android.xpermissions=<uses-permission android\:name\="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android\:name\="com.google.android.providers.gsf.permission.READ_GSERVICES"/><uses-feature         android\:glEsVersion\="0x00020000"         android\:required\="true"/>

android
.xapplication=<meta-data     android\:name\="com.google.android.geo.API_KEY"     android\:value\="AIzaSyCcdXXXXXXXXXXXXXXXXXXXXH0"/>



  1. How can I see the build log to make sure you are setting it correctly?  
  2. Why is it not working?
  3. according to this error, your blog / instructions are out of date.  It is no longer com.google.android.maps.v2.API_KEY

Shai Almog

unread,
Sep 17, 2016, 1:53:00 AM9/17/16
to CodenameOne Discussions, howud...@gmail.com
1. You can use include source and look at the code we generate.

2. I'm guessing you got stuff from the codenameone_settings.properties. Notice that the "android.xapplication" entry doesn't have the proper prefix.

Reply all
Reply to author
Forward
0 new messages