Hello, I am trying to get the ti.map module working on Android physical device; I followed these guides step by step but still not getting the map working.
Titanium SDK is 3.3.0.GA, OS X 10.9.8, Titanium Studio
http://docs.appcelerator.com/titanium/latest/#!/api/Modules.Map http://docs.appcelerator.com/titanium/latest/#!/guide/Google_Maps_v2_for_Android
The keystore/key I registered on Google API Console is the default one installed with Titanium Studio.
I also found many different forum topics opened on a similar issue but none of them was good for me and to be honest it is pretty chaotic: some say you need to refer some .jar library in your project/libs (such as android-support-v4.jar) some other suggest to copy the content of <android-sdk>/extras/google/google_play_services/libproject/google-play-services_lib/ in the Root directory of your project. But none of these steps is mentioned in the official documentation; I tried to perform them anyway but with no success.
The first error I get in the console is:
GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.I hereby attach my controller index.js, view index.xml and manifest tiapp.xml: Moreover when the Map.isGooglePlayServicesAvailable(); is invoked the result is SUCCESS
What I see on the device is the module loaded with control buttons and the blank canvas of the map.
Please help me! What else do I need to link or modify to get it work?
Console Log:
Titanium Command-Line Interface, CLI version 3.3.0, Titanium SDK version 3.3.0.GA Copyright (c) 2012-2014, Appcelerator, Inc. All Rights Reserved. /* ******* I removed the beginning of the log because it was too long ********** */ -- Start application log ----------------------------------------------------- [INFO] : Forwarding host port 61864 to device for debugging [INFO] : Project built successfully in 3m 21s 389ms [INFO] : dalvikvm: Could not find method android.app.Application.onTrimMemory, referenced from method org.appcelerator.titanium.TiApplication.onTrimMemory [WARN] : dalvikvm: VFY: unable to resolve virtual method 204: Landroid/app/Application;.onTrimMemory (I)V [INFO] : TiApplication: (main) [0,0] checkpoint, app created. [INFO] : TiApplication: (main) [883,883] Titanium 3.3.0 (2014/07/11 12:36 787cd39) [INFO] : DatabaseHelper: No value in database for platform key: 'unique_machine_id' returning supplied default '' [INFO] : DatabaseHelper: No value in database for platform key: 'hardware_machine_id' returning supplied default '' [INFO] : TiApplication: (main) [2258,3141] Titanium Javascript runtime: v8 [INFO] : TiRootActivity: (main) [0,0] checkpoint, on root activity create, savedInstanceState: null [WARN] : V8Object: Runtime disposed, cannot set property 'userAgent' [INFO] : dalvikvm: Total arena pages for JIT: 11 ... /*omissis similar warnings*/ ... [WARN] : dalvikvm: VFY: unable to resolve static field 3281 (common_google_play_services_unsupported_title) in Lcom/google/android/gms/R$string; [WARN] : dalvikvm: VFY: unable to resolve static field 3270 (common_google_play_services_install_button) in Lcom/google/android/gms/R$string; [WARN] : dalvikvm: VFY: unable to resolve static field 3267 (common_google_play_services_enable_button) in Lcom/google/android/gms/R$string; [WARN] : dalvikvm: VFY: unable to resolve static field 3282 (common_google_play_services_update_button) in Lcom/google/android/gms/R$string; [WARN] : dalvikvm: VFY: unable to resolve static field 3278 (common_google_play_services_unknown_issue) in Lcom/google/android/gms/R$string; [WARN] : dalvikvm: VFY: unable to resolve static field 3272 (common_google_play_services_install_text_tablet) in Lcom/google/android/gms/R$string; [WARN] : dalvikvm: VFY: unable to resolve static field 3271 (common_google_play_services_install_text_phone) in Lcom/google/android/gms/R$string; [WARN] : dalvikvm: VFY: unable to resolve static field 3268 (common_google_play_services_enable_text) in Lcom/google/android/gms/R$string; [WARN] : dalvikvm: VFY: unable to resolve static field 3283 (common_google_play_services_update_text) in Lcom/google/android/gms/R$string; [WARN] : dalvikvm: VFY: unable to resolve static field 3280 (common_google_play_services_unsupported_text) in Lcom/google/android/gms/R$string; [WARN] : dalvikvm: VFY: unable to resolve static field 3276 (common_google_play_services_network_error_text) in Lcom/google/android/gms/R$string; [WARN] : dalvikvm: VFY: unable to resolve static field 3274 (common_google_play_services_invalid_account_text) in Lcom/google/android/gms/R$string; [WARN] : dalvikvm: VFY: unable to resolve static field 3279 (common_google_play_services_unsupported_date_text) in Lcom/google/android/gms/R$string; [WARN] : dalvikvm: VFY: unable to resolve instance field 49 [WARN] : dalvikvm: VFY: unable to resolve static field 3278 (common_google_play_services_unknown_issue) in Lcom/google/android/gms/R$string; [ERROR] : GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included. [INFO] : ALERT: (KrollRuntimeThread) [4938,4938] Google Play services is installed. [INFO] : dalvikvm: threadid=4: reacting to signal 3 [INFO] : dalvikvm: Wrote stack traces to '/data/anr/traces.txt' [INFO] : TiRootActivity: (main) [0,0] checkpoint, on root activity resume. activity = com.special.workway.TestActivity@4059d5c8 /* some more log I could not include because too long*/index.xml
<Alloy> </Alloy>index.js
var Map = require('ti.map'); var rc = Map.isGooglePlayServicesAvailable(); switch (rc) { case Map.SUCCESS: alert('Google Play services is installed.'); break; case Map.SERVICE_MISSING: alert('Google Play services is missing. Please install Google Play services from the Google Play store.'); break; case Map.SERVICE_VERSION_UPDATE_REQUIRED: alert('Google Play services is out of date. Please update Google Play services.'); break; case Map.SERVICE_DISABLED: alert('Google Play services is disabled. Please enable Google Play services.'); break; case Map.SERVICE_INVALID: alert('Google Play services cannot be authenticated. Reinstall Google Play services.'); break; default: alert('Unknown error.'); break; } var win = Titanium.UI.createWindow(); var mountainView = Map.createAnnotation({ latitude:37.390749, longitude:-122.081651, title:"Appcelerator Headquarters", subtitle:'Mountain View, CA', pincolor:Map.ANNOTATION_RED, myid:1 // Custom property to uniquely identify this annotation. }); var mapview = Map.createView({ mapType: Map.NORMAL_TYPE, region: {latitude:33.74511, longitude:-84.38993, latitudeDelta:0.01, longitudeDelta:0.01}, animate:true, regionFit:true, userLocation:true, annotations:[mountainView] }); win.add(mapview); // Handle click events on any annotations on this map. mapview.addEventListener('click', function(evt) { Ti.API.info("Annotation " + evt.title + " clicked, id: " + evt.annotation.myid); }); win.open();tiapp.xml
<?xml version="1.0" encoding="UTF-8"?> <ti:app xmlns:ti="http://ti.appcelerator.org"> <id>com.special.workway</id> <name>Test</name> <version>1.0</version> <publisher>Luca</publisher> <url>http://</url> <description>not specified</description> <copyright>2014 by Luca</copyright> <icon>appicon.png</icon> <fullscreen>false</fullscreen> <navbar-hidden>false</navbar-hidden> <analytics>true</analytics> <guid>975f6416-6222-422d-affe-61883ada1ad0</guid> <property name="ti.ui.defaultunit" type="string">dp</property> <ios> <plist> <dict> <key>UISupportedInterfaceOrientations~iphone</key> <array> <string>UIInterfaceOrientationPortrait</string> </array> <key>UISupportedInterfaceOrientations~ipad</key> <array> <string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationPortraitUpsideDown</string> <string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeRight</string> </array> <key>UIRequiresPersistentWiFi</key> <false/> <key>UIPrerenderedIcon</key> <false/> <key>UIStatusBarHidden</key> <false/> <key>UIStatusBarStyle</key> <string>UIStatusBarStyleDefault</string> </dict> </plist> </ios> <android xmlns:android="http://schemas.android.com/apk/res/android"> <manifest> <!-- Allows the API to download data from Google Map servers --> <uses-permission android:name="android.permission.INTERNET"/> <!-- Allows the API to cache data --> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <!-- Use GPS for device location --> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <!-- Use Wi-Fi or mobile connection for device location --> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <!-- Allows the API to access Google web-based services --> <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/> <!-- Specify OpenGL ES 2.0 as a requirement --> <uses-feature android:glEsVersion="0x00020000" android:required="true"/> <!-- Replace com.domain.appid with your application ID --> <uses-permission android:name="com.special.workway.permission.MAPS_RECEIVE"/> <permission android:name="com.special.workway.permission.MAPS_RECEIVE" android:protectionLevel="signature"/> <application> <!-- Replace "PASTE YOUR GOOGLE MAPS API KEY HERE" with the Google API key you obtained --> <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyD27Z75MSXWPEffuVVY3bhhkFwzso58V_o"/> </application> </manifest> </android> <mobileweb> <precache/> <splash> <enabled>true</enabled> <inline-css-images>true</inline-css-images> </splash> <theme>default</theme> </mobileweb> <modules> <module platform="iphone">ti.map</module> <module platform="android">ti.map</module> </modules> <deployment-targets> <target device="android">true</target> <target device="blackberry">false</target> <target device="ipad">false</target> <target device="iphone">true</target> <target device="mobileweb">true</target> <target device="tizen">false</target> </deployment-targets> <sdk-version>3.3.0.GA</sdk-version> <plugins> <plugin version="1.0">ti.alloy</plugin> </plugins> </ti:app>