Android Support Library v7 AppCompat in Eclipse einbinden

Als Android-/Java-Entwickler hat man es echt nicht leicht, aber dann schaue ich mir Objective-C an und fange laut an zu lachen:D
Spaß beiseite – heute geht es um die Android Support Library, speziell die v7 AppCompat. Diese Library braucht man, um zum Beispiel das Material Design für Apps unter Android 5.0 nutzen zu können. Leider war das Einbinden nicht gerade einfach, aber lest es selbst!

 

Schritt 1: Download und Ort bestimmen

Bevor wir irgendwas einbinden, müssen wir erst einmal die Android Support Library herunterladen und installieren. Außerdem merken wir uns gleich den SDK Pfad!!!
1

 

Schritt 2: Projekt importieren

Als Nächstes: rechte Maustaste > Import… und dann „Existing Projects into Workspace“
2
3
Habt ihr euch den SDK Pfad gemerkt/kopiert? Jetzt braucht ihr ihn. (Siehe root directory)
Der Pfad muss noch um folgende Unterverzeichnisse erweitert werden …extras\android\support\v7
Bei mir lautet also der Pfad D:\Java\sdk\extras\android\support\v7
4
Es sollten jetzt 4 Projekte zusehen sein. Davon haken wir zum Beispiel „android-support-v7-appcompat“ an. Aber Achtung! Bitte beachten, dass auch der Haken „Copy projects into workspace“ angehakt ist.

 

Schritt 3: Fehler beseitigen

errors-everywhereDas folgende Bild fasst eigentlich die Situation ganz gut zusammen:
Errors…Errors everywhere…

 

Ihr bekommt also mindestens eine der folgenden Fehlermeldungen.

  • Fehler: Android SDK 4.4.3 nicht installiert
    [2014-10-26 13:28:11 - android-support-v7-appcompat] Unable to resolve target 'android-19'
  • Fehler: Datei nicht beschreibbar
    [2014-10-26 13:28:11 - android-support-v7-appcompat] WARNING: unable to write jarlist cache file G:\workspace\android-support-v7-appcompat\bin\jarlist.cache
  • Mein absoluter Lieblingsfehler: No resource found that matches
    [2014-10-27 14:58:59 - android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:75: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton'.
    

    Mehr von diesen Meldungen:D:D:D

    [text] [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:75: error: Error retrieving parent for item: No resource found that matches the given name ‚android:Widget.Material.ActionButton‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:79: error: Error retrieving parent for item: No resource found that matches the given name ‚android:Widget.Material.ActionButton.CloseMode‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:83: error: Error retrieving parent for item: No resource found that matches the given name ‚android:Widget.Material.ActionButton.Overflow‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:25: error: Error retrieving parent for item: No resource found that matches the given name ‚android:Widget.Material.ActionBar.TabView‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:29: error: Error retrieving parent for item: No resource found that matches the given name ‚android:Widget.Material.Light.ActionBar.TabView‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:33: error: Error retrieving parent for item: No resource found that matches the given name ‚android:Widget.Material.ActionBar.TabText‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:37: error: Error retrieving parent for item: No resource found that matches the given name ‚android:Widget.Material.Light.ActionBar.TabText‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:41: error: Error retrieving parent for item: No resource found that matches the given name ‚android:Widget.Material.Light.ActionBar.TabText‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:65: error: Error retrieving parent for item: No resource found that matches the given name ‚android:TextAppearance.Material.Widget.ActionMode.Title‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:69: error: Error retrieving parent for item: No resource found that matches the given name ‚android:TextAppearance.Material.Widget.ActionMode.Subtitle‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:45: error: Error retrieving parent for item: No resource found that matches the given name ‚android:TextAppearance.Material.Widget.ActionBar.Menu‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:49: error: Error retrieving parent for item: No resource found that matches the given name ‚android:TextAppearance.Material.Widget.ActionBar.Title‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:53: error: Error retrieving parent for item: No resource found that matches the given name ‚android:TextAppearance.Material.Widget.ActionBar.Subtitle‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:57: error: Error retrieving parent for item: No resource found that matches the given name ‚android:TextAppearance.Material.Widget.ActionBar.Title.Inverse‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:61: error: Error retrieving parent for item: No resource found that matches the given name ‚android:TextAppearance.Material.Widget.ActionBar.Subtitle.Inverse‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:178: error: Error retrieving parent for item: No resource found that matches the given name ‚android:Widget.Material.ProgressBar.Horizontal‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:182: error: Error retrieving parent for item: No resource found that matches the given name ‚android:Widget.Material.ProgressBar‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:113: error: Error retrieving parent for item: No resource found that matches the given name ‚android:Widget.Material.Spinner‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:115: error: Error retrieving parent for item: No resource found that matches the given name ‚android:Widget.Material.Spinner‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:110: error: Error retrieving parent for item: No resource found that matches the given name ‚android:Widget.Material.DropDownItem.Spinner‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:107: error: Error retrieving parent for item: No resource found that matches the given name ‚android:Widget.Material.ListView.DropDown‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:121: error: Error retrieving parent for item: No resource found that matches the given name ‚android:Widget.Material.ListView‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:126: error: Error retrieving parent for item: No resource found that matches the given name ‚android:Widget.Material.ListPopupWindow‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:138: error: Error: No resource found that matches the given name: attr ‚android:overlapAnchor‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:129: error: Error retrieving parent for item: No resource found that matches the given name ‚android:Widget.Material.PopupMenu‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:132: error: Error retrieving parent for item: No resource found that matches the given name ‚android:Widget.Material.Light.PopupMenu‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:146: error: Error retrieving parent for item: No resource found that matches the given name ‚android:TextAppearance.Material.Widget.PopupMenu.Large‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:150: error: Error retrieving parent for item: No resource found that matches the given name ‚android:TextAppearance.Material.Widget.PopupMenu.Small‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:154: error: Error retrieving parent for item: No resource found that matches the given name ‚android:TextAppearance.Material.Widget.PopupMenu.Large‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:158: error: Error retrieving parent for item: No resource found that matches the given name ‚android:TextAppearance.Material.Widget.PopupMenu.Small‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:164: error: Error retrieving parent for item: No resource found that matches the given name ‚@android:TextAppearance.Material.SearchResult.Title‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:168: error: Error retrieving parent for item: No resource found that matches the given name ‚@android:TextAppearance.Material.SearchResult.Subtitle‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:172: error: Error retrieving parent for item: No resource found that matches the given name ‚android:Widget.Material.AutoCompleteTextView‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:174: error: Error retrieving parent for item: No resource found that matches the given name ‚android:Widget.Material.AutoCompleteTextView‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:93: error: Error retrieving parent for item: No resource found that matches the given name ‚android:Widget.Material.Toolbar.Button.Navigation‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:97: error: Error retrieving parent for item: No resource found that matches the given name ‚android:TextAppearance.Material.Widget.ActionBar.Title‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base.xml:101: error: Error retrieving parent for item: No resource found that matches the given name ‚android:TextAppearance.Material.Widget.ActionBar.Subtitle‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base_text.xml:62: error: Error retrieving parent for item: No resource found that matches the given name ‚android:TextAppearance.Material.Button‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\styles_base_text.xml:20: error: Error retrieving parent for item: No resource found that matches the given name ‚android:TextAppearance.Material‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\themes_base.xml:193: error: Error: No resource found that matches the given name: attr ‚android:colorControlNormal‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\themes_base.xml:190: error: Error: No resource found that matches the given name: attr ‚android:colorPrimary‘. [2014-10-27 14:58:59 – android-support-v7-appcompat] G:\workspace\android-support-v7-appcompat\res\values-v21\themes_base.xml:191: error: Error: No resource found that matches the given name: attr ‚android:colorPrimaryDark‘. [/text]

und nun kommt die Lösung für all diese Probleme….

Project Build Target:

Android 5.0/ API V21

Nachdem ich stundenlang gesucht habe und schon an meinem Verstand gezweifelt habe, ist die Lösung doch so einfach. Die Freunde bei Google Inc. haben ein falsches Build Target ausgewählt! Stellt man also das importiere Projekt auf Android 5.0 um, ist alles gut:)
(Bitte beachten, dass die App, trotz dem Build Target 5.0, immer noch unter Android 2.x oder Android 4.x läuft!)
Einfach rechte Maustaste auf das Projekt und dann „Properties„. Dort auf den Reiter „Android“ und das Project Build Target auf „Android 5.0“ stellen/anhaken.
5
Als Letztes muss man das Projekt noch cleanen und FERTIG!
6

 

Schritt 4: Projekt einbinden

Jetzt sollte man also ein fehlerfreies Projekt namens „android-support-v7-appcompat“ haben. Diesen kann man bei jedem anderen Projekt referenzieren. Wieder rechte Maustaste auf das andere/neue Projekt und dann „Properties„. Dort auf den Reiter „Android“(1) und dann den Zahlen weiter folgen.
7

ABER ACHTUNG!!! Jedes abhängige Projekt muss mindestens mit Android 5.0 kompiliert(Project Build Target) werden!!! SONST kommen die gleichen Fehler wie oben!

 

Download

Für Faule gibt es hier die Projekte… besteht aus dem Support Library Projekt namens „android-support-v7-appcompat“ und einem bereits eingebunden Beispielprojekt.

Android Version 4.0.3, 5.0 Inhalt gepacktes Projekt
Android Support Library Version V7 (Version 21) Größe 2.653 KB (~3 MB)
IDE Eclipse IDE Version 4.2.1 Endung *.zip
Preis kostenlos Lizenz Creative Commons Lizenzvertrag

[download id=“26″ format=“2″]

 

Quellen und weitere Links

 

Copyright © 2014 AxxG – Alexander Gräsel




1 Antwort : “Android Support Library v7 AppCompat in Eclipse einbinden”

  1. marcmaurer00 sagt:

    Danke 🙂 Habe ich lange gesucht!

Trackbacks/Pingbacks

  1. Android: SwitchCompat verwenden | AxxG Blog - […] Um eine SwitchCompat-Komponente im Layout nutzen zukönnen, muss man nur den Pfad zur Klasse vollständig angeben. Außerdem brauch man…
  2. [android] android-support-v7-appcompat on PRJ for 4.1 (SDK16) | PipisCrew Official Homepage - […] Android Support Library v7 AppCompat in Eclipse einbinden […]
  3. android - java.lang.NoSuchFieldError android/support/v7/AppCompat/ - […] , y la importación de appcompat de gradle o por favor, lea wptrafficanalyzer.en/blog/… blog.axxg.de/… He echado un vistazo a…

Schreibe eine Antwort zu marcmaurer00Antwort abbrechen

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.