【发布时间】:2015-02-19 18:17:29
【问题描述】:
我将我的应用程序 eclipse 移至 android studio。我的代码在 Eclipse 上运行完美,但在 Android Studio 上运行良好
mapView = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
返回空 我的xml在这里
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
xmlns:ads="http://schemas.android.com/apk/res-auto"
>
<com.google.android.gms.ads.AdView
android:id="@+id/adMob"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="@string/admob_unit_id" />
<fragment
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
</LinearLayout>
为什么返回 null?
我搜索并compileSdkVersion 21 导致它。但是如果我改变它 19 仍然返回 null
【问题讨论】:
-
...所以保持
compileSdkVersion21? -
是的,我保持在 21
标签: android android-studio google-maps-api-2