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!
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!!!
Als Nächstes: rechte Maustaste > Import… und dann „Existing Projects into Workspace“
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
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.
Das folgende Bild fasst eigentlich die Situation ganz gut zusammen:
Errors…Errors everywhere…
Ihr bekommt also mindestens eine der folgenden Fehlermeldungen.
[2014-10-26 13:28:11 - android-support-v7-appcompat] Unable to resolve target 'android-19'
[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
[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: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'.
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.
Als Letztes muss man das Projekt noch cleanen und FERTIG!
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.
Für Faule gibt es hier die Projekte… besteht aus dem Support Library Projekt namens „android-support-v7-appcompat“ und einem bereits eingebunden Beispielprojekt.
Copyright © 2014 AxxG – Alexander Gräsel
Danke 🙂 Habe ich lange gesucht!