how to add android native libraries into one aar - android

I am creating private Sdk for enduser.I face some problems in my project.
Add multiple aar/libraries into one aar file.
Add native libraries like appcompactv7, RecyclerView etc.. into final aar.
Some jar file into lib folder.
For Example:
Library project1:lib1
Library project2:lib2 -> lib2 have 2 jar file (okhhttp,retrofit)
My First Lib1 build.gradle structure:
compile 'some_library_hosted_on_maven'
My Second Lib2 build structure:
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:recyclerview-v7:23.2.0'
compile 'com.android.support:support-annotations:23.2.0'
compile 'com.android.support:design:23.2.0'
compile project(':lib1')
Now I want to deploy/upload only one aar file for end user.
for creating one aar file I already go thorough fat-aar.gradle. But i can't resolve my problem. Kindly help if anyone face or experience this issue. Thanks in Advance.

Related

How to add other libraries as dependencies to my AAR project?

AllInOneProject
|
GameFolder lib(aar)
|
swipeawayDialog lib
Toasty lib
I have allInOne project which contains my GameFolder library. Also my GameFolder library contains lots of libraries.
compile 'com.labo.kaji:swipeawaydialog:0.1.1'
compile 'com.github.GrenderG:Toasty:1.2.5'
compile 'com.github.zurche:plain-pie:v0.1.1'
compile 'pl.bclogic:pulsator4droid:1.0.3'
compile 'com.android.support:multidex:1.0.1'
compile 'com.facebook.stetho:stetho:1.4.2'
compile 'com.github.rubensousa:bottomsheetbuilder:1.6.0'
I dont want to add these libraries to my AllInOne project. Also if its possible , i dont want to download and add locally to my GameFolder library too.
Is there any way to add dependencies to AAR file ?
You would have to create a "fat AAR" one way or another. If you are distributing your library with Maven, you could also add the dependencies information to your configuration file and they would be fetched on demand when building a project with your library.

Get the issue with import external library in Android Studio

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)'
}

Does anyone have an example of an android studio project that import Unirest via gradle?

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.

How to add recycle view in layout xml

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.. :)

Add Caldroid library in Android Studio

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'

Categories

Resources