У меня есть проект карты Google Android API v2, но я запустить этот проект в моем телефоне LogCat имеет ошибкуI Have Ошибка карта Google Android API v2 не загружен
Falied к нагрузке map.Error обращаясь к серверам Google. Это вероятно, проблема аутентификации (но может быть из-за ошибок в сети)
так что мой код здесь
в классе HomeActivity
package com.mpa.emvi;
import com.mpa.emvi.R;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import android.os.Bundle;
//import android.app.Activity;
import android.view.Menu;
public class HomeActivity extends FragmentActivity {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
setUpMapIfNeeded();
}
@Override
protected void onResume() {
super.onResume();
setUpMapIfNeeded();
}
private void setUpMapIfNeeded() {
// Do a null check to confirm that we have not already instantiated the map.
if (mMap == null) {
// Try to obtain the map from the SupportMapFragment.
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();
// Check if we were successful in obtaining the map.
if (mMap != null) {
setUpMap();
}
}
}
private void setUpMap() {
mMap.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker"));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.home, menu);
return true;
}
}
это макет HomeActivity
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/send"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".HomeActivity" >
<fragment xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"/>
<Button
android:id="@+id/sendDS"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/map"
android:layout_centerHorizontal="true"
android:text="@string/send_destination"/>
</RelativeLayout>
И это файл манифеста
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mpa.emvi"
android:versionCode="2"
android:versionName="2.1.0">
<permission
android:name="com.mpa.emvi.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.mpa.emvi.permission.MAPS_RECEIVE"/>
<!-- Copied from Google Maps Library/AndroidManifest.xml. -->
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="14"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- External storage for caching. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!-- My Location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<!-- Maps API needs OpenGL ES 2.0. -->
<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="com.mpa.emvi.HomeActivity"
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.maps.v2.API_KEY"
android:value="My-Release-API-KEY"/>
</application>
</manifest>
Вы видите мой код. Что ты думаешь? Хорошо, я пытаюсь разобраться с тем же вопросом в этом, и я пытаюсь перегенерировать новый ключ api, но не работает. В моем проекте aleady импортирует сервис google и поддержку android v4. В консоли Google я открываю сервис google map android api v2. В приложениях Google для Google Android: my-SHA1-serials; com.mpa.emvi
OK a lasting Я новичок программист для Android и сожалею, что мой английский плохой.
Благодарим за каждый ответ.
Проверьте, есть ли у вас карты Google для Android в консоли google api – Raghunandan
Да, я уже разрешаю google map android api v2. –
проверьте, правильно ли вы указали проект библиотеки google play services в своем проекте карты. – Raghunandan