0

I am trying to use a TabLayout in an Android project using Eclipse and Andmore but haven't been able to find a jar containing the required android.support.design.widget.TabLayout class.

Googling a bit, it seems I need the com.android.support:design:22.2.0 library. However, the latest version I can find in my SDK installation (under extras/android/support) is v17.

Where can I find this library (without having to migrate to Android Studio)?

user149408
  • 5,385
  • 4
  • 33
  • 69

3 Answers3

0

Update your sdk using sdk manager.

Amit
  • 3,422
  • 3
  • 28
  • 39
  • That was the first thing I tried. Finding the libraries was the issue – as well as the rather lengthy process of installing them. – user149408 Apr 12 '16 at 14:46
0

With the help of a few other answers I finally managed to import everything. Putting it all together, just copyiing the jar into libs will not be sufficient. Here's how it works in Andmore (ADT should be similar but some options apparently differ):

  • Make sure your SDK is up to date. Specifically, you want the latest version of Extras > Android Support Library (should be version 22 or higher) and a matching version of Tools > Android SDK Build-tools.
  • If you have a copy of android-support-v4.jar in the libs folder of your app's source tree, replace it with a recent copy from <sdk>/extras/android/support/v7/appcompat/libs. (If you have other Android support JARs in that location, you may need to update those as well.)
  • Copy <sdk>/extras/android/support/v7/appcompat and <sdk>/extras/android/support/design into your workspace folder. (Not really necessary, but using a local copy will prevent polluting your SDK setup with Eclipse-generated files.
  • Select File > New... > Android Project.
  • Select Create project from existing source and select your copy of the appcompat folder. Be sure to select at least API 22 as a build target (I needed to use API 23, YMMV), and don't forget to give it a meaningful name.
  • When import has finished, open the properties of the new project, go to Android and check Is Library.
  • Repeat the same two steps to import the design library. After import, in its project properties, go to Android, and in Libraries add a reference to the appcompat project.
  • Open the properties of your app project, go to Android, and in Libraries add a reference to the design project.

I had to make some minor modifications to my source code as some resource identifiers are no longer constants as of API 14, requiring me to convert a switch statement to a series of ifs. After that, I could finally build my app.

This should work for other Android libraries as well – their locations are documented in http://developer.android.com/tools/support-library/features.html.

Edit: There may be an easier way: Both ADT and Andmore also have Android Tools > Add Support Library, which might make a few of the aforementioned steps easier, which installs the most recent version of the support library. But you still have to add them to your project by hand.

user149408
  • 5,385
  • 4
  • 33
  • 69
-1

Got it. Everything's there if you update your SDK to the latest version, things are just a bit hidden in the folder tree. You'll need three JARs:

  • extras/android/support/v7/appcompat/libs/android-support-v4.jar (the file was already in my project but I upgraded it anyway – not sure if it was necessary)
  • extras/android/support/v7/appcompat/libs/android-support-v7-appcompat.jar
  • extras/android/support/design/libs/android-support-design.jar

Copy these three to your project's libs dir, refresh your project in Eclipse (cleaning won't hurt as well) and you should be good.

Library locations are documented in http://developer.android.com/tools/support-library/features.html

user149408
  • 5,385
  • 4
  • 33
  • 69
  • 1
    You should add them as Android Library projects. With this method, you do not include the resources which are needed. – Christopher Apr 12 '16 at 12:02
  • 1
    This will be the way to go: http://stackoverflow.com/questions/31430633/how-to-add-android-design-support-library-to-eclipse-with-adt-plugin/31431076#31431076 – Christopher Apr 12 '16 at 12:03
  • Thanks – which of the project types would I select to create the design library project? It says something about "Android Library" but I don't have that as a project type. – user149408 Apr 12 '16 at 12:23
  • You should have this option? Do you have ADT installed? – Christopher Apr 12 '16 at 12:28
  • No, I'm on Andmore. It's a fork of ADT but some things seem to be different. – user149408 Apr 12 '16 at 12:30
  • Hmm, ok. I'm sorry. I do not know this plugin. But nevertheless, I think you would save a lot of time, when switching to Android Studio. – Christopher Apr 12 '16 at 12:39
  • Apparently with Andmore you create an "Android Project" from existing source (make a copy to avoid polluting your SDK setup) and mark it as a library afterwards. The only remaining issue is an error message in `res/values/styles.xml`: `No resource found that matches the given name: attr 'backgroundTint'` – user149408 Apr 12 '16 at 13:06
  • Fixed it – turns out the v7 appcompat library needs to be added in the same manner. – user149408 Apr 12 '16 at 13:36