Android MapBox inflating error. Didn't find class MapView












0














When I launch android app with MapBox library I get exception:




"android.view.InflateException: Binary XML file line #9: Error
inflating class com.mapbox.mapboxsdk.views.MapView"




Field "cause" contains this text:




java.lang.ClassNotFoundException: Didn't find class
"com.mapbox.mapboxsdk.views.MapView" on path: DexPathList[[zip file
"/data/app/com.example.my.mymapbox-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.my.mymapbox-2/lib/arm,
/vendor/lib, /system/lib]]




Help please



This is my code:



build.gradle



apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "com.example.my.mymapbox"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:4.0.0-beta.2@aar'){
transitive=true
}
}


MainActivity.java



package com.example.my.mymapbox;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

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


}



activity_main.xml



<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<com.mapbox.mapboxsdk.views.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
mapbox:access_token="@string/accessToken"/>
<!-- note the access token string created in the previous step -->
</RelativeLayout>









share|improve this question
























  • Did you try a full clean & gradle build of your project?
    – Daniel Veihelmann
    Mar 28 '16 at 13:54










  • Clean & gradle build didn't help.
    – BadEugene
    Mar 28 '16 at 14:02






  • 2




    Another think that you should keep in mind is that an invalid Token will cause the also an inflating error.
    – Adrian C.
    Mar 28 '16 at 21:05
















0














When I launch android app with MapBox library I get exception:




"android.view.InflateException: Binary XML file line #9: Error
inflating class com.mapbox.mapboxsdk.views.MapView"




Field "cause" contains this text:




java.lang.ClassNotFoundException: Didn't find class
"com.mapbox.mapboxsdk.views.MapView" on path: DexPathList[[zip file
"/data/app/com.example.my.mymapbox-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.my.mymapbox-2/lib/arm,
/vendor/lib, /system/lib]]




Help please



This is my code:



build.gradle



apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "com.example.my.mymapbox"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:4.0.0-beta.2@aar'){
transitive=true
}
}


MainActivity.java



package com.example.my.mymapbox;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

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


}



activity_main.xml



<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<com.mapbox.mapboxsdk.views.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
mapbox:access_token="@string/accessToken"/>
<!-- note the access token string created in the previous step -->
</RelativeLayout>









share|improve this question
























  • Did you try a full clean & gradle build of your project?
    – Daniel Veihelmann
    Mar 28 '16 at 13:54










  • Clean & gradle build didn't help.
    – BadEugene
    Mar 28 '16 at 14:02






  • 2




    Another think that you should keep in mind is that an invalid Token will cause the also an inflating error.
    – Adrian C.
    Mar 28 '16 at 21:05














0












0








0







When I launch android app with MapBox library I get exception:




"android.view.InflateException: Binary XML file line #9: Error
inflating class com.mapbox.mapboxsdk.views.MapView"




Field "cause" contains this text:




java.lang.ClassNotFoundException: Didn't find class
"com.mapbox.mapboxsdk.views.MapView" on path: DexPathList[[zip file
"/data/app/com.example.my.mymapbox-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.my.mymapbox-2/lib/arm,
/vendor/lib, /system/lib]]




Help please



This is my code:



build.gradle



apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "com.example.my.mymapbox"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:4.0.0-beta.2@aar'){
transitive=true
}
}


MainActivity.java



package com.example.my.mymapbox;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

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


}



activity_main.xml



<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<com.mapbox.mapboxsdk.views.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
mapbox:access_token="@string/accessToken"/>
<!-- note the access token string created in the previous step -->
</RelativeLayout>









share|improve this question















When I launch android app with MapBox library I get exception:




"android.view.InflateException: Binary XML file line #9: Error
inflating class com.mapbox.mapboxsdk.views.MapView"




Field "cause" contains this text:




java.lang.ClassNotFoundException: Didn't find class
"com.mapbox.mapboxsdk.views.MapView" on path: DexPathList[[zip file
"/data/app/com.example.my.mymapbox-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.my.mymapbox-2/lib/arm,
/vendor/lib, /system/lib]]




Help please



This is my code:



build.gradle



apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "com.example.my.mymapbox"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:4.0.0-beta.2@aar'){
transitive=true
}
}


MainActivity.java



package com.example.my.mymapbox;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

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


}



activity_main.xml



<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<com.mapbox.mapboxsdk.views.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
mapbox:access_token="@string/accessToken"/>
<!-- note the access token string created in the previous step -->
</RelativeLayout>






android mapbox inflate-exception






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 11 '16 at 13:02









usr2564301

17.6k73270




17.6k73270










asked Mar 28 '16 at 13:44









BadEugene

137




137












  • Did you try a full clean & gradle build of your project?
    – Daniel Veihelmann
    Mar 28 '16 at 13:54










  • Clean & gradle build didn't help.
    – BadEugene
    Mar 28 '16 at 14:02






  • 2




    Another think that you should keep in mind is that an invalid Token will cause the also an inflating error.
    – Adrian C.
    Mar 28 '16 at 21:05


















  • Did you try a full clean & gradle build of your project?
    – Daniel Veihelmann
    Mar 28 '16 at 13:54










  • Clean & gradle build didn't help.
    – BadEugene
    Mar 28 '16 at 14:02






  • 2




    Another think that you should keep in mind is that an invalid Token will cause the also an inflating error.
    – Adrian C.
    Mar 28 '16 at 21:05
















Did you try a full clean & gradle build of your project?
– Daniel Veihelmann
Mar 28 '16 at 13:54




Did you try a full clean & gradle build of your project?
– Daniel Veihelmann
Mar 28 '16 at 13:54












Clean & gradle build didn't help.
– BadEugene
Mar 28 '16 at 14:02




Clean & gradle build didn't help.
– BadEugene
Mar 28 '16 at 14:02




2




2




Another think that you should keep in mind is that an invalid Token will cause the also an inflating error.
– Adrian C.
Mar 28 '16 at 21:05




Another think that you should keep in mind is that an invalid Token will cause the also an inflating error.
– Adrian C.
Mar 28 '16 at 21:05












2 Answers
2






active

oldest

votes


















2














Your XML for the MapView needs to be com.mapbox.mapboxsdk.maps.MapView not com.mapbox.mapboxsdk.views.MapView



Other things that might help when using the latest Mapbox Android SDK version which is:



compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:4.0.0-rc.1@aar'){
transitive=true
}


make sure to include all the required permissions as well as Telemetry service:



<service android:name="com.mapbox.mapboxsdk.telemetry.TelemetryService" />


To control the MapView in 4.0.0 there is a new method called getMapAsync which listens for when the map is ready. Once it is, you can add markers, change the camera position, etc. So your onCreate will look something like so:



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

mapView = (MapView) findViewById(R.id.mapview);
mapView.onCreate(savedInstanceState);

mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap mapboxMap) {

// add markers, change camera position, etc. here!

}

...


Lastly, make sure you include all the mapView methods within your activities lifecycle. It will look like this:



// Activity lifecycle calls
@Override
protected void onStart() {
super.onStart();
mapView.onStart();
}

@Override
public void onResume() {
super.onResume();
mapView.onResume();
}

@Override
public void onPause() {
super.onPause();
mapView.onPause();
}

@Override
protected void onStop() {
super.onStop();
mapView.onStop();
}

@Override
protected void onDestroy() {
super.onDestroy();
mapView.onDestroy();
}

@Override
public void onLowMemory() {
super.onLowMemory();
mapView.onLowMemory();
}

@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mapView.onSaveInstanceState(outState);
}


Hope this helps!






share|improve this answer























  • Yes! It helps, Thank you:) Now I have another exception:D
    – BadEugene
    Mar 28 '16 at 15:44










  • I edited my answer with some useful steps. If you post your logcat where the exception occurs I can further help you out.
    – cammace
    Mar 28 '16 at 15:55










  • May be I should create other topic. Next exception message is: "/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)" This is logcat pastebin.com/jtYivuzV
    – BadEugene
    Mar 28 '16 at 17:05












  • Probably best to create a new question for this one. Make sure to include your logcat and what device your trying it on, along with any other relevant info and i'll be able to help. If I resolved your issue mentioned within your question above, please mark this as answered so others with the same question can quickly find the answer.
    – cammace
    Mar 28 '16 at 17:09










  • Now all work! Thank you!
    – BadEugene
    Mar 28 '16 at 17:15



















0














I also faced this problem but when add this library to my dependencies



implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.23.0'


Give this exeptions



Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class com.mapbox.mapboxsdk.maps.MapView


Even if i do not use navigation!! Then i realize i must initialize Mapbox before setContentView



So just move up like this



@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//first initialize Mapbox
Mapbox.getInstance(this, YOUR_MAPBOX_KEY);
//then
setContentView(R.layout.activity_main);
}


And my problem solve






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f36263653%2fandroid-mapbox-inflating-error-didnt-find-class-mapview%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    Your XML for the MapView needs to be com.mapbox.mapboxsdk.maps.MapView not com.mapbox.mapboxsdk.views.MapView



    Other things that might help when using the latest Mapbox Android SDK version which is:



    compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:4.0.0-rc.1@aar'){
    transitive=true
    }


    make sure to include all the required permissions as well as Telemetry service:



    <service android:name="com.mapbox.mapboxsdk.telemetry.TelemetryService" />


    To control the MapView in 4.0.0 there is a new method called getMapAsync which listens for when the map is ready. Once it is, you can add markers, change the camera position, etc. So your onCreate will look something like so:



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

    mapView = (MapView) findViewById(R.id.mapview);
    mapView.onCreate(savedInstanceState);

    mapView.getMapAsync(new OnMapReadyCallback() {
    @Override
    public void onMapReady(MapboxMap mapboxMap) {

    // add markers, change camera position, etc. here!

    }

    ...


    Lastly, make sure you include all the mapView methods within your activities lifecycle. It will look like this:



    // Activity lifecycle calls
    @Override
    protected void onStart() {
    super.onStart();
    mapView.onStart();
    }

    @Override
    public void onResume() {
    super.onResume();
    mapView.onResume();
    }

    @Override
    public void onPause() {
    super.onPause();
    mapView.onPause();
    }

    @Override
    protected void onStop() {
    super.onStop();
    mapView.onStop();
    }

    @Override
    protected void onDestroy() {
    super.onDestroy();
    mapView.onDestroy();
    }

    @Override
    public void onLowMemory() {
    super.onLowMemory();
    mapView.onLowMemory();
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    mapView.onSaveInstanceState(outState);
    }


    Hope this helps!






    share|improve this answer























    • Yes! It helps, Thank you:) Now I have another exception:D
      – BadEugene
      Mar 28 '16 at 15:44










    • I edited my answer with some useful steps. If you post your logcat where the exception occurs I can further help you out.
      – cammace
      Mar 28 '16 at 15:55










    • May be I should create other topic. Next exception message is: "/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)" This is logcat pastebin.com/jtYivuzV
      – BadEugene
      Mar 28 '16 at 17:05












    • Probably best to create a new question for this one. Make sure to include your logcat and what device your trying it on, along with any other relevant info and i'll be able to help. If I resolved your issue mentioned within your question above, please mark this as answered so others with the same question can quickly find the answer.
      – cammace
      Mar 28 '16 at 17:09










    • Now all work! Thank you!
      – BadEugene
      Mar 28 '16 at 17:15
















    2














    Your XML for the MapView needs to be com.mapbox.mapboxsdk.maps.MapView not com.mapbox.mapboxsdk.views.MapView



    Other things that might help when using the latest Mapbox Android SDK version which is:



    compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:4.0.0-rc.1@aar'){
    transitive=true
    }


    make sure to include all the required permissions as well as Telemetry service:



    <service android:name="com.mapbox.mapboxsdk.telemetry.TelemetryService" />


    To control the MapView in 4.0.0 there is a new method called getMapAsync which listens for when the map is ready. Once it is, you can add markers, change the camera position, etc. So your onCreate will look something like so:



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

    mapView = (MapView) findViewById(R.id.mapview);
    mapView.onCreate(savedInstanceState);

    mapView.getMapAsync(new OnMapReadyCallback() {
    @Override
    public void onMapReady(MapboxMap mapboxMap) {

    // add markers, change camera position, etc. here!

    }

    ...


    Lastly, make sure you include all the mapView methods within your activities lifecycle. It will look like this:



    // Activity lifecycle calls
    @Override
    protected void onStart() {
    super.onStart();
    mapView.onStart();
    }

    @Override
    public void onResume() {
    super.onResume();
    mapView.onResume();
    }

    @Override
    public void onPause() {
    super.onPause();
    mapView.onPause();
    }

    @Override
    protected void onStop() {
    super.onStop();
    mapView.onStop();
    }

    @Override
    protected void onDestroy() {
    super.onDestroy();
    mapView.onDestroy();
    }

    @Override
    public void onLowMemory() {
    super.onLowMemory();
    mapView.onLowMemory();
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    mapView.onSaveInstanceState(outState);
    }


    Hope this helps!






    share|improve this answer























    • Yes! It helps, Thank you:) Now I have another exception:D
      – BadEugene
      Mar 28 '16 at 15:44










    • I edited my answer with some useful steps. If you post your logcat where the exception occurs I can further help you out.
      – cammace
      Mar 28 '16 at 15:55










    • May be I should create other topic. Next exception message is: "/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)" This is logcat pastebin.com/jtYivuzV
      – BadEugene
      Mar 28 '16 at 17:05












    • Probably best to create a new question for this one. Make sure to include your logcat and what device your trying it on, along with any other relevant info and i'll be able to help. If I resolved your issue mentioned within your question above, please mark this as answered so others with the same question can quickly find the answer.
      – cammace
      Mar 28 '16 at 17:09










    • Now all work! Thank you!
      – BadEugene
      Mar 28 '16 at 17:15














    2












    2








    2






    Your XML for the MapView needs to be com.mapbox.mapboxsdk.maps.MapView not com.mapbox.mapboxsdk.views.MapView



    Other things that might help when using the latest Mapbox Android SDK version which is:



    compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:4.0.0-rc.1@aar'){
    transitive=true
    }


    make sure to include all the required permissions as well as Telemetry service:



    <service android:name="com.mapbox.mapboxsdk.telemetry.TelemetryService" />


    To control the MapView in 4.0.0 there is a new method called getMapAsync which listens for when the map is ready. Once it is, you can add markers, change the camera position, etc. So your onCreate will look something like so:



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

    mapView = (MapView) findViewById(R.id.mapview);
    mapView.onCreate(savedInstanceState);

    mapView.getMapAsync(new OnMapReadyCallback() {
    @Override
    public void onMapReady(MapboxMap mapboxMap) {

    // add markers, change camera position, etc. here!

    }

    ...


    Lastly, make sure you include all the mapView methods within your activities lifecycle. It will look like this:



    // Activity lifecycle calls
    @Override
    protected void onStart() {
    super.onStart();
    mapView.onStart();
    }

    @Override
    public void onResume() {
    super.onResume();
    mapView.onResume();
    }

    @Override
    public void onPause() {
    super.onPause();
    mapView.onPause();
    }

    @Override
    protected void onStop() {
    super.onStop();
    mapView.onStop();
    }

    @Override
    protected void onDestroy() {
    super.onDestroy();
    mapView.onDestroy();
    }

    @Override
    public void onLowMemory() {
    super.onLowMemory();
    mapView.onLowMemory();
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    mapView.onSaveInstanceState(outState);
    }


    Hope this helps!






    share|improve this answer














    Your XML for the MapView needs to be com.mapbox.mapboxsdk.maps.MapView not com.mapbox.mapboxsdk.views.MapView



    Other things that might help when using the latest Mapbox Android SDK version which is:



    compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:4.0.0-rc.1@aar'){
    transitive=true
    }


    make sure to include all the required permissions as well as Telemetry service:



    <service android:name="com.mapbox.mapboxsdk.telemetry.TelemetryService" />


    To control the MapView in 4.0.0 there is a new method called getMapAsync which listens for when the map is ready. Once it is, you can add markers, change the camera position, etc. So your onCreate will look something like so:



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

    mapView = (MapView) findViewById(R.id.mapview);
    mapView.onCreate(savedInstanceState);

    mapView.getMapAsync(new OnMapReadyCallback() {
    @Override
    public void onMapReady(MapboxMap mapboxMap) {

    // add markers, change camera position, etc. here!

    }

    ...


    Lastly, make sure you include all the mapView methods within your activities lifecycle. It will look like this:



    // Activity lifecycle calls
    @Override
    protected void onStart() {
    super.onStart();
    mapView.onStart();
    }

    @Override
    public void onResume() {
    super.onResume();
    mapView.onResume();
    }

    @Override
    public void onPause() {
    super.onPause();
    mapView.onPause();
    }

    @Override
    protected void onStop() {
    super.onStop();
    mapView.onStop();
    }

    @Override
    protected void onDestroy() {
    super.onDestroy();
    mapView.onDestroy();
    }

    @Override
    public void onLowMemory() {
    super.onLowMemory();
    mapView.onLowMemory();
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    mapView.onSaveInstanceState(outState);
    }


    Hope this helps!







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Mar 28 '16 at 15:54

























    answered Mar 28 '16 at 15:17









    cammace

    2,6141615




    2,6141615












    • Yes! It helps, Thank you:) Now I have another exception:D
      – BadEugene
      Mar 28 '16 at 15:44










    • I edited my answer with some useful steps. If you post your logcat where the exception occurs I can further help you out.
      – cammace
      Mar 28 '16 at 15:55










    • May be I should create other topic. Next exception message is: "/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)" This is logcat pastebin.com/jtYivuzV
      – BadEugene
      Mar 28 '16 at 17:05












    • Probably best to create a new question for this one. Make sure to include your logcat and what device your trying it on, along with any other relevant info and i'll be able to help. If I resolved your issue mentioned within your question above, please mark this as answered so others with the same question can quickly find the answer.
      – cammace
      Mar 28 '16 at 17:09










    • Now all work! Thank you!
      – BadEugene
      Mar 28 '16 at 17:15


















    • Yes! It helps, Thank you:) Now I have another exception:D
      – BadEugene
      Mar 28 '16 at 15:44










    • I edited my answer with some useful steps. If you post your logcat where the exception occurs I can further help you out.
      – cammace
      Mar 28 '16 at 15:55










    • May be I should create other topic. Next exception message is: "/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)" This is logcat pastebin.com/jtYivuzV
      – BadEugene
      Mar 28 '16 at 17:05












    • Probably best to create a new question for this one. Make sure to include your logcat and what device your trying it on, along with any other relevant info and i'll be able to help. If I resolved your issue mentioned within your question above, please mark this as answered so others with the same question can quickly find the answer.
      – cammace
      Mar 28 '16 at 17:09










    • Now all work! Thank you!
      – BadEugene
      Mar 28 '16 at 17:15
















    Yes! It helps, Thank you:) Now I have another exception:D
    – BadEugene
    Mar 28 '16 at 15:44




    Yes! It helps, Thank you:) Now I have another exception:D
    – BadEugene
    Mar 28 '16 at 15:44












    I edited my answer with some useful steps. If you post your logcat where the exception occurs I can further help you out.
    – cammace
    Mar 28 '16 at 15:55




    I edited my answer with some useful steps. If you post your logcat where the exception occurs I can further help you out.
    – cammace
    Mar 28 '16 at 15:55












    May be I should create other topic. Next exception message is: "/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)" This is logcat pastebin.com/jtYivuzV
    – BadEugene
    Mar 28 '16 at 17:05






    May be I should create other topic. Next exception message is: "/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)" This is logcat pastebin.com/jtYivuzV
    – BadEugene
    Mar 28 '16 at 17:05














    Probably best to create a new question for this one. Make sure to include your logcat and what device your trying it on, along with any other relevant info and i'll be able to help. If I resolved your issue mentioned within your question above, please mark this as answered so others with the same question can quickly find the answer.
    – cammace
    Mar 28 '16 at 17:09




    Probably best to create a new question for this one. Make sure to include your logcat and what device your trying it on, along with any other relevant info and i'll be able to help. If I resolved your issue mentioned within your question above, please mark this as answered so others with the same question can quickly find the answer.
    – cammace
    Mar 28 '16 at 17:09












    Now all work! Thank you!
    – BadEugene
    Mar 28 '16 at 17:15




    Now all work! Thank you!
    – BadEugene
    Mar 28 '16 at 17:15













    0














    I also faced this problem but when add this library to my dependencies



    implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.23.0'


    Give this exeptions



    Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class com.mapbox.mapboxsdk.maps.MapView


    Even if i do not use navigation!! Then i realize i must initialize Mapbox before setContentView



    So just move up like this



    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //first initialize Mapbox
    Mapbox.getInstance(this, YOUR_MAPBOX_KEY);
    //then
    setContentView(R.layout.activity_main);
    }


    And my problem solve






    share|improve this answer


























      0














      I also faced this problem but when add this library to my dependencies



      implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.23.0'


      Give this exeptions



      Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class com.mapbox.mapboxsdk.maps.MapView


      Even if i do not use navigation!! Then i realize i must initialize Mapbox before setContentView



      So just move up like this



      @Override
      protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      //first initialize Mapbox
      Mapbox.getInstance(this, YOUR_MAPBOX_KEY);
      //then
      setContentView(R.layout.activity_main);
      }


      And my problem solve






      share|improve this answer
























        0












        0








        0






        I also faced this problem but when add this library to my dependencies



        implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.23.0'


        Give this exeptions



        Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class com.mapbox.mapboxsdk.maps.MapView


        Even if i do not use navigation!! Then i realize i must initialize Mapbox before setContentView



        So just move up like this



        @Override
        protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //first initialize Mapbox
        Mapbox.getInstance(this, YOUR_MAPBOX_KEY);
        //then
        setContentView(R.layout.activity_main);
        }


        And my problem solve






        share|improve this answer












        I also faced this problem but when add this library to my dependencies



        implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.23.0'


        Give this exeptions



        Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class com.mapbox.mapboxsdk.maps.MapView


        Even if i do not use navigation!! Then i realize i must initialize Mapbox before setContentView



        So just move up like this



        @Override
        protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //first initialize Mapbox
        Mapbox.getInstance(this, YOUR_MAPBOX_KEY);
        //then
        setContentView(R.layout.activity_main);
        }


        And my problem solve







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 19 '18 at 12:41









        Radesh

        3,17111330




        3,17111330






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f36263653%2fandroid-mapbox-inflating-error-didnt-find-class-mapview%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            MongoDB - Not Authorized To Execute Command

            in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

            How to fix TextFormField cause rebuild widget in Flutter