Reputation: 119
I want import .arr in my library module not main module,how can i do?
in my library module build.gradle set aar, err: can not find it.
dependencies {
compile(name:'nameArrFile', ext:'aar')
}
repositories{
flatDir{
dirs 'libs'
}
}
Upvotes: 2
Views: 3595
Reputation: 61
To Add to the answer: From the Android Studio File Menu, Click Import .JAR/.AAR Package then click Next. Enter the location of the compiled AAR or JAR file then click Finish. Import the library module to your project (the library source becomes part of your project): Click File > New > Import Module. Enter the location of the library module directory then click Finish. The library module is copied to your project, so you can actually edit the library code. If you want to maintain a single version of the library code, then this is probably not what you want and you should instead add the compiled AAR file as described above.
Make sure the library is listed at the top of your settings.gradle file, as shown here for a library named "my-library-module":
include ':app', ':my-library-module'
Open the app module's build.gradle file and add a new line to the dependencies block as shown in the following snippet:
dependencies {
compile project(":my-library-module")
}
Click Sync Project with Gradle Files. In this example above, the compile configuration adds the library named my-library-module as a build dependency for the entire app module.
If you instead want the library only for a specific build variant, then instead of compile, use buildVariantNameCompile. For example, if you want to include the library only in your "pro" product flavor, it looks like this:
Upvotes: 2
Reputation: 33398
Your code is correct. Make sure the following things are in place and it will work just fine.:
nameAarFile
should be just the file name without the extension .aar. Also make sure there is no spelling error in the file name.arr
at several places in your question (I corrected). make sure the same is no the case with extension in your file name.aar
file is in the libs folder. If in any other directory either move to libs or include the other directory under FlatDir - > dirs
Upvotes: 0