无法解析方法“ getMap()”

时间:2019-07-06 13:17:51

标签: android google-maps android-maps-v2

在gradle.properties中:

android.useAndroidX=true
android.enableJetifier=true

在app / build.gradle中:

def AAVersion = '4.6.0'

dependencies {
    annotationProcessor "org.androidannotations:androidannotations:$AAVersion"

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

    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'org.apache.commons:commons-lang3:3.8.1'
    implementation 'com.google.android.gms:play-services:4.3.23'
    implementation 'com.google.code.gson:gson:2.8.5'

}

在androidx片段中

import com.google.android.gms.maps.SupportMapFragment;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.GoogleMap.OnMarkerClickListener;
import com.google.android.gms.maps.GoogleMap.OnMyLocationChangeListener;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;


public class AgentsFragmentMapTab extends androidx.fragment.app.Fragment {

private SupportMapFragment mapFrag;
private GoogleMap map;



                    FragmentManager fm = getChildFragmentManager();
                    mapFrag = (SupportMapFragment) fm.findFragmentById(R.id.google_map);
                    map = mapFrag.getMap();
                    map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
                    map.setOnMarkerClickListener((OnMarkerClickListener) thisFragment);
                    map.moveCamera(CameraUpdateFactory.zoomTo(14f));

}

一切正常。但是当我升级lib时:

implementation 'com.google.android.gms:play-services:12.0.1'

此行出现编译错误:

map = mapFrag.getMap();

错误消息:

Cannot resolve method 'getMap()'

0 个答案:

没有答案