I got a weird problem with a GoogleMap in Fragment.
I implemented some sort of a menu with items displayed via ViewPager. Some items can show a short GoogleMap as preview. The Items are Fragments wich are loaded by ViewPager. To show previous and next items the ViewPager is also wrapped inside a FrameLayout Container (like ViewPager with previous and next page boundaries).
The problem is that the map does not load. Last year I released a version with Eclipse and there was no problem. Now I use a different mac and imported the project in Android Studio. All things worked. I got an error in logcat, but map shows up in other activity with MapFragment:
E/dalvikvm﹕ Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zza
E/dalvikvm﹕ Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.common.hg.a
Method 1: MapView in custom Fragment (android MapView in Fragment) The MapView was shown but you can only see the grid of the map. When you scroll in the ViewPager a black rectangle appears on the place where the map has been.
<LinearLayout
android:id="@+id/itemInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/itemSubTitle"
android:layout_centerHorizontal="true"
android:orientation="vertical"
>
<TextView
android:id="@+id/itemDistanceInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="0dp"
android:paddingTop="0dp"
android:textSize="6pt"
android:textColor="@color/white"
android:text="ca. 89 km"
android:visibility="gone"
/>
<RelativeLayout
android:id="@+id/itemInfoPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="@color/white“
android:layout_marginTop="8dp"
android:padding="5dp"
android:visibility="gone"
>
<include layout="@layout/price_menu_fragment"/>
</RelativeLayout>
<FrameLayout
android:id="@+id/itemInfoPicture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="@color/white“
android:layout_marginTop="8dp"
android:padding="5dp"
android:visibility="visible"
>
<ImageView
android:id="@+id/itemImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="@drawable/menue_info"
android:visibility="invisible"
/>
<com.google.android.gms.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</FrameLayout>
</LinearLayout>
Method 2: SupportMapFragment in custom Fragment Here there is only a black view but with Google logo shown in the left corner. Scrolling in the ViewPager does not show a black rectangle like in method 1.
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
I hope that someone can help me out.