0

I have downloaded MapBox jar file from here and added to my eclipse project. I am getting following exception when running the app.

02-01 13:11:42.867: E/AndroidRuntime(2674): java.lang.NoClassDefFoundError: com.mapbox.mapboxsdk.MapboxAccountManager 02-01 13:11:42.867: E/AndroidRuntime(2674): at com.example.mapbox.MainActivity.onCreate(MainActivity.java:18)

here is my code:

public class MainActivity extends Activity {
    private MapView mapView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         MapboxAccountManager.start(this, getString(R.string.access_token));
        setContentView(R.layout.activity_main);


        mapView = (MapView) findViewById(R.id.mapView);
        mapView.onCreate(savedInstanceState);
        mapView.getMapAsync(new OnMapReadyCallback() {

            @Override
            public void onMapReady(MapboxMap arg0) {
                // TODO Auto-generated method stub

            }
        });
    }

activity_main

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:mapbox="http://schemas.android.com/apk/lib/mapbox"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".examples.basics.SimpleMapViewActivity">

    <!-- Set the starting camera position and map style using xml-->
    <com.mapbox.mapboxsdk.maps.MapView
        android:id="@+id/mapView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        mapbox:center_latitude="40.73581"
        mapbox:center_longitude="-73.99155"
        mapbox:style_url="@string/url"
        mapbox:zoom="11" />

</RelativeLayout>

Please help me. I have searched a lot but nothing found useful. Thanks in advance.

user1767260
  • 1,543
  • 8
  • 26
  • 51
  • do you use proguard in your app? Is there is reason why you not just declare the dependency in your gradle/maven file? – reebow Feb 01 '17 at 07:56
  • First thing first - Go to the properties of the project by right clicking on the project. Then go to Java build path and then Order and Export tab. See if the jar included is checked. If not then check it and clean your project again and run. This is from here - http://stackoverflow.com/questions/20112614/android-eclipse-jar-file-class-not-found-at-run-time – Dibzmania Feb 01 '17 at 07:57
  • @Dibzmania When doing this I am getting another exception Unable to execute dex: Multiple dex files define Landroid/support/v7/appcompat/R$anim +eclipse – user1767260 Feb 01 '17 at 08:01
  • @reebow this project already done in Eclipse and it is using an older version of Mapbox and it working fine.now I want to update Mapbox – user1767260 Feb 01 '17 at 08:03
  • ok. That's because v7 support library is included multiple times within your project. I think the library you are using is already using v7 support library. If your app project has dependency on v7, then remove it and give it a go – Dibzmania Feb 01 '17 at 08:13
  • @Dibzmania after removing v7 depndency from project Ia m getting errors like Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'. – user1767260 Feb 01 '17 at 08:23
  • Do you have any other libraries that you are using which in turn might be including v7 support library. Scan all your libraries – Dibzmania Feb 01 '17 at 08:25
  • @Dibzmania MapBox library contains v7 library. But how can I fix it. It is jar file – user1767260 Feb 01 '17 at 08:30
  • I think the easiest way it to update your project to Android Studio and declare your dependencies in gradle. There you can also exclude libs that you have already in your project. Or you could try to update support lib as well. – reebow Feb 01 '17 at 08:30
  • Please use the aar file instead of the jar file – Tobrun Feb 06 '17 at 06:25

0 Answers0