No se pueden mostrar mosaicos con osmdroid de CloudMade

I'm trying to make work osmdroid with CloudMade (or whatever) but I'm unable to show any tile only blank squares. The only thing I can see in Log cat is

Could not find method org.osmdroid.views.MapView.getScaleX, referenced from method org.osmdroid.views.overlay.SafeDrawOverlay.draw

unable to resolve virtual method 5572: Lorg/osmdroid/views/MapView;.getScaleX ()

AndroidManifest.xml

    <uses-sdk
        android:minSdkVersion="7"
        android:targetSdkVersion="17" />
<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_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
<meta-data android:name="CLOUDMADE_KEY" android:value="heremycorrectkeyfromcloudmade" />
        <activity
            android:name="com.example.testosm.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

actividad_principal.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <org.osmdroid.views.MapView
        android:id="@+id/mapTest"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />

</RelativeLayout>

MainActivity.java

package com.example.testosm;

import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.tileprovider.util.CloudmadeUtil;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapController;
import org.osmdroid.views.MapView;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);        
    CloudmadeUtil.retrieveCloudmadeKey(getApplicationContext());
    MapView mapView = (MapView) findViewById(R.id.mapTest);     
    mapView.setTileSource(TileSourceFactory.CLOUDMADESMALLTILES);
    mapView.setBuiltInZoomControls(true);
    MapController mMapController = mapView.getController();
    mMapController.setZoom(13);
    GeoPoint gPt = new GeoPoint(51500000, -150000);
    //Centre map near to Hyde Park Corner, London
    mMapController.setCenter(gPt);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

}

preguntado el 25 de mayo de 13 a las 19:05

1 Respuestas

I suspect your target SDK is too low. Osmdroid supports SDK 7, but if your device is higher then it will use api calls from the newer API. Target the latest SDK but keep your min SDK at 7.

contestado el 26 de mayo de 13 a las 01:05

Thanks for your help, I have tried to change manifest to <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="17" /> but the problem persists. - TlmaK0

Does the crash happen on phones with all APIs, or only early APIs? - Kurtzmarc

I test it with new and old apis emulator, and with one reald device with SDK 10. But I think that it doesn't crash, because the memory increase like it was loading the tiles. - TlmaK0

Please take a look at the osmdroid sample application which does not have this problem and find what is different between your app and the sample app. - Kurtzmarc

GOOGLE = ANDROID =! OPENMAPS - ciclista espacial

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.