Hmm,
also ich geh mal alles Schritt für Schritt nochmal durch:
1. Eclipse Rechtsklick Import > Existing Android Code Into Workspace
2. <android.sdk.path>/extras/google/google_play_services/libproject > Öffnen > Finish
3. Neues Android Projekt erzeugen
3. Rechtsklick drauf > Properties > Android > Library Add ... > google-play-services_lib
4. Manifest ergänzen
<permission
android:name="com.example.mapdemo.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.mapdemo.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" />
Alles anzeigen
5. SHA1 holen
cd && keytool -list -v -alias androiddebugkey -keystore .android/debug.keystore -storepass android -keypass android
6. https://code.google.com/apis/console an browsen > Services > Google Maps Android API v2 auf ON
7. API Access > Create new Android Key > SHA1;my.package.name
8. API Key kopieren und ins AndroidManifest eintragen (innerhalb von <application></application>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my_api_key" />
9. fragment meinem Layout hinzufügen
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/hello_world" />
10. MainActivity anpassen
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
public class MainActivity extends Activity {
public static final int REQUEST_CODE = 123;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
protected void onResume() {
super.onResume();
checkPlayServices();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_CANCELED) {
Toast.makeText(this, R.string.message_canceled, Toast.LENGTH_LONG)
.show();
}
}
private void checkPlayServices() {
int code = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (code != ConnectionResult.SUCCESS) {
showErrorDialog(code);
}
}
private void showErrorDialog(int code) {
GooglePlayServicesUtil.getErrorDialog(code, this,
MainActivity.REQUEST_CODE).show();
}
}
Alles anzeigen
11. LogCat Output
Füge ich später hinzu, der knecht erkennt grad kein Handy mehr -.- adb kill-server && adb start-server hilft nix ... super *seufz*
Gruß,
matze
EDIT:
Ohman, jetzt gehts ... was zur Hölle
(PS: die letzten 2 Edits wegen den switch-cases ... die waren echt unnötig)