AirMap找不到导入

时间:2019-11-14 04:14:59

标签: java android mapbox

我看到的构建错误是-
错误:无法访问OnMapChangedListener 找不到com.mapbox.mapboxsdk.maps.MapView $ OnMapChangedListener的类文件

这是我的片段

package com.example.mapboxhelloworld;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.airmap.airmapsdk.models.rules.AirMapRuleset;
import com.airmap.airmapsdk.models.status.AirMapAirspaceStatus;
import com.airmap.airmapsdk.networking.services.AirMap;
import com.airmap.airmapsdk.ui.views.AirMapMapView;
import com.airmap.airmapsdk.ui.views.AirMapMapView.OnMapDataChangeListener;
import com.airmap.airmapsdk.util.AirMapConfig;
import com.mapbox.mapboxsdk.Mapbox;
import java.util.List;

public class MainActivity extends Fragment implements OnMapDataChangeListener {
    Context context;
    public AirMapMapView mapView;                  // mapbox MapView wrapper
    private AirMapMapView.DynamicConfiguration configuration;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        //initialize and setup AirMap
        Mapbox.getInstance(context, AirMapConfig.getMapboxApiKey());
        AirMap.init(context);
        View view = inflater.inflate(R.layout.activity_main, null);
        Mapbox.getInstance(context, getString(R.string.MAPBOX_ACCESS_TOKEN));

        //ui
        mapView = view.findViewById(R.id.mapView);
        mapView.onCreate(savedInstanceState);
        mapView.getMapAsync(null);
        mapView.addOnMapDataChangedListener(this);

        //configuration
        mapView.getMapAsync(null);
        configuration = new AirMapMapView.DynamicConfiguration(null, null, true);
        mapView.configure(configuration);



// Add this line when using Mapbox
        return view;

    }
            // Mapbox requires lifecycle
            @Override
            public void onStart() {
                super.onStart();
                mapView.onStart();
            }

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

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

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

            @Override
            public void onDestroyView() {
                super.onDestroyView();
                mapView.onDestroy();

                mapView.removeOnMapDataChangedListener(this);
            }

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

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

    @Override
    public void onAttachFragment(@NonNull Fragment childFragment) {
        super.onAttachFragment(childFragment);
        context = getContext();
    }

    @Override
    public void onRulesetsChanged(List<AirMapRuleset> availableRulesets, List<AirMapRuleset> selectedRulesets) {}

    @Override
    public void onAdvisoryStatusChanged(AirMapAirspaceStatus status) {}

    @Override
    public void onAdvisoryStatusLoading() {}

}


这是我的应用程序build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"


    defaultConfig {
        applicationId "com.example.mapboxhelloworld"
        manifestPlaceholders = ['appAuthRedirectScheme': applicationId]
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    //mapbox
    implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:8.4.0'

    //airmap
    implementation 'com.airmap.airmapsdk:airmapsdk:3.0.0'

    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

这是我的项目build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.2'
        //mapbox
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven{
            url "https://maven.google.com"
        }
        maven {
            url "https://jitpack.io"
        }
        mavenCentral()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

这是我的json.config文件-

{
  "airmap": {
    "api_key": "API_KEY",
    "client_id": "CLIENT_ID",
    "callback_url": "com.example.skymap://oauth2/airmap"
  },
  "mapbox": {
    "access_token": "ACCESS_TOKEN"
  }
}

我尝试过的-
1)遍历依赖项以确保我没有丢失任何东西。
2)试图隔离此问题。看起来findViewByID似乎正在解决这个问题。使用此方法的方式是否会出错?
3)检查了我的导入,并添加了所有推荐的android studio导入。   
4)我没有实现接口,而是尝试创建OnMapDataChangeListener类型的新类变量并进行适当的更改。没运气。

注意-我正在config.json文件中使用我的公共mapbox访问令牌。请注意,OnMapDataChangeListener与OnMapDataChangedListener不同。他们是2个不同的班级。

PS-对代码量感到抱歉。这无能为力。

edit-更新了移动应用程序的config.json。

0 个答案:

没有答案