5
votes

I'm using Titanium SDK 1.5.1 for both iPhone and Android development. I have an app that loads a map with my current position perfectly on iPhone. But, for android, nothing is showing but an error from the Geolocation API.

I added my Android Map API key and other properties in the tiapp.xml file:

<property name="ti.android.debug" type="bool">false</property>
    <property name="ti.android.google.map.api.key.development">xxxxxxxxxxxxxxxxxxx</property>
    <android xmlns:android="http://schemas.android.com/apk/res/android">
            <uses-permission android:name="android.permission.INTERNET"/>
            <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
            <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
            <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
            <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
            <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
            <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/>
    </android>

Then, in my js file, I added the two lines:

Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST;
Titanium.Geolocation.distanceFilter = 10;

And, for the call, here is the code:

Titanium.Geolocation.getCurrentPosition(function(e){

    if (e.error)
    {
        alert('Error while retrieving your position!');
        return;
    }
var longitude = e.coords.longitude;
var latitude = e.coords.latitude;
....

On my device, the app returns the alert above even if I allow Android to access to my position (in Android Settings).

So what is the problem?

Thanks by advance!

1
This one seems to be a bug in Titanium 1.5.1. I've seen support requests regarding this topic. Try to use the nightly builds: builds.appcelerator.com.s3.amazonaws.com/index.htmlFa11enAngel
You are right. I used that the 1.6.0 nightly build and ran the app on my device: Worked perfectly. Will you mind if you posted your comment as an answer so that I can mark it as the best answer?Zakaria

1 Answers

2
votes

Quoting @Fa11enAngel J

This one seems to be a bug in Titanium 1.5.1.

I've seen support requests regarding this topic.

Try to use the nightly builds: Appcelerator Continuous Builds