XML布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".ui.popularmovies.SearchByLocationActivity">
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_gravity="center"
android:layout_height="match_parent"
/>
</RelativeLayout>
还有我的Java代码:
public class SearchByLocationActivity extends FragmentActivity implements OnMapReadyCallback, PopularMoviesMvpView{
private GoogleMap mMap;
/* @Inject
PopularMoviesPresenter popularMoviesPresenter;*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// getActivityComponent().inject(this);
setContentView(R.layout.activity_search_by_location);
// popularMoviesPresenter.attachView(this);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
// popularMoviesPresenter.searchByLocation("1", "6");
}
这是我在日志中看到的异常:
java.lang.NoSuchMethodError:没有虚拟方法 zzts()Lcom / google / android / gms / dynamic / LifecycleDelegate;在班上 Lcom / google / android / gms / maps / SupportMapFragment $ zzb;或其超级 类(声明 'com.google.android.gms.maps.SupportMapFragment $ zzb'