java.lang.noclassdeffounderror: com.google.android.gms.R $ styleable
Ich bin erstellen einer android-Anwendung mit google maps. hier ist der code:
MapFragActivity.java
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
public class MapFragActivity extends FragmentActivity {
private GoogleMap map;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map_frag);
map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();
}
}
AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.him.mapfrag_rnd"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="15" />
<permission
android:name="com.him.mapfrag_rnd.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.him.mapfrag_rnd.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MapFragActivity"
android:label="@string/title_activity_map_frag" >
<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_api_key" />
</application>
</manifest>
activity_map_frag.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
wenn ich versuche diesen code bekomme ich einen Fehler, hier der log:
01-17 10:01:17.685: E/AndroidRuntime(8923): FATAL EXCEPTION: main
01-17 10:01:17.685: E/AndroidRuntime(8923): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
01-17 10:01:17.685: E/AndroidRuntime(8923): at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
01-17 10:01:17.685: E/AndroidRuntime(8923): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
01-17 10:01:17.685: E/AndroidRuntime(8923): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:279)
01-17 10:01:17.685: E/AndroidRuntime(8923): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
01-17 10:01:17.685: E/AndroidRuntime(8923): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
01-17 10:01:17.685: E/AndroidRuntime(8923): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
01-17 10:01:17.685: E/AndroidRuntime(8923): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
01-17 10:01:17.685: E/AndroidRuntime(8923): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
01-17 10:01:17.685: E/AndroidRuntime(8923): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:272)
01-17 10:01:17.685: E/AndroidRuntime(8923): at android.app.Activity.setContentView(Activity.java:1835)
01-17 10:01:17.685: E/AndroidRuntime(8923): at com.him.mapfrag_rnd.MapFragActivity.onCreate(MapFragActivity.java:16)
01-17 10:01:17.685: E/AndroidRuntime(8923): at android.app.Activity.performCreate(Activity.java:4470)
01-17 10:01:17.685: E/AndroidRuntime(8923): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052)
01-17 10:01:17.685: E/AndroidRuntime(8923): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931)
01-17 10:01:17.685: E/AndroidRuntime(8923): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
01-17 10:01:17.685: E/AndroidRuntime(8923): at android.app.ActivityThread.access$600(ActivityThread.java:127)
01-17 10:01:17.685: E/AndroidRuntime(8923): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
01-17 10:01:17.685: E/AndroidRuntime(8923): at android.os.Handler.dispatchMessage(Handler.java:99)
01-17 10:01:17.685: E/AndroidRuntime(8923): at android.os.Looper.loop(Looper.java:137)
01-17 10:01:17.685: E/AndroidRuntime(8923): at android.app.ActivityThread.main(ActivityThread.java:4511)
01-17 10:01:17.685: E/AndroidRuntime(8923): at java.lang.reflect.Method.invokeNative(Native Method)
01-17 10:01:17.685: E/AndroidRuntime(8923): at java.lang.reflect.Method.invoke(Method.java:511)
01-17 10:01:17.685: E/AndroidRuntime(8923): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:986)
01-17 10:01:17.685: E/AndroidRuntime(8923): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:753)
01-17 10:01:17.685: E/AndroidRuntime(8923): at dalvik.system.NativeStart.main(Native Method)
wenn ich ein paar änderungen vornehmen MapFragActivity.java dann Karte angezeigt wird. hier sind die änderungen:
package com.him.mapfrag_rnd;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.SupportMapFragment;
public class MapFragActivity extends FragmentActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_map_frag);
SupportMapFragment fragment = new SupportMapFragment();
getSupportFragmentManager().beginTransaction().add(android.R.id.content, fragment).commit();
}
}
Die änderung, die ich gemacht habe, ist, kommentierte der setContentView.
Ich habe die erforderlichen Schritte noch und ich bin immer und Fehler. wenn kommentieren Sie die setContentView (), dann wieder bekomme ich den Fehler.
Bitte um HILFE!!!!
InformationsquelleAutor der Frage Himanshu | 2013-01-17
Du musst angemeldet sein, um einen Kommentar abzugeben.
Was Sie tun müssen, ist Google Play-Dienste-Bibliothek zu Ihrem Projekt. Google hat sehr gute Anleitung hier:
Da gibt es auch eine Kurzanleitung, die ich sehr nützlich beim Versuch, Google Maps v2 zu arbeiten.
InformationsquelleAutor der Antwort Michael
Wenn Sie mit Intellij Idea,
Hinweis: Stellen Sie sicher, dass Sie nicht Hinzugefügt haben, "google-play-services_lib" - Projekt als Bibliothek in "Bibliotheken" (Links unter Module). Wenn Sie haben, können Sie gehen, um "Bibliotheken und einfach entfernen. Google Play Bibliothek Wird Nicht Angezeigt, In Bibliotheken.
Note 2: Sie können kopieren Sie den gesamten google-play-services_lib Verzeichnis zu Ihrem eigenen Projekt, wenn Sie möchten, haben Sie im version control oder ähnlich.
InformationsquelleAutor der Antwort Hesam
Ich denke, Sie haben zum importieren der ganzen Google-Play-Dienst-Bibliothek zu deiner IDE nicht nur die .jar
versuchen 😉
InformationsquelleAutor der Antwort cesards
Ich löste das Problem, indem Sie zuerst die überprüfung der play-services-lib ist korrekt Hinzugefügt und fügen Sie diese Daten in der manifest-Datei unter application-tag
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
InformationsquelleAutor der Antwort vamshi palutla
Ich habe den gleichen Fehler. Ich benutze Android Studio und Gradle es gibt also nicht zu viele Dinge zu konfigurieren oder zu verbessern. Ich habe getan, fast alle Dinge, die aber alle nicht für mich arbeiten. Die letzten arbeiten: ersetzen Sie die gesamte Paket-play-services, die von kleineren. In meinem Fall:
Ersetzen (in build.gradle-Datei):
durch:
InformationsquelleAutor der Antwort Tony
habe ich auch diesen Fehler in android studio und ich hatte bereits im Lieferumfang enthalten-play-services-alpha-3 mit gradle alpha5,
was ich falsch gemacht habe war, ich habe multidex.
in gradle
multiDexEnabled wahr
und in der Application-Klasse ist onCreate
MultiDex.installieren(this);
aber ich vergaß zu erweitert die Application-Klasse mit MultiDexApplication
weil MultiDexApplication ist nicht verlängert worden, so dass es keine gms und alle anderen dex-Klassen, so gibt es Fehler bei starten von gms String.
Hoffe diese hilft
InformationsquelleAutor der Antwort rcb13
Überprüfen AndroidManifest.xml Datei von Ihrem google-play-services_lib Projekt. Sollte sein:
InformationsquelleAutor der Antwort Artem K
Android SDK Manager download "google play-Dienste"
importieren Sie es in Ihrem Arbeitsbereich (Pfad: android-sdk root/extras/google/google_play_service/libproject/google-play-service_lib)
Projekt-Eigenschaften -> android -> Bibliothek hinzufügen google-play-service_lib
Build path -> Um-und Export-check Android private libraries
InformationsquelleAutor der Antwort iceboxi
Löste ich diesen Fehler, indem Sie "Copy projects into workspace " " beim importieren der Google-Play-Services-lib.
Mehr info hier: http://developer.android.com/google/play-services/setup.html
InformationsquelleAutor der Antwort UmbySlipKnot
Ich habe den Link gefolgt
http://www.vogella.com/tutorials/AndroidGoogleMaps/article.html
Hinzugefügt und den google-play-services_lib-Bibliothek-Projekt für meine Anwendung. Es war großartig, bis auf gestern. Aber zu Tag hab ich die Ausnahme oben erwähnt. Es ist wegen der Abwesenheit des google play-Bibliothek oder mein Projekt nicht in der Lage, den Zugriff auf die Dateien aus der Bibliothek. Ich baute mein Projekt, aber es war nicht gelungen. Dann habe ich umgebaut, die google-play-services_lib-Bibliothek-Projekt, aber keine Hoffnung. Dann versuchte ich die "build-all" - option in eclipse und es funktioniert gut.
InformationsquelleAutor der Antwort Arshad
Wenn Sie mit split-Google-Play-Dienste (siehe hier : https://developers.google.com/android/guides/setup#split)
Müssen Sie die Basis play-Dienste, um Ihre gradle-Datei:
Mit slipt Play-Dienste verhindern, dass die 65k Fehler und machen Sie Ihre app kleinere
InformationsquelleAutor der Antwort sonique
Diese zwei google-play-Dienst hinzufügen in den Bau.gradle
Seine arbeitete für mich..
compile 'com.google.android.gms:play-Dienste-appindexing:8.1.0'
compile 'com.google.android.gms:play-Dienste:8.1.0'
InformationsquelleAutor der Antwort Soumen Das