Asp*_*cas 4 android google-maps android-studio
我正在尝试在我的应用程序上显示地图,但无法显示,这对我来说是不可能的...

构建.gradle
应用插件:'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "prueba.mapas.alvaro.myapplication"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
}
Run Code Online (Sandbox Code Playgroud)
也添加库AndroidManifest.xml。
清单(部分)
<application
......
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
......
</application>
Run Code Online (Sandbox Code Playgroud)



AndroidManifest.xml有权限修改。
<permission
android:name="prueba.mapas.alvaro.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="prueba.mapas.alvaro.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- The following two permissions are not required to use
Google Maps Android API v2, but are recommended. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
//api key
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyD1UolEb1tDMe6qB5BUF5orFzc3CDtvJYg"/>
</application>
Run Code Online (Sandbox Code Playgroud)
创建我的布局 map_activity.xml
创建我的主要课程 MainActivity.class
公共类 MainActivity 扩展了 ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_activity);
MapFragment mapFragment = (MapFragment) getFragmentManager()
.findFragmentById(R.id.map);
}
}
Run Code Online (Sandbox Code Playgroud)连接我的设备,它报告错误并且在我的设备上总是出现白屏。

注意:我总是从我的设备上的应用程序中清除数据,卸载并重新安装,但不起作用
更新
我在控制台上启用了 Google Maps V2

有什么建议?
更新 - 解决方案
解决了,我在 Google API 控制台上显示了“浏览器应用程序的密钥(带引用者)”而不是“Android 应用程序的密钥(带证书)”
| 归档时间: |
|
| 查看次数: |
4532 次 |
| 最近记录: |