0

Ich habe Map-Fragment in meiner App und wie ich sagte es verursacht Rendering-Problem, versuchte ich zu reinigen/Rebuild-Projekt, mit verschiedenen API rendern, aber es funktioniert nicht, das ist ein Fehler:Google Map Fragment verursacht Render-Fehler in Android Studio

Preview timed out while rendering the layout. 

Wenn ich es kommentieren alles gut funktioniert, hier ist der Code:

<android.support.v4.widget.DrawerLayout 
     android:id="@+id/drawerlayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 


     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 

       <include 
        android:id="@+id/customtoolbar" 
        layout="@layout/toolbar_layout" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"/> 

      <!-- 
        <fragment 

         android:id="@+id/map_fragment_id" 
         android:name="com.google.android.gms.maps.MapFragment" 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:layout_alignParentStart="true" 
         android:layout_below="@+id/customtoolbar" 
         tools:layout="@layout/activity_main" /> --> 


       <Button 
        android:id="@+id/main_btn" 
        android:layout_width="280dp" 
        android:layout_height="50dp" 
        android:layout_alignParentBottom="true" 
        android:layout_centerHorizontal="true" 
        android:layout_marginBottom="6dp" 
        android:background="@drawable/radius_corners_green_background" 
        android:gravity="center" 
        android:textColor="#FFF" 
        android:textSize="17sp" 
        android:text="yep"/> 

     </RelativeLayout> 

      <android.support.design.widget.NavigationView 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       app:menu="@menu/navigation_menu" 
       android:layout_gravity="start" 
       app:headerLayout="@layout/navigation_header"> 
      </android.support.design.widget.NavigationView> 

    </android.support.v4.widget.DrawerLayout> 
+0

es, weil Ihre Designer-Vorschau höhere API-Ebene als die aktuelle API-Ebene verwendet wird, . Versuchen Sie es in build.gradle zu ändern und synchronisieren Sie Ihr Projekt. –

Antwort

0

Versuchen sie, diese

<fragment 
     android:id="@+id/map" 
     android:name="com.google.android.gms.maps.SupportMapFragment" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

Implementieren OnMapReadyCallback in Ihrer Tätigkeit

diese Zeilen innerhalb onCreate hinzufügen()

SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); 
    mapFragment.getMapAsync(this); 

Aufschalten onMapReady Methode()

@Override 
public void onMapReady(GoogleMap map) { 
    // googleMap = map; 
} 
Verwandte Themen