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?
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
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.
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.
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.
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.
I had the same problem with old project. But when I create new project, Eclipse can find this import.
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.
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
In androidx, add
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
inorder to use SwipeRefreshLayout
Related
I updated My Android Support Library Version to 23.1.1?.. But Can't able to find and Import design Library?..
In order to use android design support library, try importing it from your SDK library.
It should be in your_SDK_path/extras/android/support in the folder you can find design, import it as a project in your eclipse and set is as is Library.
Just Refresh, Clean and Build.
You can find your library here inside your SDK
.../sdk/extras/android/support/design/libs
So, import from that, you will get your library.
I was trying to use the snippet from 2nd answer of the following post:
How do you turn off share history when using ShareActionProvider?
Which can be dowloaded from here and after adding ActivityChooserView.java along with other files to my project, I cannot resolve:
import android.support.v7.internal.widget.ListPopupWindow;
Import of android.support.v7.appcompat does not give any errors.
Where can I find android.support.v7.internal.widget.ListPopupWindow class?
I googled it and found nothing :)
I am compiling for android v23 and using appcompat.v7 of the same version.
As you can see here the package name is android.support.v7.widget, so the correct import is:
import android.support.v7.widget.ListPopupWindow;
ListPopupWindow was moved from android.support.v7.internal.widget to android.support.v7.widget in v7 appcompat library v21.0.0.
To fix the issue change the import to the updated one.
I have recently updated a project that makes use of the Android Support Library ( android-support-v4.jar )
I updated the support library by "Android Tools > Add Support Library"
After doing this my project fails to build and the following imports that worked fine previously now error.
import android.support.v4.app.FragmentManager;
import android.support.v4.widget.SearchViewCompat;
import android.support.v4.widget.SearchViewCompat.OnQueryTextListenerCompat;
With errors long the lines of "The import android.support.v4.widget cannot be resolved"
What have I done wrong? how do I get it working again?
Which API are you using? It is best to use the Android SDK Manager in Eclipse(ADT) plugin to download the support libraries.
The Android Support v4 JAR needs to be in the 'libs' folder of your project. Make sure you have the JAR 'copied' in the folder. It is best to manually do it yourself to make sure it is there.
The best way to fix the 'red' import errors in Eclipse is
Ctrl + Shift + O
to automatically import the correct imports.
Please let me know if this helps! I have had problems with Android imports as well.
Regards,
The jar file also needs to be in your build path.
I have imported a project to Eclipse. The version of the API was 15 and it compiled successfully, but I needed 7th because on my phone the OS cannot be updated. After changing the version of the Android API to older one (7th) I can't compile the project, the follwing errors occures:
import android.hardware.usb.UsbConstants;
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbDeviceConnection;
import android.hardware.usb.UsbEndpoint;
import android.hardware.usb.UsbInterface;
import android.hardware.usb.UsbManager;
It says R cannot be resolved to a variable:
setContentView(R.layout.main);
And in main.xml
android:layout_width="match_parent"
it says: String types not allowed (at 'layout_width' with value 'match_parent').
Is it possible to resolve this errors, but still using the old API version?
If you need the USB functionality: No. It exists since API level 12.
You have to compile your project with the latest Android Api.
Project Properties -> Android -> Android 4.0
In the manifest, you can set the
<uses-sdk android:minSdkVersion="7" />
If you are not using any library or new feature, it should work.
Add the Jar of API 15 from platforms folder and include in Android MAnifesh as Android minsdk as 9 and target sdk as 15 then i hope your app will run
Ok i'm just starting to get into Android programming now, and I'm following the android "TabActivity" tutorial: http://developer.android.com/reference/android/app/TabActivity.html.
Everythings working but it can't seem to find some of the support classes, see the code below that is generating the errors.
mTabManager.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple"),
FragmentStackSupport.CountingFragment.class, null);
mTabManager.addTab(mTabHost.newTabSpec("contacts").setIndicator("Contacts"),
LoaderCursorSupport.CursorLoaderListFragment.class, null);
mTabManager.addTab(mTabHost.newTabSpec("custom").setIndicator("Custom"),
LoaderCustomSupport.AppListFragment.class, null);
mTabManager.addTab(mTabHost.newTabSpec("throttle").setIndicator("Throttle"),
LoaderThrottleSupport.ThrottledLoaderListFragment.class,null);
For FragmentStackSupport/LoaderCursorSupport/LoaderCustomSupport/LoaderThrottleSupport, it says for all of them cannot be resolved to a type. I've added the latest support library to a folder in the root directory named "libs" and also coppied it into "C:/Eclipse/v4/" directory. My import files are:
import java.util.HashMap;
import android.R;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.View;
import android.widget.TabHost;
import cowdawg.hello_tab.namespace.R.layout;
import cowdawg.hello_tab.namespace.R.id;
Could someone please offer me some advice on how to solve this, thanks :).
It's probably because the following classes are not part of the standard Android API (or the support library), but only exist in the support demos sample code for demonstration purposes:
FragmentStackSupport.CountingFragment
LoaderCursorSupport.CursorLoaderListFragment
LoaderCustomSupport.AppListFragment
LoaderThrottleSupport.ThrottledLoaderListFragment
You will need to add these classes to your own project in order to be able to use them. Here you can find the source files under the subsection 'Files'.
FragmentStackSupport
LoaderCursorSupport
LoaderCustomSupport
LoaderThrottleSupport
On Eclipse IDE: Select your project and then right click on the project -> Android Tools -> Add Support Library.
Required support library will be added on your project build path. You will found this library jar under Java Build Path -> Libraries tab -> Android Dependencies.
Enjoy exploring!
Have you added the library to your build path? Right click on the jar in eclipse -> Build Path -> Add to Build Path.
Try adding by right clicking on the project and opening properties window
Instead of these missing classes you can create your own by subclassing Fragment class (or its subclasses like DialogFragment, ListFragment etc). More info is provided by Android here.