地图不再适用于Android API 23

时间:2017-12-21 20:44:18

标签: android google-maps

我的应用包含一个曾经工作过的mapFragment。但是,在代码中的一些更改后,它不再有效(它只显示底部的Google徽标)。不幸的是,我已经覆盖了工作代码。

这是MapActivity:

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {

private GoogleMap mMap;
String tag="Babis map";

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.i(tag,"onCreate start");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);
    // Obtain the SupportMapFragment and get notified when the map is ready to be used.
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
    Log.i(tag,"onCreate end");
}

@Override
public void onMapReady(GoogleMap googleMap) {
    Log.i(tag,"mapready start");
    mMap = googleMap;
    // Add a marker in Sydney and move the camera
    LatLng cent=new LatLng(35.36,24.48);
    //mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
    //mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
    mMap.addMarker(new MarkerOptions()
            .position(new LatLng(35.3617284,24.4863311))
            .anchor(0.5f, 0.5f)
            .title("Bob")
            .snippet("potato")
            .icon(BitmapDescriptorFactory
                    .defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
    mMap.moveCamera(CameraUpdateFactory.newLatLng(cent));
    mMap.moveCamera(CameraUpdateFactory.zoomTo(13) );
    Log.i(tag,"onCreate end");
}



}

这是清单文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="charalampos.walker">

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
<uses-feature android:name="android.hardware.location.gps" />


<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity
        android:name=".MainActivity"
        android:configChanges="orientation|screenSize"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <!--
         The API key for Google Maps-based APIs is defined as a string resource.
         (See the file "res/values/google_maps_api.xml").
         Note that the API key is linked to the encryption key used to sign the APK.
         You need a different API key for each encryption key, including the release key that is used to
         sign the APK for publishing.
         You can define the keys for the debug and release targets in src/debug/ and src/release/. 
    -->
    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="@string/google_maps_key" />

    <activity
        android:name=".MapsActivity"
        android:label="@string/title_activity_maps" />

    <service
        android:name=".YourService"
        android:enabled="true"
        android:exported="true" />

    <receiver
        android:name=".Alarm"
        android:enabled="true"
        android:exported="true">
        <intent-filter>
            <action android:name="habos.START_ALARM"></action>
        </intent-filter>
    </receiver>
</application>

</manifest>

我最近不得不重新安装AS,不得不清理并重建项目。这可能会影响应用程序,Map键或其他什么?

Logcat输出是这样的(抱歉格式不好):

  

12-21 22:38:50.087 23354-23354 / charalampos.walker I / Babis map:onCreate start   12-21 22:38:50.143 23354-23354 / charalampos.walker I / zzai:动态制作造物主   12-21 22:38:50.247 23354-23354 / charalampos.walker I / System.out:[/ system / bin / getprop,debug.mapview.logs]   12-21 22:38:50.247 23354-23354 / charalampos.walker I / System.out:null   12-21 22:38:50.247 23354-23354 / charalampos.walker I / System.out:null   12-21 22:38:50.248 23354-23354 / charalampos.walker I / System.out:通过:: className调用:com.google.maps.api.android.lib6.common.o MethodName:a   12-21 22:38:50.284 23354-23354 / charalampos.walker I / Google Maps Android API:Google Play服务客户端版本:10298000   12-21 22:38:50.294 23354-23354 / charalampos.walker I / Google Maps Android API:Google Play服务包版本:11951446   12-21 22:38:50.296 23354-23354 / charalampos.walker I / System.out:[/ system / bin / getprop,debug.mapview.renderer]   12-21 22:38:50.296 23354-23354 / charalampos.walker I / System.out:null   12-21 22:38:50.296 23354-23354 / charalampos.walker I / System.out:null   12-21 22:38:50.297 23354-23354 / charalampos.walker I / System.out:通过:: className调用:com.google.maps.api.android.lib6.common.o MethodName:a   12-21 22:38:50.332 23354-23354 / charalampos.walker I / System.out:[/ system / bin / getprop,debug.mapview.streetview]   12-21 22:38:50.332 23354-23354 / charalampos.walker I / System.out:null   12-21 22:38:50.332 23354-23354 / charalampos.walker I / System.out:null   12-21 22:38:50.333 23354-23354 / charalampos.walker I / System.out:通过:: className调用:com.google.maps.api.android.lib6.common.o MethodName:a   12-21 22:38:50.409 23354-23354 / charalampos.walker I / System.out:[/ system / bin / getprop,debug.mapview.gmmserver]   12-21 22:38:50.410 23354-23354 / charalampos.walker I / System.out:null   12-21 22:38:50.410 23354-23354 / charalampos.walker I / System.out:null   12-21 22:38:50.411 23354-23354 / charalampos.walker I / System.out:通过:: className调用:com.google.maps.api.android.lib6.common.o MethodName:a   12-21 22:38:50.590 23354-23354 / charalampos.walker I / System.out:[/ system / bin / getprop,debug.mapview.renderer.label]   12-21 22:38:50.590 23354-23354 / charalampos.walker I / System.out:null   12-21 22:38:50.590 23354-23354 / charalampos.walker I / System.out:null   12-21 22:38:50.590 23354-23354 / charalampos.walker I / System.out:通过:: className调用:com.google.maps.api.android.lib6.common.o MethodName:a   12-21 22:38:50.827 3163-3172 /?我/艺术:背景部分并发标记扫描GC释放90218(6MB)AllocSpace对象,37(636KB)LOS对象,32%免费,32MB / 48MB,暂停3.535ms总计252.052ms   12-21 22:38:50.885 23354-23354 / charalampos.walker I / Babis地图:onCreate end   12-21 22:38:50.893 23354-23354 / charalampos.walker I / Choreographer:跳过51帧!应用程序可能在其主线程上做了太多工作。   12-21 22:38:50.901 2474-2474 /? E / HAL:load:id = gralloc!= hmi-&gt; id = gralloc   12-21 22:38:50.922 2474-2527 /? I / [Gralloc]:分配w [720] h [1280]格式[1]用法[3842]   12-21 22:38:50.924 2474-2527 /? I / [Gralloc]:alloc succ handle [0x55a2081780] stride [720]   12-21 22:38:50.925 2474-2949 /? I / [Gralloc]:分配w [720] h [1280]格式[1]用法[3842]   12-21 22:38:50.928 2474-2949 /? I / [Gralloc]:分配succ句柄[0x55a207ba70]步幅[720]   12-21 22:38:50.928 2474-2949 /? I / [Gralloc]:分配w [720] h [1280]格式[1]用法[3842]   12-21 22:38:50.931 2474-2949 /? I / [Gralloc]:alloc succ handle [0x55a207bc40] stride [720]   12-21 22:38:50.931 2474-2949 /? I / [Gralloc]:分配w [720] h [1280]格式[1]用法[3842]   12-21 22:38:50.934 2474-2949 /? I / [Gralloc]:alloc succ handle [0x55a20425f0] stride [720]   12-21 22:38:50.946 4616-4627 /? I / System.out:[/ system / bin / getprop,debug.mapview.gmmserver]   12-21 22:38:50.946 4616-4627 /? I / System.out:null   12-21 22:38:50.946 4616-4627 /? I / System.out:null   12-21 22:38:50.946 4616-4627 /? I / System.out:通过:: className调用:azpr MethodName:a   12-21 22:38:50.974 23354-23354 / charalampos.walker I / Babis地图:mapready start   12-21 22:38:51.032 23354-23354 / charalampos.walker I / Babis地图:onCreate end

我最近不得不重新安装AS,不得不清理并重建项目。这可能会影响应用程序,Map键或其他什么?

0 个答案:

没有答案
相关问题