I Have To Add .aar Files As A Library In A Sub Project In Android Studio. It Gives Me An Error.
Solution 1:
In the repositories of your module: app
repositories {
flatDir {
dirs'libs'
}
}
Add the following in the dependencies of your module: app In the case that your have both a JAR and an AAR file, do the following.
dependencies
{
implementation (name: '***library name***', ext: 'aar')
implementationfileTree(dir: 'libs', include: ['*.jar', '*.aar'], )
}
Solution 2:
You need to set the dependencies too:
compilefileTree(dir: 'libs', include: ['*.jar','*.aar'])
This can be done in the subprojects build.gradle.
Edit: You might need to specify the file itself:
compile(name:'name-of-file',ext:'aar')
Solution 3:
classpath 'com.android.tools.build:gradle:1.3.0'
File -> New Module -> Import JAR/AAR Package
"File name" select .aar file, example:
d:/myproject/mylib/build/outputs/aar/mylib-release.aar
"Subproject name",example:
mylib-release
/app/build.gradle
dependencies{
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':mylib-release')
}
Solution 4:
For filename.aar
repositories {
flatDir {
dirs'libs'
}
}
dependencies {
compile(name:'filename', ext:'aar')
}
Solution 5:
You are adding a aar file in libs folder. The aar file doesn't contain the dependencies, then you have to add these dependencies also in the main project.
In your module1/build.gradle
you should have something like:
dependencies {
compilefileTree(dir: 'libs', include: ['*.jar'])
compile('com.android.support:appcompat-v7:22.2.1') //for example//..
}
In your mainModule/build.gradle
you have to add all the dependencies used by your module1.
dependencies {
compilefileTree(dir: 'libs', include: ['*.jar'])
compile(name:'fileName',ext:'aar')
compile('com.android.support:appcompat-v7:22.2.1') //for example//...
}
Post a Comment for "I Have To Add .aar Files As A Library In A Sub Project In Android Studio. It Gives Me An Error."