2

I'm trying to use a fragment autocomplete UI from ---> https://docs.mapbox.com/android/plugins/overview/places/

but the IDE says that it can't resolve the symbol CarmenFeature and I don't know how to import that class or solve this exception

I've tried :

  • to import ---> import com.mapbox.api.v4.models.CarmenFeature; but I think that the API folder does not exist

  • sync with gradle

  • invalidate cache and restart

  • rebuild project

  • clean project


autocompleteFragment = (SupportPlaceAutocompleteFragment) getSupportFragmentManager().findFragmentByTag(TAG);
autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
   @Override
   public void onPlaceSelected( CarmenFeature carmenFeature) {

   }

   @Override
   public void onError(Status status) {

   }
});
Jorgesys
  • 124,308
  • 23
  • 334
  • 268
Iann7
  • 79
  • 9

1 Answers1

1

Well the problem is that the class cannot be imported and loaded. You need to configure inside the build.gradle in the root of your project :

allprojects {
    repositories {
        ...
        ...
        maven
             {
              url 'https://mapbox.bintray.com/mapbox'
             }
    }
}

and inside your /app/build.gradle :

dependencies {
    ...
    ...  
    // MAPBOX DEPENDENCIES
    implementation ('com.mapbox.mapboxsdk:mapbox-android-sdk:6.5.0@aar')
            {
                transitive=true
            }
    implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.20.0'
    implementation ('com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.20.0')
            {
                transitive = true
            }
    implementation 'com.google.android.gms:play-services-maps:16.0.0'
    implementation 'com.android.support:design:27.0.2'

}

this is enough to use the CarmenFeature class.

enter image description here

Jorgesys
  • 124,308
  • 23
  • 334
  • 268
  • 1
    Thanks! everything seems to be working out fine. But since I'm just a beginner I've got no idea what have I just done. What would you recommend to learn these stuff? – Iann7 Jul 28 '19 at 19:58
  • 1
    Read about dependencies : https://developer.android.com/studio/build/dependencies – Jorgesys Jul 29 '19 at 00:18