how to add more than 1 map file in mapsforge projects?

476 views
Skip to first unread message

sarahave...@gmail.com

unread,
Feb 25, 2015, 7:36:33 AM2/25/15
to mapsfo...@googlegroups.com
I was trying to use The MultiMapDataStore but seems like thats not exist in mapsforge-map-reader-0.5.0.jar lib and for some reason i cant compile mapsforge resources.

how can i add more than 1 map file or use that MultiMapDataStorein in eclipse?

Emux

unread,
Feb 25, 2015, 7:43:16 AM2/25/15
to
The multiple maps feature was introduced after the 0.5 release.
So you need newer jars.

Besides Wiki you can check also the relative example in Samples.

--
Emux
Cruiser - Atlas

sarahave...@gmail.com

unread,
Feb 25, 2015, 9:48:18 AM2/25/15
to mapsfo...@googlegroups.com
after adding those new jars, 2 new errors appeared :

        // tile renderer layer using internal render theme
       
this.tileRendererLayer = new TileRendererLayer(tileCache,
               
this.mapView.getModel().mapViewPosition, false, true, AndroidGraphicFactory.INSTANCE);
        c
.setMapFile(getMapFile());

1. The constructor TileRendererLayer(T
ileCache,MapViewPosition,boolean,boolean,AndroidGraphicFactory) is undefined
2. the method setMapFile(File) is undefined for type
TileRendererLayer

can u help me plz?

Ludwig

unread,
Feb 25, 2015, 9:52:10 AM2/25/15
to mapsfo...@googlegroups.com
That interface has changed slightly, best to have a look at the Samples app how it is done there. 

We have just released mapsforge 0.5.1-rc1, the first release candidate for version 0.5.1. You can find the binaries here: http://ci.mapsforge.org/job/0.5.1-rc1/ 
That would be the best for moving your app forward. 



--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/mapsforge-dev/e0bf2c0f-27f4-4165-8e54-81a07fdbb0bd%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

sarahave...@gmail.com

unread,
Feb 26, 2015, 3:11:27 AM2/26/15
to mapsfo...@googlegroups.com
Please update Getting-Started-Android-App.md  for that new interface , im so confused with importing samples app sources in my application.


Emux

unread,
Feb 26, 2015, 3:28:41 AM2/26/15
to mapsfo...@googlegroups.com
Sorry about that,
I just updated the Getting-Started-Android-App wiki to use the new interface.

sarahave...@gmail.com

unread,
Feb 26, 2015, 7:23:26 AM2/26/15
to mapsfo...@googlegroups.com
something is wrong and i cant find it , since i replaced my old 0.5.0 jars with new 0.5.1-rc1 jars i get some errors like : "Could not find class 'org.mapsforge.map.layer.overlay.Marker[]" referenced from method blah.blah.activity<clinit>.

sarahave...@gmail.com

unread,
Feb 26, 2015, 8:17:32 AM2/26/15
to mapsfo...@googlegroups.com


On Thursday, February 26, 2015 at 3:53:26 PM UTC+3:30, sarahave...@gmail.com wrote:
something is wrong and i cant find it , since i replaced my old 0.5.0 jars with new 0.5.1-rc1 jars i get some errors like : "Could not find class 'org.mapsforge.map.layer.overlay.Marker[]" referenced from method blah.blah.activity<clinit>.

Im sure i added libs right in my project ,i changed things in my buildpath too but still i get this errors,it was working fine before i add new version.
 plz help me .

Ludwig

unread,
Feb 26, 2015, 8:29:58 AM2/26/15
to mapsfo...@googlegroups.com
Can you just paste the entire message? 

--
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.

sarahave...@gmail.com

unread,
Feb 26, 2015, 8:43:50 AM2/26/15
to mapsfo...@googlegroups.com
sure


02-27 17:06:05.078: E/AndroidRuntime(31642): FATAL EXCEPTION: main
02-27 17:06:05.078: E/AndroidRuntime(31642): Process: com.vis.bigmap, PID: 31642
02-27 17:06:05.078: E/AndroidRuntime(31642): java.lang.NoClassDefFoundError: org.mapsforge.map.layer.overlay.Marker[]
02-27 17:06:05.078: E/AndroidRuntime(31642):     at com.vis.bigmap.bigActivity.<clinit>(bigActivity.java:31)
02-27 17:06:05.078: E/AndroidRuntime(31642):     at java.lang.Class.newInstanceImpl(Native Method)
02-27 17:06:05.078: E/AndroidRuntime(31642):     at java.lang.Class.newInstance(Class.java:1208)
02-27 17:06:05.078: E/AndroidRuntime(31642):     at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
02-27 17:06:05.078: E/AndroidRuntime(31642):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2154)
02-27 17:06:05.078: E/AndroidRuntime(31642):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2286)
02-27 17:06:05.078: E/AndroidRuntime(31642):     at android.app.ActivityThread.access$800(ActivityThread.java:144)
02-27 17:06:05.078: E/AndroidRuntime(31642):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1246)
02-27 17:06:05.078: E/AndroidRuntime(31642):     at android.os.Handler.dispatchMessage(Handler.java:102)
02-27 17:06:05.078: E/AndroidRuntime(31642):     at android.os.Looper.loop(Looper.java:212)
02-27 17:06:05.078: E/AndroidRuntime(31642):     at android.app.ActivityThread.main(ActivityThread.java:5137)
02-27 17:06:05.078: E/AndroidRuntime(31642):     at java.lang.reflect.Method.invokeNative(Native Method)
02-27 17:06:05.078: E/AndroidRuntime(31642):     at java.lang.reflect.Method.invoke(Method.java:515)
02-27 17:06:05.078: E/AndroidRuntime(31642):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902)
02-27 17:06:05.078: E/AndroidRuntime(31642):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:718)
02-27 17:06:05.078: E/AndroidRuntime(31642):     at dalvik.system.NativeStart.main(Native Method)


Thank you for help.

Ludwig

unread,
Feb 26, 2015, 8:53:03 AM2/26/15
to mapsfo...@googlegroups.com
The Marker class is certainly part of the mapsforge-map 0.5.1-rc1 jar and I find it a bit strange that that is the first missing class your app complains about. The path or packaging of this part has also not changed. 

why does it say 'java.lang.NoClassDefFoundError: org.mapsforge.map.layer.overlay.Marker[]' with [] at the end? 

Ludwig




--
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.

Emux

unread,
Feb 26, 2015, 8:55:08 AM2/26/15
to mapsfo...@googlegroups.com
Probably an array?

Maybe with the replace of jars, the IDE is not yet aware of the new ones?
A project refresh or something similar could help.

Ludwig

unread,
Feb 26, 2015, 8:56:18 AM2/26/15
to mapsfo...@googlegroups.com
Yes, obviously an array, but we do not have/export that. It seems to me more a part of his code.


--
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.

sarahave...@gmail.com

unread,
Feb 26, 2015, 8:57:10 AM2/26/15
to mapsfo...@googlegroups.com


On Thursday, February 26, 2015 at 5:23:03 PM UTC+3:30, Ludwig wrote:
The Marker class is certainly part of the mapsforge-map 0.5.1-rc1 jar and I find it a bit strange that that is the first missing class your app complains about. The path or packaging of this part has also not changed. 

why does it say 'java.lang.NoClassDefFoundError: org.mapsforge.map.layer.overlay.Marker[]' with [] at the end? 

Ludwig


maybe because of this :

Marker[] marker_red = new Marker[6];

i have same issue about LatLong too:

LatLong[] bigLatlng = new LatLong[5];

this 2 arrays was working fine in 0.5.0.
 
 
Message has been deleted

sarahave...@gmail.com

unread,
Feb 26, 2015, 9:25:10 AM2/26/15
to mapsfo...@googlegroups.com
import java.io.File;

import org.mapsforge.core.model.LatLong;
import org.mapsforge.map.android.graphics.AndroidGraphicFactory;
import org.mapsforge.map.android.graphics.AndroidResourceBitmap;
import org.mapsforge.map.android.util.AndroidUtil;
import org.mapsforge.map.android.view.MapView;
import org.mapsforge.map.layer.cache.TileCache;
import org.mapsforge.map.layer.overlay.Marker;
import org.mapsforge.map.layer.renderer.TileRendererLayer;
import org.mapsforge.map.reader.MapDataStore;
import org.mapsforge.map.reader.MapFile;
import org.mapsforge.map.reader.MultiMapDataStore;
import org.mapsforge.map.rendertheme.InternalRenderTheme;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
   
public class bigActivity extends Activity {
    static Marker[] marker_red = new Marker[6];
    static Marker[] marker_blue = new Marker[6];
    static Marker marker_green;
    static LatLong[] blatlng = new LatLong[5];
    static LatLong[] mlatlng = new LatLong[5];
    // name of the map file in the external storage
    private static final String IMAPFILE = "Germany.map";
    private MultiMapDataStore multiMapDataStore;
       
    static MapView mapView;   
    private TileCache tileCache;
    private TileRendererLayer tileRendererLayer;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        AndroidGraphicFactory.createInstance(this.getApplication());
   
        mapView = new MapView(this);
        setContentView(mapView);

        mapView.setClickable(true);
        mapView.getMapScaleBar().setVisible(true);
        mapView.setBuiltInZoomControls(true);
        mapView.getMapZoomControls().setZoomLevelMin((byte) 2);
        mapView.getMapZoomControls().setZoomLevelMax((byte) 22);
   
        this.tileCache = AndroidUtil.createTileCache(this, "mapcache",
                mapView.getModel().displayModel.getTileSize(), 1f,
                mapView.getModel().frameBufferModel.getOverdrawFactor());
 }
   
    @Override
    protected void onStart() {
        super.onStart();
        try{           
            mapView.getModel().mapViewPosition.setCenter(new LatLong(51.111111, 14.111111));
            mapView.getModel().mapViewPosition.setZoomLevel((byte) 12);

            multiMapDataStore = new MultiMapDataStore(MultiMapDataStore.DataPolicy.RETURN_ALL);
            multiMapDataStore.addMapDataStore(getMapFile1(), true, true);
            multiMapDataStore.addMapDataStore(getMapFile2(), false, false);

           
            //     tile renderer layer using internal render theme
            this.tileRendererLayer = new TileRendererLayer(tileCache,getMapFile(),
                    this.mapView.getModel().mapViewPosition, false, true, AndroidGraphicFactory.INSTANCE);

            tileRendererLayer.setXmlRenderTheme(InternalRenderTheme.OSMARENDER);
           
            mapView.getLayerManager().getLayers().add(tileRendererLayer);

            marker_red[1] = Utils.createMarker(this,R.drawable.marker_red1t,null);
            marker_red[2] = Utils.createMarker(this,R.drawable.marker_red2t,null);
            marker_red[3] = Utils.createMarker(this,R.drawable.marker_red3t,null);
            marker_red[4] = Utils.createMarker(this,R.drawable.marker_red4t,null);
            marker_red[5] = Utils.createMarker(this,R.drawable.marker_red1,null);
           
            marker_blue[1] = Utils.createMarker(this,R.drawable.marker_blue1t,null);
            marker_blue[2] = Utils.createMarker(this,R.drawable.marker_blue2t,null);
            marker_blue[3] = Utils.createMarker(this,R.drawable.marker_blue3t,null);
            marker_blue[4] = Utils.createMarker(this,R.drawable.marker_blue4t,null);
            marker_blue[5] = Utils.createMarker(this,R.drawable.marker_blue1,null);
           
            marker_green = Utils.createMarker(this,R.drawable.marker_green_c,null);

            marker[1].setLatLong(new LatLong(51.111111, 14.111111));
            //mapView.getLayerManager().getLayers().remove(marker[1]);
 
            SharedPreferences disk = getSharedPreferences("comcom",Context.MODE_PRIVATE);
 
            double lat = Double.longBitsToDouble(disk.
getLong("blat",0));
            if(lat!=0){
                double lng = Double.longBitsToDouble(disk.getLong("blng",0));
                mapView.getLayerManager().getLayers().add(bigActivity.marker_red[5]);
                marker_red[5].setLatLong(new LatLong(lat, lng));
            }
            lat = Double.longBitsToDouble(disk.getLong("mlat",0));
            if(lat!=0){
                double lng = Double.longBitsToDouble(disk.getLong("mlng",0));
                mapView.getLayerManager().getLayers().add(bigActivity.marker_blue[5]);
                marker_blue[5].setLatLong(new LatLong(lat, lng));
            }
           
        }catch(Exception e){
            Log.v("bigTAg",String.valueOf(e));
        }
    }
       
    @Override
    protected void onStop() {
        super.onStop();
        mapView.getLayerManager().getLayers().remove(this.tileRendererLayer);
        this.tileRendererLayer.onDestroy();
    }
       
    @Override
    protected void onDestroy() {
        super.onDestroy();
        this.tileCache.destroy();
        mapView.getModel().mapViewPosition.destroy();
        mapView.destroy();
        AndroidResourceBitmap.clearResourceBitmaps();
    }
    public MapDataStore getMapFile() {
        return this.multiMapDataStore;
    }
    protected MapDataStore getMapFile1() {
        File file= new File(context.getExternalFilesDir("MAPS"), IMAPFILE);
        return new MapFile(file);
    }
    protected MapDataStore getMapFile2() {
        File file = new File(context.getExternalFilesDir("MAPS"),"world.map");
        return new MapFile(file);
    }
       
}



here is part of my code 
 

Emux

unread,
Feb 26, 2015, 9:29:11 AM2/26/15
to mapsfo...@googlegroups.com
What IDE are you using?
Something seems to go wrong with the classpath.

Maybe trying to re-download the jars?

Message has been deleted

sarahave...@gmail.com

unread,
Feb 26, 2015, 9:53:39 AM2/26/15
to mapsfo...@googlegroups.com
Im using Eclipse, i just downloaded all jars again and still have those errors.

Ludwig

unread,
Feb 26, 2015, 10:12:27 AM2/26/15
to mapsfo...@googlegroups.com
I have the feeling this is the usual export problem again, eclipse seems funny when you adjust the jars as the build config files get regenerated and I remember that it used to drop the export declaration. 

As Emux suggested, can you check your .classpath file on the top level of your project?



--
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.

sarahave...@gmail.com

unread,
Feb 26, 2015, 10:20:00 AM2/26/15
to mapsfo...@googlegroups.com
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
    <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
    <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
    <classpathentry kind="lib" path="libs/mapsforge-core-0.5.1-rc1.jar"/>
    <classpathentry kind="lib" path="libs/mapsforge-map-0.5.1-rc1.jar"/>
    <classpathentry kind="lib" path="libs/mapsforge-map-android-0.5.1-rc1.jar"/>
    <classpathentry kind="lib" path="libs/mapsforge-map-awt-0.5.1-rc1.jar"/>
    <classpathentry kind="lib" path="libs/mapsforge-map-reader-0.5.1-rc1.jar"/>
    <classpathentry kind="lib" path="libs/SwingMapViewer-0.5.1-rc1.jar"/>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="src" path="gen"/>
    <classpathentry kind="output" path="bin/classes"/>
</classpath>

its my .classpath file.

Ludwig

unread,
Feb 26, 2015, 10:21:36 AM2/26/15
to mapsfo...@googlegroups.com
You need the export keyword on all the mapsforge jars... similar to this:

<classpathentry exported="true" kind="lib" path="lib/mapsforge-core-0.5.0.jar"/>



Message has been deleted

sarahave...@gmail.com

unread,
Feb 26, 2015, 10:46:49 AM2/26/15
to mapsfo...@googlegroups.com
I changed my .classpath now this errors are happened.

 
[2015-02-27 18:09:17 - Dex Loader] Unable to execute dex: Multiple dex files define Lorg/mapsforge/map/reader/Deserializer;
[2015-02-27 18:09:17 - bigMap] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lorg/mapsforge/map/reader/Deserializer;

sarahave...@gmail.com

unread,
Feb 26, 2015, 11:31:55 AM2/26/15
to mapsfo...@googlegroups.com
I unselected  "Android Privet Libraries" from Build Path > Order and Export and cleaned my project but didnt fix my problem.
also i removed everything in Bin folder and restarted eclipse this didnt fixed my problem too.
tried many similar things, im wonder why i didnt have this issues with 0.5.0 jars.

Ludwig

unread,
Feb 26, 2015, 11:35:00 AM2/26/15
to mapsfo...@googlegroups.com

Can you see the differences with version control?

--
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.

sarahave...@gmail.com

unread,
Feb 26, 2015, 11:42:46 AM2/26/15
to mapsfo...@googlegroups.com
No, how can i do that?

sarahave...@gmail.com

unread,
Feb 26, 2015, 11:52:57 AM2/26/15
to mapsfo...@googlegroups.com
Do you know why this errors happened?

Emux

unread,
Feb 26, 2015, 12:13:33 PM2/26/15
to mapsfo...@googlegroups.com
I never had to play with other settings like order or export.
I simply put the jars in libs folder in all IDEs (Eclipse, Idea, AS) and they parse it fine.

i.e. in .classpath there isn't any lib jar definition

I suggest to follow this way and try with a new clean Android project.

sarahave...@gmail.com

unread,
Feb 28, 2015, 5:46:59 AM2/28/15
to mapsfo...@googlegroups.com
its almost 3 days that im working on what you suggested me . i tried sooooo many defrent things but here i start from step 1 again maybe you guys can help me with this really annoying issues step by step...
I created a clean android project and it worked fine on my tablet without adding any extra jar files, then i just copied jar files into my project lib folder






















after this step i restarted eclipse then i refreshed my project and i run it . in console this error happened:

[2015-03-01 13:57:25 - Dex Loader] Unable to execute dex: Multiple dex files define Lorg/mapsforge/core/graphics/Align;
[2015-03-01 13:57:25 - Basir] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lorg/mapsforge/core/graphics/Align;
 












Now what should i do ?
I googled so many answers about it and i almost tried all of them but none of them carried me to the end without making new issues,some of them made my old marker[] error again for me.

Emux

unread,
Feb 28, 2015, 5:58:44 AM2/28/15
to
That message indicates a mix in classpath, if finds a class more than 1 times.
Something is wrong there, have you added the jars also with IDE UI in classpath?

I suggest to try building a simple project (maybe irrelevant of mapsforge) with a single jar, to understand the IDE workings (I would try also with a clean workspace).

sarahave...@gmail.com

unread,
Feb 28, 2015, 6:18:53 AM2/28/15
to mapsfo...@googlegroups.com

On Saturday, February 28, 2015 at 2:28:44 PM UTC+3:30, Emux wrote:
Something is wrong there, have you added the jars also with IDE UI in classpath?

 
No i didnt, i just copied jar files directly into my lib folder from windows.



I suggest to try building a simple project (maybe irrelevant of mapsforge) with a single jar, to understand the IDE workings (I would try also with a clean workspace).


Its strange!
I just created a fresh test project again and i added a random jar file into it and it worked fine.then i started to add mapsforge jars 1 by 1 it was working fine even when i added all of them , when i removed that random jar file from my project that dex error happened again.

Emux

unread,
Feb 28, 2015, 6:22:54 AM2/28/15
to mapsfo...@googlegroups.com
I just took a closer look at your screenshots.

You have some unneeded and mixed jars.
The needed libraries are mentioned here.

Don't mix Android and AWT jars.
Also the SwingMapViewer is a sample application, not a library.

sarahave...@gmail.com

unread,
Feb 28, 2015, 6:29:51 AM2/28/15
to mapsfo...@googlegroups.com
Thank you so much , seems like it fixed my errors now im gonna do it for my main project to find out if that was same issue.
Reply all
Reply to author
Forward
0 new messages