17

Even after clicking on Add Support Library and choosing version 19, eclipse still can't find android.support.v4.widget.SwipeRefreshLayout. Does anyone know how to get this to work? I am using

<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="19" />

I am working on a mac mavericks computer with Juno.

update: import section

import java.util.Observer;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.TextView;
import android.support.v4.widget.SwipeRefreshLayout;//red underline

Update

By the way, I don't know if this matters: this is an Appengine Connected Android Project, which I build using Google-Eclipse-Plugin

Update 3:

It's looking like the Android Support Library 19.1.0 is not available through the SDK Manager. How else might I obtain it?

Katedral Pillon
  • 14,534
  • 25
  • 99
  • 199
  • show us your import section... maybe you forgot to import the widget. – Phantômaxx Mar 29 '14 at 19:48
  • @Vyger eclipse red underlines my import `import android.support.v4.widget.SwipeRefreshLayout;` I restarted eclipse to no avail. Also when I look on the available list after `android.support.v4.widget.`, sure enough `SwipeRefreshLayout` is not an option. so I must somehow have the wrong support library. – Katedral Pillon Mar 29 '14 at 19:50
  • 3
    Note that `SwipeRefreshLayout` is in v19.1 of the library. Are you sure that is what you added, and not v19.0.1? – CommonsWare Mar 29 '14 at 19:57
  • When I go to `Android Tools > Add Support Library` I click on the one option that is provided: version 19. How do I get something else/more such as v19.0.1? @CommonsWare. Also my libs folder only has the one support library (deleted before adding it to make sure). Also the support library works fine with my Fragments, etc – Katedral Pillon Mar 29 '14 at 20:00
  • @Vyger I have added import section – Katedral Pillon Mar 29 '14 at 20:09
  • Use your SDK Manager and see what version you have downloaded. – CommonsWare Mar 30 '14 at 01:09

9 Answers9

18

It was difficult to update the support library to version 19.1 so i downloaded it manually from https://dl-ssl.google.com/android/repository/support_r19.1.zip and added the jar to my build path manually. works for me. I dont know why the 19 update shows instead of 19.1.0

Michael Obi
  • 526
  • 1
  • 6
  • 17
  • 1
    I tried everything in this thread (as well as others) with no luck. This answer worked instantly. Thanks MYK – echappy May 22 '14 at 15:00
  • 1
    for people (like me) who had trouble adding it to the in eclipse build path, do this: Using Eclipse Create a libs/ directory in the root of your application project. Copy the JAR file from your Android SDK installation directory (e.g., /extras/android/support/v4/android-support-v4.jar) into your application's project libs/ directory. Right click the JAR file and select Build Path > Add to Build Path. – I'm_With_Stupid Jun 18 '14 at 21:19
5

So it turns out the library is in the following location

/android-sdk-macosx/extras/android/m2repository/com/android/support/support-v4/19.1.0

As opposed to the usual

/android-sdk-macosx/extras/android/support

Also I had to restart eclipse and go to Android SDK Manager over and over and over, until the 19.1.0 version shows up.

I hope this saves someone else some trouble.

Katedral Pillon
  • 14,534
  • 25
  • 99
  • 199
3

The SDK Manager update Android Support Library to 19.1.0. But when you use Android Tools > Add Support Library, eclipse update Android Support Library to 19.0. I think this is a bug. Copy Android Support Library 19.1.0 to libs folder manually.

2

It looks as if you don't have the android-support-v4.jar in Java Build Path. Add it from the android-support-v7-appcompat.

user936580
  • 1,223
  • 1
  • 12
  • 19
  • If that were the case, why would `import android.support.v4.app.DialogFragment;` work? It's only failing for `import android.support.v4.widget.SwipeRefreshLayout;` – Katedral Pillon Mar 29 '14 at 22:42
  • I didn't notice that. Are you sure you are using the correct version of the v4? I would remove all libraries from Eclipse and add them again. – user936580 Mar 29 '14 at 23:07
1

For some reason, even though you may include v4 support library or you may have v7-appcompat included in your project, you may not be able to import SwipeRefreshLayout.

You need to make sure that

  • you change the target=android-19 to target=android-22(It should be anything greater that 19) and
  • manually import : import android.support.v4.widget.SwipeRefreshLayout; in your activity which will resolve the import related issue.
Haresh Chaudhary
  • 4,390
  • 1
  • 34
  • 57
0

I had the same problem with old project. But when I create new project, Eclipse can find this import.

tehnolog
  • 1,204
  • 1
  • 11
  • 23
  • What do you mean? Delete project and then create from existing source? This is not the kind of project I can just recreate from scratch. Also it's a Appengine Connected Android Project. – Katedral Pillon Mar 29 '14 at 20:24
  • Try to copy library from new test project to your old project (replace jar-file) – tehnolog Mar 30 '14 at 14:25
0

It's a problem with updating support library from eclipse: https://code.google.com/p/android/issues/detail?id=67991

Just update it by starting Android SDK manager manually and add new v4 lib to your project.

amukhachov
  • 5,822
  • 1
  • 41
  • 60
0

Thanks for tehnolog's tips. Update to 19.1 by follow above link -> create new project and import android.support.v4 library -> simply copy android.support.v4.jar to old project's libs folder, Add To BuildPath. SwipeRefreshLayout will appear :D

dangthaison.91
  • 269
  • 1
  • 5
0

In androidx, add

implementation 'androidx.legacy:legacy-support-v4:1.0.0'

inorder to use SwipeRefreshLayout

user158
  • 12,852
  • 7
  • 62
  • 94