【发布时间】:2017-03-24 19:06:11
【问题描述】:
我开发了一个使用 MapActivity 的应用程序。我已经在 Manifest 中关联了一个 API-KEY,并且我正在使用 Gradle 10.2.0 中的地图的 google play 服务 ...
我的问题:
在我的 AVD 和我的真实设备上(带有 Nougat 的 Galaxy s6,Android 7)我可以看到地图并且它正确加载。但是在某些设备上却没有,我不知道为什么?当然,相同的 API 密钥。我正在使用 supportMapFragment。
例如,在这些手机上,地图保持灰色,左下角带有谷歌徽标。
在带有 4.03 和 4.1.1 的 Galaxy s3 中也不起作用。在小米 Mi MAX 上它可以工作。
清单
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ibas.locatixteamviewer">
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
location permissions for the 'MyLocation' functionality.
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
location permissions for the 'MyLocation' functionality.
-->
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<!--
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"></activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:noHistory="true"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ListActivity"
android:label="@string/title_activity_list"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".FahrzeugActivity"
android:label="@string/title_activity_fahrzeug"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".WebActivity"
android:label="@string/title_activity_web"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".ListMapsActivity"
android:label="@string/title_activity_list_maps"></activity>
</application>
activity_maps.xml
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="ibas.locatixteamviewer.MapsActivity">
<!--<Button-->
<!--android:id="@+id/button1"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:background="#359c5e"-->
<!--android:layout_alignParentTop="true"-->
<!--android:layout_alignParentEnd="true"-->
<!--android:padding="8dp"-->
<!--android:layout_margin="5dp"-->
<!--android:src="@drawable/menu_car_side_7_white"-->
<!--android:textColor="#ffffff" />-->
</fragment>
Gradle
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.google.android.gms:play-services-maps:10.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support:recyclerview-v7:25.2.0'
testCompile 'junit:junit:4.12'
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "ibas.locatixteamviewer"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
【问题讨论】:
-
您是否将已安装的 Google Play 服务版本与您的应用使用的版本进行对比?也许它在某些设备上不是最新的
标签: android maps fragment supportmapfragment