Android : why does native_start fails in startNavigating() on Android 2.3.1 emulator?

I am using Android 2.3.1 project to get a current location using LocationManager.GPS_PROVIDER.

This is my code

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    LocationManager locManager = (LocationManager)this.getSystemService(Context.LOCATION_SERVICE);
    LocationListener locListener = new BTILocationListener();

    locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locListener);
}

public class BTILocationListener implements LocationListener {

    @Override
    public void onLocationChanged(Location loc) {
        Log.d("BTILocation", "Inside onLocationChanged() ---");

        if (loc != null) {
            double latitude = loc.getLatitude();
            double longitude = loc.getLongitude();

            String locationstr = "Latitude = " + latitude + " longitude = "  +longitude;

            Log.d("BTILocation", locationstr);



        }
    }

    @Override
    public void onProviderDisabled(String provider) {
        Toast.makeText(getApplicationContext(), "GPS Disabled", Toast.LENGTH_SHORT).show();
        Log.w("BTILocation", "GPS is Disabled");
    }

    @Override
    public void onProviderEnabled(String provider) {
        Toast.makeText(getApplicationContext(), "GPS Enabled", Toast.LENGTH_SHORT).show();
        Log.w("BTILocation", "GPS is Enabled");
    }

    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) {
        // TODO Auto-generated method stub

    }

}

The permission set I use -

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>

I use open telnet connection

telnet localhost 5544
geo fix 12 22

I see following errors on logcat -

E/GpsLocationProvider(   75): native_start failed in startNavigating()

The location object returned in onLocationChanged(location loc) is always null on 2.3.1.

The same code works fine in Android 2.1 and 4.0. Please please help me solve this issue, I have tried google search but I couldn't find the solution anywhere. Thanks! I don't have Google APIs compatible with Android API level 7, does anyone know how I can download it?

Answers


It seems that it's a known problem with platform 2.3 I downloaded Google APIs for platform 2.2 and 2.1 using android SDK manager. Just had to check obsolete checkbox to be able to download the required packages.


I got the same error with 4.4.2 in API level 17. This is sporadic though, not really clear what fixes the issue. I did reboot of emulator, system all the usual stuff, nothing helped.

But I opened another emulator and that fixed them both.


Need Your Help

Play audio in background by use BackgroundCapableMedia

windows-8 microsoft-metro windows-runtime

In the windows8 Developer preview we can use this code to play audio in background:

Using log4j on Google App Engine

java google-app-engine log4j

I need to use log4j in my application, but I don't know how I can get properties loaded. Deafult properties files says that I should put log4j.properties to /WEB-INF/classes/ folder, but in eclipse I