谷歌地图加载缓慢

时间:2018-02-19 22:13:44

标签: android google-maps

我正在尝试使用支持片段加载一个简单的谷歌地图。一切正常,但初始加载导致jank和跳过帧。除谷歌地图片段外,活动中没有任何内容。我在这里做错了吗?非常感谢您的投入

日志

02-19 17:00:23.868 22747-22747/com.demo.android I/MainActivity: onCreate: Start
02-19 17:00:23.908 22747-22747/com.demo.android I/zzbz: Making Creator dynamically
02-19 17:00:23.913 22747-22747/com.demo.android I/DynamiteModule: Considering local module com.google.android.gms.maps_dynamite:0 and remote module com.google.android.gms.maps_dynamite:18
02-19 17:00:23.913 22747-22747/com.demo.android I/DynamiteModule: Selected remote version of com.google.android.gms.maps_dynamite, version >= 18
02-19 17:00:23.943 22747-22747/com.demo.android W/zygote64: Unsupported class loader
02-19 17:00:24.022 22747-22747/com.demo.android I/Google Maps Android API: Google Play services client version: 11910000
02-19 17:00:24.031 22747-22747/com.demo.android I/Google Maps Android API: Google Play services package version: 11975940
02-19 17:00:24.490 22747-22761/com.demo.android I/zygote64: Do full code cache collection, code=110KB, data=101KB
02-19 17:00:24.490 22747-22761/com.demo.android I/zygote64: After code cache collection, code=100KB, data=63KB
02-19 17:00:24.662 22747-22747/com.demo.android I/MainActivity: onCreate: End
02-19 17:00:24.680 22747-22747/com.demo.android I/Choreographer: Skipped 48 frames!  The application may be doing too much work on its main thread.
02-19 17:00:24.741 22747-22747/com.demo.android I/MainActivity: onMapReady: 

代码

public class MainActivity extends AppCompatActivity implements OnMapReadyCallback {

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.i("MainActivity", "onCreate: Start");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

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

    Log.i("MainActivity", "onCreate: End");
}

@Override
public void onMapReady(GoogleMap googleMap) {
    Log.i("MainActivity", "onMapReady: ");
    LatLng sydney = new LatLng(-33.852, 151.211);
    googleMap.addMarker(new MarkerOptions().position(sydney)
            .title("Marker in Sydney"));
    googleMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
}

布局

<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mapfrag"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.demo.android.MainActivity"/>

依赖

//Google Maps dependency
compile 'com.google.android.gms:play-services-maps:11.8.0'

0 个答案:

没有答案