XML Error

104 views
Skip to first unread message

Ruben Ferradás

unread,
Jun 5, 2013, 11:48:35 AM6/5/13
to mapsfo...@googlegroups.com
Hello, i jave an exception when i try to open the map view, here is my code:
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;

import org.mapsforge.android.maps.MapController;
import org.mapsforge.android.maps.MapView;

import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.app.Activity;
import android.content.res.AssetManager;

public class MainActivity extends Activity {


protected static MapView myOpenMapView;
private MapController mapController;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try{
    setContentView(R.layout.activity_main);      //THE PROBLEM IS THIS LINE
}
catch (Exception e){Log.i("----->", e.getMessage());}
AssetManager am = getAssets();
          myOpenMapView = (MapView)findViewById(R.id.openmapview);
        
        
        String filepath = Environment.getExternalStorageDirectory().getPath() + "/mapas/spain.map";
        myOpenMapView.setMapFile(new File(filepath));
        setContentView(myOpenMapView);  
        mapController = myOpenMapView.getController();
        mapController.setZoom(4);
}
}


In the XML file i only have the Mapview, the exception is: 

Binary XML file line #11: Error inflating class org.mapsforge.android.maps.MapView

Somebody knows how to fix it? thank you.

PD: sorry for my english;

Thilo Mühlberg

unread,
Jun 5, 2013, 12:17:28 PM6/5/13
to mapsfo...@googlegroups.com

Unless you provide the complete stack trace we will be unable to help you I am afraid.

Greetings,
Thilo

--
You received this message because you are subscribed to the Google Groups "mapsforge-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapsforge-de...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ruben Ferradás

unread,
Jun 5, 2013, 12:24:04 PM6/5/13
to mapsfo...@googlegroups.com
06-05 18:21:56.241: W/System.err(19632): android.view.InflateException: Binary XML file line #11: Error inflating class org.mapsforge.android.maps.MapView
06-05 18:21:56.246: W/System.err(19632): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:698)
06-05 18:21:56.246: W/System.err(19632): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
06-05 18:21:56.246: W/System.err(19632): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
06-05 18:21:56.246: W/System.err(19632): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
06-05 18:21:56.246: W/System.err(19632): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
06-05 18:21:56.246: W/System.err(19632): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:308)
06-05 18:21:56.246: W/System.err(19632): at android.app.Activity.setContentView(Activity.java:1924)
06-05 18:21:56.246: W/System.err(19632): at com.example.pruebaoffline.MainActivity.onCreate(MainActivity.java:26)
06-05 18:21:56.246: W/System.err(19632): at android.app.Activity.performCreate(Activity.java:5206)
06-05 18:21:56.246: W/System.err(19632): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
06-05 18:21:56.251: W/System.err(19632): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
06-05 18:21:56.251: W/System.err(19632): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
06-05 18:21:56.251: W/System.err(19632): at android.app.ActivityThread.access$600(ActivityThread.java:140)
06-05 18:21:56.251: W/System.err(19632): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
06-05 18:21:56.251: W/System.err(19632): at android.os.Handler.dispatchMessage(Handler.java:99)
06-05 18:21:56.251: W/System.err(19632): at android.os.Looper.loop(Looper.java:137)
06-05 18:21:56.251: W/System.err(19632): at android.app.ActivityThread.main(ActivityThread.java:4898)
06-05 18:21:56.251: W/System.err(19632): at java.lang.reflect.Method.invokeNative(Native Method)
06-05 18:21:56.251: W/System.err(19632): at java.lang.reflect.Method.invoke(Method.java:511)
06-05 18:21:56.251: W/System.err(19632): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
06-05 18:21:56.251: W/System.err(19632): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
06-05 18:21:56.251: W/System.err(19632): at dalvik.system.NativeStart.main(Native Method)
06-05 18:21:56.251: W/System.err(19632): Caused by: java.lang.ClassNotFoundException: org.mapsforge.android.maps.MapView
06-05 18:21:56.251: W/System.err(19632): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
06-05 18:21:56.251: W/System.err(19632): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-05 18:21:56.251: W/System.err(19632): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-05 18:21:56.251: W/System.err(19632): at android.view.LayoutInflater.createView(LayoutInflater.java:552)
06-05 18:21:56.251: W/System.err(19632): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
06-05 18:21:56.251: W/System.err(19632): ... 21 more

Ruben Ferradás

unread,
Jun 5, 2013, 12:24:41 PM6/5/13
to mapsfo...@googlegroups.com
there it is. thanks

Ludwig

unread,
Jun 5, 2013, 9:04:53 PM6/5/13
to mapsfo...@googlegroups.com
You always need to read down the stack to the line where it says "Caused by:"

In your case it is 
java.lang.ClassNotFoundException: org.mapsforge.android.maps.MapView

This is a build error that has been discussed here a few times: the mapsforge library is compiled against, but not linked into your apk.

I do not know how you build your apks, but if you are using eclipse you will need to adjust the .classpath file and add exported="true" to the line where you link in the mapsforge library. If you are using maven, you might have a <provided>true</provided> setting for the mapsforge library.

HTH

Ludwig




On 6 June 2013 00:24, Ruben Ferradás <mone...@gmail.com> wrote:
there it is. thanks

Ruben Ferradás

unread,
Jun 6, 2013, 7:26:50 AM6/6/13
to mapsfo...@googlegroups.com
my casspath looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

can i add this line?: 

<classpathentry exported="true" kind="con" path="libs/mapsforge-map-0.3.0-jar-with-dependencies.jar"/>

Ludwig

unread,
Jun 6, 2013, 7:55:22 AM6/6/13
to mapsfo...@googlegroups.com
I think type is lib:
   
<classpathentry exported="true" kind="lib" path="libs/mapsforge-map-0.3.0-jar-with-dependencies.jar""/>


Ruben Ferradás

unread,
Jun 6, 2013, 9:27:45 AM6/6/13
to mapsfo...@googlegroups.com
still doesnt work. any other option to probe? Thank you.

Reply all
Reply to author
Forward
0 new messages