Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to get jar file with android.support.v7.widget.RecyclerView  RSS feed

 
Rancher
Posts: 3163
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am unable to use Android Studio because of an older and smaller PC. When I try to use AS it can take many minutes to start and to do anything.  I have been using Eclipse for years and it works.
But now it appears Google won't allow the download of new libraries with the new classes like: android.support.v7.widget.RecyclerView

Other than buy a new machine, is there a way to get the support library for android.support.v7.widget.RecyclerView?
 
Saloon Keeper
Posts: 1692
68
Android Chrome IntelliJ IDE Java MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which build system are you using?
If you are using Gradle then you could do something like the following:
 
Pete Letkeman
Saloon Keeper
Posts: 1692
68
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wait a minute...In AS Gradle runs in the background when and when you change the build, files are downloaded automatically.
I wonder if it could be a matter of downloading the files from a Google Android Repo?
 
Norm Radder
Rancher
Posts: 3163
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

If you are using Gradle


I don't think I am using Gradle.  I use Eclipse/Juno
 
Pete Letkeman
Saloon Keeper
Posts: 1692
68
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What about using this https://dl.google.com/dl/android/maven2/master-index.xml as a source for your Maven build system.
I have not use Eclipse in a few years and I do not not too much about Maven, but I think that you may be able to use that repository.

Google also supplied this link https://dl.google.com/dl/android/maven2/index.html from this page
https://developer.android.com/studio/build/dependencies.html#google-maven which may help you out.
 
Norm Radder
Rancher
Posts: 3163
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for trying.  I also do not use Maven. 

Looking the links you provided I don't see any reference to the android-support-v7-appcompat.jar file that I need to get a newer version of.
 
Pete Letkeman
Saloon Keeper
Posts: 1692
68
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you see this

https://developer.android.com/studio/build/dependencies.html#gmaven-access wrote:Programmatic access
For programmatic access to Google's Maven artifacts, you can get an XML list of artifact groups from maven.google.com/master-index.xml. Then, for any group, you can view its library names and versions at:

maven.google.com/group_path/group-index.xml

For example, libraries in the android.arch.lifecycle group are listed at maven.google.com/android/arch/lifecycle/group-index.xml.

You can also download the POM and JAR files at:

maven.google.com/group_path/library/version/library-version.ext

For example: maven.google.com/android/arch/lifecycle/compiler/1.0.0/compiler-1.0.0.pom.


They say that you can download the JAR file, you just need to know the path to the file.
 
Norm Radder
Rancher
Posts: 3163
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

you just need to know the path to the file


That is often true.  I've been to many sites in the last hour and have not found it yet.

I get Error 404 for several of the posted links.
 
Pete Letkeman
Saloon Keeper
Posts: 1692
68
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Norm Radder wrote:I get Error 404 for several of the posted links.


From the links that I have provided in the last few posts or from the links that you have tried over the last hour or two?
 
Pete Letkeman
Saloon Keeper
Posts: 1692
68
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Almost there
https://maven.google.com/com/android/support/recyclerview-v7/26.1.0/recyclerview-v7-26.1.0.aar
or
https://maven.google.com/com/android/support/recyclerview-v7/27.0.0/recyclerview-v7-27.0.0.aar
download and rename the .aar to .jar.

I do not know which version you said that you wanted.
I suspect now that you see the pattern you can download the one you want along with other files if needed
 
Norm Radder
Rancher
Posts: 3163
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
2 steps forward - found RecyclerView class
1 step backwards - problem with  Cannot find the class file for android.support.v4.view.NestedScrollingChild2

How did you get those paths to the aar files?
 
Pete Letkeman
Saloon Keeper
Posts: 1692
68
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I'm not too sure. I guess you are going to have to fight with repo as noted here
https://developer.android.com/studio/build/dependencies.html#gmaven-access

Does this file have what you need?
https://maven.google.com/com/android/support/support-v4/26.0.2/support-v4-26.0.2.aar

My trick:
Google using the following
site:maven.google.com android.support.v4
site:maven.google.com RecyclerView


But you need to know where the package is located and I would have suspected that NestedScrolling is located in android.support.v4, but maybe not
 
Norm Radder
Rancher
Posts: 3163
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got a version of a library from version 25 (NestedScrollingChild2   added in version 26.1.0 ) and it now compiles and executes and fails for
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/appcompat/R$styleable

Something for tomorrow.

Thanks for all your help.
 
Pete Letkeman
Saloon Keeper
Posts: 1692
68
Android Chrome IntelliJ IDE Java MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are welcome and at least you are making progress.

Please remember that it is not suggested that you mix different versions of Android libraries.
I suspect that you should either use version 25 or version 26.1.0 but not both at the same time.
 
Norm Radder
Rancher
Posts: 3163
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you determine a library's version by looking at its contents?

Or do you need to be careful when renaming the classes.jar files?
 
Pete Letkeman
Saloon Keeper
Posts: 1692
68
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Norm Radder wrote:Can you determine a library's version by looking at its contents?


I think so, support-v4-26.0.2.jar has a file named AndroidManifest.xml.
In AndroidManifest.xml there is the following XML

I suspect that other files have the same XML file with a corresponding value for which version they are.
 
Norm Radder
Rancher
Posts: 3163
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found there was a .version file in the META-INF folder in some of the classes.jar file that was in the aar file that had a String like: 27.0.0
It wasn't in all of them
 
Pete Letkeman
Saloon Keeper
Posts: 1692
68
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting, I wonder what the reasoning is for including/excluding that file is.
And no you cannot count on AndroidManifest.xml for showing you which version the jar or class is.
 
Pete Letkeman
Saloon Keeper
Posts: 1692
68
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Problem solved...I think that is at least.
1) Install Gradle, which is really a matter of downloading and extracting a file if you are using Windows 10 as noted here https://coderanch.com/t/689645/gradle/build-tools/install-Gradle-Windows
    You do not need to keep Gradle running in the background or anything like that at all.
2) Create a simple Gradle build file like this
3) From the command line run the following command gradle -b [nameOfBuildFile] copyDependencies
4) Notice a directory named "dependencies" which has this file and it's related dependencies
I'll take credit for Googling, but I will not take credit for the build script, which I got from https://newfivefour.com/gradle-copy-all-dependencies-into-dir.html
 
Norm Radder
Rancher
Posts: 3163
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
I copied that for the gradle input and uncommented the last 2 compile statements and installed gradle (modified .bat file for debugging)
I get this:

D:\Android\_MyStuff\EclipseSupportLibraryProblem>echo on

D:\Android\_MyStuff\EclipseSupportLibraryProblem>D:\gradle-4.5-all\gradle-4.5\bin\gradleTest.bat -b GetLib.gradle copyDependencies

D:\Android\_MyStuff\EclipseSupportLibraryProblem>echo on

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':compile'.
> Could not find android.support.v4:26.1.0:.
  Required by:
      project :
> Could not find android.support.v7:26.1.0:.
  Required by:
      project :

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
1 actionable task: 1 executed


It worked when I restored the comments for the last two compile statements.
 
Pete Letkeman
Saloon Keeper
Posts: 1692
68
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not too sure, maybe you have the dependency named incorrectly.
Please note that I did comment out the following two lines in my previous example
Maybe you do need to set the Windows path variable to include gradle?
You can name the Gradle file anything you want, I named it gradle.build.
In my gralde.build I have this:
From the command line I used this line:
gradle -b gradle.build copyDependencies
If you try with the contents of the file as listed in this post do you get a successful result?
 
Pete Letkeman
Saloon Keeper
Posts: 1692
68
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will get errors when you do not correctly specify the library name.
 
Norm Radder
Rancher
Posts: 3163
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that works as is.  It puts 14 files into the dependencies folder.

Where did you get the names like appcompat and cardview
and the version numbers like v7:26.1.0 ?


Thanks again.

The batch file I use to run gradle:
 
Pete Letkeman
Saloon Keeper
Posts: 1692
68
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Norm Radder wrote:Where did you get the names like appcompat and cardview
and the version numbers like v7:26.1.0 ?


Android Studio, a project I was working on.
But I think that you can get that from https://developer.android.com/reference/packages.html as shown here
https://developer.android.com/reference/android/support/v7/widget/CardView.html in the top right hand corner you see this:

added in version 25.1.0
belongs to Maven artifact com.android.support:cardview-v7:27.0.0
Summary: XML Attrs | Inherited Constants | Inherited Fields | Ctors | Methods | Protected Methods | Inherited



Knowing which each library does it a different matter.
There is also some information in the Android SDK manager as shown in the attached image.
studio64_2018-02-01_09-42-27.png
[Thumbnail for studio64_2018-02-01_09-42-27.png]
 
Norm Radder
Rancher
Posts: 3163
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks again.  The upper right corner has what I'm looking for.
 
Pete Letkeman
Saloon Keeper
Posts: 1692
68
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are most welcome.

After all, we are all in this together and I'm glad I could help.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!