Reputation: 23
My Android project download the maven aar file from others' personal maven,it exists in the directory:
C:\Users\username\.gradle\caches\modules-2\files-2.1
now I want to use the maven file,how can I configure in my project build.gradle
,or in my module build.gradle
.
I have tried many methods to solve the question,including add
repositories{
flatDir{
dirs 'libs'
}
}
dependencies {
compile(name: 'myaarfilename.aar', ext: 'arr')
}
in my modulebuild.gradle
and add
buildscript{
repositories{
jcenter()
mavencentral()
mavenLocal() //to use my local maven aar file
}
}
in my projectbuild.gradle
all of these methods does not work, so how can I use the my maven cache aar file ,or how can I configure maven?Hoping somebody can help me ,thanks a lot.
Upvotes: 1
Views: 4964
Reputation: 363737
My Android project download the maven aar file from others' personal maven,it exists in the directory:
C:\Users\username\.gradle\caches\modules-2\files-2.1
Pay attention because the gradle cache folder is NOT a maven repo.
Then:
buildscript{ repositories{ jcenter() mavencentral() mavenLocal() //to use my local maven aar file } }
You are using the repositories
block inside the buildscript
and it is NOT related to the dependencies
like an aar file.
If you have an aar file you can put the file in the libs
folder and then use:
dependencies {
compile(name:'nameOfYourAARFileWithoutExtension', ext:'aar')
}
repositories{
flatDir{
dirs 'libs'
}
}
Please pay attention because the aar file doesn't contain the transitive 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.
Otherwise if you have a maven repo just use:
dependencies {
compile 'my_dependencies:X.X.X'
}
Upvotes: 3
Reputation: 77
Try adding in the project's build.gradle
:
allprojects {
repositories {
maven { url 'file://' + new File('path/to/repository').canonicalPath }
}
}
Upvotes: -2