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.
Related
For developing android applications by using Android Studio, generally we add dependencies in build.gradle instead of adding jars or libraries.
Example given below
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
How can i create own gradle dependency in android studio?
You have to publish your library on JCenter. You can find steps of publishing it on Google.
I am building an SDK for Android that should be exported as an .aar file.
The SDK has a list of dependencies defined in its build.gradle file, for example:
compile 'com.makeramen:roundedimageview:2.2.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.google.android.gms:play-services-ads:9.0.2'
My question is: how do i include these libraries in the .aar, so that it is self-contained and does not require the developer using it to add these libraries when using my SDK?
I have looked everywhere for this, but most answers don't seem to address this issue or don't work.
How do i include these libraries in the .aar
Not at all.
An .aar-file is not intended to contain it's own dependencies
You should use a dependency management system (like maven or ivy) to distribute your SDK in order to handle transitive dependencies.
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.
My AAR includes a picasso library, but in my java code can't find picasso.
Here is my build.gradle:
and here is my multi-image-selector AAR gradle:
Why you not using only
compile 'com.squareup.picasso:picasso:2.5.2'
The aar file doesn't contain the nested dependencies and doesn't have a pom file which describes the dependencies used by the library.
It means that, if you are importing a aar file using a flatDir repo you have to specify the dependencies also in your project.
In your case you have to add in your app (not the library):
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
If you use the gradle maven plugin to deploy the aar to a local repo, then you can get transitive dependencies to work. Here's how to do that:
How to use maven plugin to publish a library as an aar
How to enable transitive dependencies on the library dependency
Assume that you have one app and one library module. In your library module you use Picasso as dependency.
Let me explain step by step, with possible scenarios.
1- If you add your library module to your app module as the following :
implementation(project(":myLibrary"))
Your library works correctly.
2- If you add your library module to your app module as the following :
implementation files('../libs/mainLibrary-debug.aar')
You may get a crash if you don't put Picasso dependency to your app module. You have two options to get rid of this crash.
2.a.First option is to add Picasso library to your app module.
2.b.The second option is to compile you aar using any fat aar plugin. If you use a fat aar plugin, when you generate aar, it automatically downloads Picasso library and put it in aar. In this way, you don't need to add Picasso dependency into your app module. There are several fat aar plugins available, here is one of them : https://github.com/kezong/fat-aar-android
I'm unable to get the YouTubePlayerSupportFragment correctly compiled into my project. I've reviewed this post and this post and have implemented the suggestions there, but still no luck.
Here is what I have tried so far: I have the YouTube API saved in my libs folder. The dependencies section of my gradle file looks like this. You can see that I've tried to include the library using gradle. Whether I comment this line out or not (and sync, of course), I still have the same result.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.google.dagger:dagger:2.0.1'
apt 'com.google.dagger:dagger-compiler:2.0.1'
provided 'org.glassfish:javax.annotation:10.0-b28'
compile 'commons-codec:commons-codec:1.10'
compile 'org.apache.commons:commons-io:1.3.2'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'
compile 'joda-time:joda-time:2.8.2'
compile 'com.google.android.gms:play-services:7.8.0'
// compile 'com.google.apis:google-api-services-youtube:v3-rev149-1.20.0'
}
Here is a screenshot to show how I have the YouTube API saved in the libs folder.
I followed the instructions from the Google Developers guide to download the zip file and understand which jars needed to be copied over. These instructions include the following:
Dependencies for all Platforms
The following are the jars from the libs folder required for
applications on all platforms: google-api-client-1.20.0.jar
google-oauth-client-1.20.0.jar google-http-client-1.20.0.jar
jsr305-1.3.9.jar google-http-client-gson-1.20.0.jar (when using GSON)
gson-2.1.jar google-http-client-jackson2-1.20.0.jar (when using
Jackson 2) jackson-core-$2.1.3.jar google-http-client-jdo-1.20.0.jar
(when using JDO) jdo2-api-2.3-eb.jar Android Dependencies
The following are the jars from the libs folder required for android
applications or a newer compatible version of each dependency:
google-api-client-android-1.20.0.jar (for SDK >= 2.1)
google-http-client-android-1.20.0.jar
Finally, I looked at the project structure, and it looks great here:
So why doesn't this thing resolve to a type? I'm completely at a loss. Thanks for any advice.
You have included the wrong YouTube SDK.
YouTubePlayerSupportFragment is part of the YouTube Player API package, that you can find here: https://developers.google.com/youtube/android/player/
Just download the JAR archive, put it in your 'libs' folder, and you'll be good to go.