Search code examples
androidosmdroid

OSMdroid Caused by: java.lang.ClassNotFoundException: org.osmdroid.views.MapView


I try to use OSMdroid in one of my applictions, but i got this:

running on hardware device Android 4.0.3 (CM9)

log from logcat:

06-25 16:56:07.389: E/AndroidRuntime(17760): java.lang.RuntimeException: Unable to start activity ComponentInfo{app.OSMMapViewActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class org.osmdroid.views.MapView
06-25 16:56:07.389: E/AndroidRuntime(17760):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2079)
06-25 16:56:07.389: E/AndroidRuntime(17760):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2104)
06-25 16:56:07.389: E/AndroidRuntime(17760):    at android.app.ActivityThread.access$600(ActivityThread.java:132)
06-25 16:56:07.389: E/AndroidRuntime(17760):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1157)
06-25 16:56:07.389: E/AndroidRuntime(17760):    at android.os.Handler.dispatchMessage(Handler.java:99)
06-25 16:56:07.389: E/AndroidRuntime(17760):    at android.os.Looper.loop(Looper.java:137)
06-25 16:56:07.389: E/AndroidRuntime(17760):    at android.app.ActivityThread.main(ActivityThread.java:4575)
06-25 16:56:07.389: E/AndroidRuntime(17760):    at java.lang.reflect.Method.invokeNative(Native Method)
06-25 16:56:07.389: E/AndroidRuntime(17760):    at java.lang.reflect.Method.invoke(Method.java:511)
06-25 16:56:07.389: E/AndroidRuntime(17760):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
06-25 16:56:07.389: E/AndroidRuntime(17760):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
06-25 16:56:07.389: E/AndroidRuntime(17760):    at dalvik.system.NativeStart.main(Native Method)
06-25 16:56:07.389: E/AndroidRuntime(17760): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class org.osmdroid.views.MapView
06-25 16:56:07.389: E/AndroidRuntime(17760):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
06-25 16:56:07.389: E/AndroidRuntime(17760):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
06-25 16:56:07.389: E/AndroidRuntime(17760):    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
06-25 16:56:07.389: E/AndroidRuntime(17760):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
06-25 16:56:07.389: E/AndroidRuntime(17760):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
06-25 16:56:07.389: E/AndroidRuntime(17760):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
06-25 16:56:07.389: E/AndroidRuntime(17760):    at android.app.Activity.setContentView(Activity.java:1835)
06-25 16:56:07.389: E/AndroidRuntime(17760):    at app.OSMMapViewActivity.onCreate(OSMMapViewActivity.java:16)
06-25 16:56:07.389: E/AndroidRuntime(17760):    at android.app.Activity.performCreate(Activity.java:4465)
06-25 16:56:07.389: E/AndroidRuntime(17760):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
06-25 16:56:07.389: E/AndroidRuntime(17760):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2033)
06-25 16:56:07.389: E/AndroidRuntime(17760):    ... 11 more
06-25 16:56:07.389: E/AndroidRuntime(17760): Caused by: java.lang.ClassNotFoundException: org.osmdroid.views.MapView
06-25 16:56:07.389: E/AndroidRuntime(17760):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
06-25 16:56:07.389: E/AndroidRuntime(17760):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-25 16:56:07.389: E/AndroidRuntime(17760):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-25 16:56:07.389: E/AndroidRuntime(17760):    at android.view.LayoutInflater.createView(LayoutInflater.java:552)
06-25 16:56:07.389: E/AndroidRuntime(17760):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
06-25 16:56:07.389: E/AndroidRuntime(17760):    ... 21 more

i hope this will help you more.

mapscreen.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <org.osmdroid.views.MapView
        android:id="@+id/mapview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:clickable="true" />

</LinearLayout>

this is my activity:

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

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

public class OSMMapViewActivity extends Activity{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mapscreen);

        MapView mMapView = (MapView) findViewById(R.id.mapview);
        mMapView.setTileSource(TileSourceFactory.MAPNIK);
        mMapView.setBuiltInZoomControls(true);
        MapController mMapController = mMapView.getController();
        mMapController.setZoom(13);
        GeoPoint gPt = new GeoPoint(51500000, -150000);
        //Centre map near to Hyde Park Corner, London
        mMapController.setCenter(gPt);
    }

}

i'm using OSMDroid 3.0.8 and slf4j-1.5.8 and eclipse.

EDIT:

I commented out the setContentView() and the other code. I think the problem is something eith the layout files...

EDIT1:

The Problem is solved... :)

copy osmdroid and the other jars from libs/osmdroid to libs/ ^_^

Thanks for help anyway!!!!

Thx for helping


Solution

  • The problem is that eclipse need a restart, to load external libraries correct.

    Thanks for all your help!!!