0
我想在Android Studio项目中设置谷歌地图,但即使应用不同的选项后仍面临不兼容的类型错误无法摆脱它。感谢您的时间和制导误差的Android Studio谷歌地图不兼容类型错误
截图
Logcate报告
Error:(454, 88) error: incompatible types: Fragment cannot be converted to SupportMapFragment
XML代码
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map2"
class="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
活动代码
public class Search extends FragmentActivity implements OnMapReadyCallback
private void initializeMap()
{
SupportMapFragment map = ((SupportMapFragment) getFragmentManager().findFragmentById(R.id.map2)).getMapAsync(this);
}
@Override
public void onMapReady(GoogleMap googleMap) {
}