无法解析符号“ CarmenFeature”

时间:2019-07-28 17:09:13

标签: java android mapbox-android

我正在尝试使用---> https://docs.mapbox.com/android/plugins/overview/places/

中的片段自动完成UI

但是IDE表示它无法解析符号CarmenFeature,而且我不知道如何导入该类或解决此异常

我尝试过:

  • 导入--->导入com.mapbox.api.v4.models.CarmenFeature; 但我认为API文件夹不存在

  • 与gradle同步

  • 使缓存无效并重新启动

  • 重建项目

  • 清理项目


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

   }

   @Override
   public void onError(Status status) {

   }
});

1 个答案:

答案 0 :(得分:0)

问题是无法导入和加载该类。您需要在proyect的根build.gradle内部进行配置:

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

并在您的/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'

}

这足以使用CarmenFeature类。

enter image description here