I am following this link, as mentioned in the link I am trying to add recycle view as follows:
<android.support.v7.widget.RecyclerView
android:id="#+id/my_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" />
I have added android-support-v7-appcompat library project and also tried adding recyclerview-v7-21.0.0-rc1.aar to libs but still I am getting following error.
The following classes could not be found:
- android.support.v7.widget.RecyclerView
Note: I have updated Android SDK Tools, Android SDK Platform Tools, Android SDK Build Tools, Android L (API 20, L Preview)
please help..
You can't add the aar file to libs folder in Eclipse (it isn't a jar file)
The best way to work with the new RecyclerView is, currently, to switch to Android Studio and add this dependency to your build.gradle
compile 'com.android.support:recyclerview-v7:+'
Just a note. It is not a good practice to use the '+' placeholder, but in this case you are trying a preview release, so it will be update soon with stable release.
You can use one of these versions.
Check your sdk for updated version:
//it requires compileSdkVersion 23
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.android.support:recyclerview-v7:23.2.1'
compile 'com.android.support:recyclerview-v7:23.2.0'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.0'
//it requires compileSdkVersion 22
compile 'com.android.support:recyclerview-v7:22.2.1'
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'com.android.support:recyclerview-v7:22.1.1'
compile 'com.android.support:recyclerview-v7:22.1.0'
compile 'com.android.support:recyclerview-v7:22.0.0'
//it requires compileSdkVersion 21
compile 'com.android.support:recyclerview-v7:21.0.3'
compile 'com.android.support:recyclerview-v7:21.0.2'
compile 'com.android.support:recyclerview-v7:21.0.0'
Of course you can still use Eclipse but it will requires some manual operations.
You can find all the release of the support libraries library in this folder:
sdk/extras/android/m2repository/com/android/support/
Here you can check all version.
In the folders you will find the aar file of the support libraries.
Inside you can check the classes.jar file,the res folder and the AndroidManifest file.
Create a project in your workspace
Unzip the AAR into some directory.
Copy the AndroidManifest.xml, the res, and assets folders from the AAR into your project.
Create a libs directory in your project and copy into it the classes.jar
Add the dependency.
Use the SDK 23 to compile
Mark the project as a library
The Recyclerview library has the support-v4.jar and the support-annotations-23.x.X.jar as dependencies.
ECLIPSE
If your problem is not solved or for future readers , here is the answer: From android sdk manager download Android Support Library first.
Go to this location and copy .aar file from here
X:\android-sdk\extras\android\m2repository\com\android\support\recyclerview-v7\21.0.0
Then rename it as .zip file then unZIP it then find classes.jar file , rename it with some proper name like 'RecyclerView_v7.jar' Then copy the that .jar file in you project library. Add it to build path then restart eclipse so that it can be instantiated (not necessary but i had to do this).
**=================================Update=======================**
After new Library Updates; RecyclerView,CardView etc are available as simple library projects.! :)
File~>Import~>Existing Android Code~>SDKpath~>extras~>android~>support~>
v7~>recyclerView.
Then right click on this project , go to properties under Android check Is Library. It is done ..!
Now open your app in which you want to use recyclerView.
goto properties of your app Project under Android add Library here you will find that Library project add that (remember don't make your app a library project by checking 'Is Library'), now go to your App Project's
Properties~>Java Build Path~>Libraries~>Add Jars~>RecyclerView LibraryProject~>libs
Then add that jar into your project and buildpath .! Pheeew.. :)
Related
I know that in order to get the latest version of Android/Google libraries, I can always go to the Android SDK Manager and update the Android Support Repository / Google Repository.
How about to update the other dependency libraries, such as the "commons-net:commons-net:20030805.205232" from Apache collection libraries? Since it is able to add these libraries from a Module's dependencies, I assume there should be a way to update it within the Android Studio IDE, but so far all the solutions I found is to download the specific .jar and put in the libs directory.
Just curious if anyone know there is a way to update these libraries from within the Android Studio IDE like the Android/Google dependencies.
Android Studio & IntelliJ have a dependency setting window themselves. Though, it does not have a "update" feature as the SDK Manager does. Reason being: Updating a library can cause bugs, errors, or complete crashes in your app.
so far all the solutions I found is to download the specific .jar and put in the libs directory
Not sure where you read that... Remote Gradle dependencies are preferred in most cases.
such as the "commons-net:commons-net:20030805.205232"
Go find what you want in Maven Central, find the most recent version, click the "Gradle" tab, the copy that into your build.gradle section.
There is no automated process for this, as far as I know, though you should be able to auto-complete version numbers via the IDE while you type it out.
When you create a project under Android Studio, it generates for your gradle files which let you use dependencies. Gradle is like maven, you can find lot of documents on google.
Under "Project" tab -> Gradle Scripts -> build.gradle (Module app), you'll find something like this :
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.journeyapps:zxing-android-embedded:3.0.2#aar'
compile 'com.android.support:support-v13:23.4.0'
compile 'com.google.zxing:core:3.2.0'
compile 'com.android.support:support-v4:23.4.0'}
So you just have to put your dependencies and gradle will download them for you.
More here.
I want to import the library https://github.com/jpardogo/FlabbyListView
First, I download the Zip file, then I extract it then I copy it to the lib folder of my project, then I turn on my project in Android Stduio. I add this line in the build.gradle compile 'com.jpardogo.flabbylistview:library:(latest version)'. But the Android Studio show:
How can I fix it?
You are mixing two concepts. If you use the compile dependency you don't have to put the jar in libs, and if you put the jar, don't put the managed dependency.
What the line compile library:artifact:version does is putting in your classpath in compile time the corresponding library, downloading it for you from a maven repository.
That said, I suggest you to remove the .jar and change your line of compile to:
compile 'com.jpardogo.flabbylistview:library:1.0.0
if you are manually adding the library to android. then you will add it to you project also.
In you settings.gradle file for the project add
include ':nameoflibrary'
or
include 'lib:nameoflibrary'
Where lib is the name of the folder you added the library and nameoflibrary is the actual name of the library.
then in you actual module usually the app-module gradle file add
dependencies {
compile project(':nameoflibrary')
}
or
dependencies {
compile project('lib:nameoflibrary')
}
same analogy too.
But if you are adding it from the repository you only need to add this line of code in your app-module gradle
dependencies {
compile 'com.jpardogo.flabbylistview:library:(latest version)'
}
I don't have the exact coding (at the moment since I'm not back in my room) I used in my project but I believe what I did was add all of the libraries necessary to Unirest.io as well as importing the jar file (after putting it into my lib folder) they have available here:
http://oss.sonatype.org/content/repositories/releases/com/mashape/unirest/unirest-java/1.4.5/unirest-java-1.4.5.jar
In the dependencies portion I added something like this:
compile 'org.json:json:20140107'
compile 'org.apache.httpcomponents:httpclient:3.6'
compile 'org.apahe.httpcomponents:httpasyncclient:4.0.2'
compile 'org.apache.httpcomponents:httpmime:4.3.6'
into the dependencies {} portion of the build.gradle file along with the Unirest jar in the lib folder.
I have just downloaded Android Studio 1.0.1 and this is the new project structure
and when i see it in the explorer there is a empty libs folder
i want to import 3 external libraries i have, which i want to use.
build.gradle has already defined this
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
but when i copy my libraries in libs folder my project still dont recognize it,
how do i make use of the libs folder and copy my libraries in this folders and use it?
any help?
Edit:
it was a simple question, how to add libraries to project in Android Studio
like we do in eclipse, for eg i have a library project(a folder, not a jar!).
in my case i have a library project 'viewPagerIndicator' (again a Library folder, not a jar!) i have to add it to my project like i use to do it with eclipse by importing project, right click->properties->android->Library->add-> select the library project
PS: i have found the answer now.
suppose my library project name is 'viewPagerIndicator'
- Copy library project on root of my Android Studio Project
- Under build.gradle(under your Android Studio Project folder) write this under dependencies
compile project(':viewPagerIndicator')
- include it in settings.gradle, write:
include ':viewPagerIndicator'
- Sync project with gradle files
this is how project structure look like now:
so sorry that admins stopping the question without understanding it.
First you have to add library project (module) in Android Studio
File -> Import Module
To add library project (module) in build path, click
File -> Project Structure
On the left hand side click on
app -> Dependencies tab -> green + button -> Module dependency
Now select the library project you already added.
For more details refer this link
In My Case to add external library project into android studio 1.1.0
step-1 : File -> Import Module -> set path for library project
step-2 : Set dependencies{} in main projects's build.gradle like,
dependencies {
compile project(':facebookSDK')
compile project(':slidingMenu')
compile project(':SkyconsLibrary')
}
I have a problem when adding Caldroid library on Android Studio. I try many different ways to add but it won't work. I use Android Studio 0.8.2.
First off, I created a root folder called libraries.
I created a new folder caldroid in /libraries.
Then, I pasted the downloaded files in /libraries folder.
Then, I changed the following files.
settings.gradle
include ':app'
include 'libraries:caldroid:library'
build.gradle
dependencies {
compile 'com.android.support:appcompat-v7:20.+'
compile 'com.google.android.gms:play-services:4.0.30'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':libraries:caldroid:library')
}
But I get this error:
Error:Configuration with name 'default' not found.
How to fix this?
I'm late but I faced a similar issue so I thought I'll share how I solved it.
To import an external library to Android Studio, I follow this convention:
Create libs folder inside the app directory. Then copy the required library files to the libs folder. For example, my folder contains actionbarsherlock and caldroid folders.
Caldroid has a library dependency that can be downloaded here, you can see this in the build.gradle file (Also, make sure the gradle files have the correct SDK versions). Download the hirondelle-date4j-1.5.1-sources.jar.
Create libs folder in app/libs/caldroid/. Copy the hirondelle-date4j-1.5.1-sources.jar to app/libs/caldroid/libs/. You may also have to copy android-support-v4.jar from -User_Home-/Android/Sdk/extras/android/support/v4/ to app/libs/caldroid/libs/.
Open app/libs/caldroid/build.gradle and replace compile 'com.darwinsys:hirondelle-date4j:1.5.1' with compile files('libs/hirondelle-date4j-1.5.1-sources.jar').
In Android Studio, open settings.gradle and add this line include ':app:libs:caldroid'. Next, open "build.gradle (Module: app)" and add this line compile project(':app:libs:caldroid') in dependencies.
And that's it, now allow the gradle to "sync" or clean and build your project.
Add this line in your dependencies in build.gradle
compile 'com.roomorama:caldroid:3.0.1'