Fixed
Status Update
Comments
xa...@android.com <xa...@android.com>
xa...@ducrohet.com <xa...@ducrohet.com> #2
[Comment deleted]
ar...@gmail.com <ar...@gmail.com> #3
For those running into this issue, you can install maven, and reference the library from a local maven repository.
I've written up a simple article on how to do that:
http://www.flexlabs.org/2013/06/using-local-aar-android-library-packages-in-gradle-builds
I've written up a simple article on how to do that:
ph...@gmail.com <ph...@gmail.com> #4
I tried following your article, but I still get "cannot find symbol".
ar...@gmail.com <ar...@gmail.com> #5
Oh right.. I just realised I didn't make it obvious how to reference the newly setup libraries after installing them to maven..
Check the article for an update (look at step 5), and tell me if it works? :)
Check the article for an update (look at step 5), and tell me if it works? :)
xa...@android.com <xa...@android.com> #6
referencing local aar file is not yet supported.
aar works either as a different module or as a published artifact. We'll supported this in the future but we have to be careful when it comes to local dependencies.
aar works either as a different module or as a published artifact. We'll supported this in the future but we have to be careful when it comes to local dependencies.
nd...@gmail.com <nd...@gmail.com> #7
[Comment deleted]
vi...@gmail.com <vi...@gmail.com> #8
I'm waiting this function too.
Hope to support it soon.
Thank you.
Hope to support it soon.
Thank you.
fu...@gmail.com <fu...@gmail.com> #9
When did this feature come?
ch...@gmail.com <ch...@gmail.com> #10
I'm resolving my .aar file(s) from a Maven repo and I'm getting the "cannot find symbol" error during compilation as well. Whereas my project compiles without issue in Eclipse. Looks like this Gradle bug is not just for local .aar files!
ya...@gmail.com <ya...@gmail.com> #11
Are you kidding?
xa...@android.com <xa...@android.com> #13
[Comment deleted]
au...@gmail.com <au...@gmail.com> #14
Is there a new target for this fix?
Using `compile files('libs/somelib.aar')` still does not work in `v0.5.3`. The .aar resources are not found when I try to build the project.
Using `compile files('libs/somelib.aar')` still does not work in `v0.5.3`. The .aar resources are not found when I try to build the project.
xa...@android.com <xa...@android.com> #16
I just created a test project with this, and it's working.
reference:https://android-review.googlesource.com/#/c/89460/
In this test the main manifest reference @drawable/ic_launcher which is coming from lib1.aar
reference:
In this test the main manifest reference @drawable/ic_launcher which is coming from lib1.aar
as...@dismoiou.fr <as...@dismoiou.fr> #17
Looks to me like you are referencing the 'lib1' project as a dependency along with 'lib1.aar', so sure it works.
By removing the 'lib1' project dependency, leaving only the 'lib1.aar' one, it does not work again.
Gradle/AndroidStudio do not recognize .aar files correctly, even on the latest 0.5.8 Android Studio IDE version.
By removing the 'lib1' project dependency, leaving only the 'lib1.aar' one, it does not work again.
Gradle/AndroidStudio do not recognize .aar files correctly, even on the latest 0.5.8 Android Studio IDE version.
as...@dismoiou.fr <as...@dismoiou.fr> #18
I personally got it to (finally) work after weeks of investigation using:
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile(name:'yourfilename', ext:'aar')
}
Works with libraries, sources, resources as of Android Studio 0.5.8.
Credits to Vipul Shah:http://stackoverflow.com/a/23326397
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile(name:'yourfilename', ext:'aar')
}
Works with libraries, sources, resources as of Android Studio 0.5.8.
Credits to Vipul Shah:
no...@gmail.com <no...@gmail.com> #19
js...@gmail.com <js...@gmail.com> #20
Any update on this?
ts...@gmail.com <ts...@gmail.com> #21
Thanks aschnei..., it work !
ra...@gmail.com <ra...@gmail.com> #22
Aschnei's solution works.
One dump follow up question, after you done with repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile(name:'yourfilename', ext:'aar')
}
How do you use yourfilename.aar? Do you need to import it? How do you call the method inside your aar library?
I have try many ways and google it a lot, couldn't get it to work.
One dump follow up question, after you done with repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile(name:'yourfilename', ext:'aar')
}
How do you use yourfilename.aar? Do you need to import it? How do you call the method inside your aar library?
I have try many ways and google it a lot, couldn't get it to work.
pa...@gmail.com <pa...@gmail.com> #23
rabbit20, just use your library package name, like:
import com.test.mylibrary.SomeClass;
.
.
.
android.util.Log.d(TAG, new SomeClass().getSomeString());
import com.test.mylibrary.SomeClass;
.
.
.
android.util.Log.d(TAG, new SomeClass().getSomeString());
te...@gmail.com <te...@gmail.com> #24
Questio to 24 : What about transitive dependencies?
I have an AAR library (MyAAR) that in turn depends on other (JAR) libs from maven central (say, okhttp). I do not use maven or POMs - all the dependencies are declared in the build.gradle of my library project.
Now I am trying to create an app that has MyAAR in its libs/ directory. I can access the classes defined in MyAAR, but my app cannot access classes from the dependencies like OkHttp.
In fact this is obvious since the AAR format doesn't have any means of expressing its dependencies. But then, how do I get my app to compile in the libraries that MyAAR depends on?
I have an AAR library (MyAAR) that in turn depends on other (JAR) libs from maven central (say, okhttp). I do not use maven or POMs - all the dependencies are declared in the build.gradle of my library project.
Now I am trying to create an app that has MyAAR in its libs/ directory. I can access the classes defined in MyAAR, but my app cannot access classes from the dependencies like OkHttp.
In fact this is obvious since the AAR format doesn't have any means of expressing its dependencies. But then, how do I get my app to compile in the libraries that MyAAR depends on?
ma...@gmail.com <ma...@gmail.com> #25
#32, I have the same problem. Did you find out a workaround?
lo...@gmail.com <lo...@gmail.com> #26
The workaround :
To compile the aar, just clean the project, and the aar file will be automatically regenerated.
To include the aar, use flatdir
To compile the aar, just clean the project, and the aar file will be automatically regenerated.
To include the aar, use flatdir
co...@gmail.com <co...@gmail.com> #27
Use the module import wizard (File | New Module | Import .JAR or .AAR package), and then set it as new dependency of your "app module" (File | Project Structure | Dependencies). But it would be nice if we can import the .aar the same way as we import .jar.
se...@mobiquite.fr <se...@mobiquite.fr> #28
Importing my .aar as specified in the #35 comment (= the official way) gives me the same problem as explained here:
http://stackoverflow.com/questions/28477952/issue-with-using-aar-file-in-other-project
My .aar library is well imported, everything is compiling without any error.
The only thing is that Android Studio seems to not find the library package and so write in red the imports line and the class name in my code. So, I've got java files that appear to not compile in Android Studio but do compile !
My .aar library is well imported, everything is compiling without any error.
The only thing is that Android Studio seems to not find the library package and so write in red the imports line and the class name in my code. So, I've got java files that appear to not compile in Android Studio but do compile !
lo...@gmail.com <lo...@gmail.com> #29
The current workaround :
Put the aar file in the libs directory (create it if needed), then, add the following code in your build.gradle inside the repositories braces :
flatDir {
dirs 'libs'
}
Put the aar file in the libs directory (create it if needed), then, add the following code in your build.gradle inside the repositories braces :
flatDir {
dirs 'libs'
}
ni...@gmail.com <ni...@gmail.com> #30
Agree with @louis , but for people who want a more verbose version
Complete example:
Put the aar file in the libs directory (create it if needed), then, add the following code in your build.gradle :
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile(name:'nameOfYourAARFile', ext:'aar')
}
repositories{
flatDir{
dirs 'libs'
}
}
Complete example:
Put the aar file in the libs directory (create it if needed), then, add the following code in your build.gradle :
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile(name:'nameOfYourAARFile', ext:'aar')
}
repositories{
flatDir{
dirs 'libs'
}
}
to...@nepatec.de <to...@nepatec.de> #31
When will this be fixed???
xa...@android.com <xa...@android.com> #32
#36 this is a temporary regression in studio that will be fixed in 1.2
The current support we have (creating a new module for the aar) is how we mean to support it.
The current support we have (creating a new module for the aar) is how we mean to support it.
ha...@google.com <ha...@google.com> #33
#40 I still have the same problem with 1.2 preview 4 if import .aar as a new module.
Looking into the app's build/intermediates/exploded-aar directory, all .aar contents were extracted, but the class files in classes.jar didn't seem to be extracted. When using the workaround described in #38, I could see all classes from the aar file's classes.jar from the Project view.
Can anyone verify if this works in 1.2? Thanks!
Looking into the app's build/intermediates/exploded-aar directory, all .aar contents were extracted, but the class files in classes.jar didn't seem to be extracted. When using the workaround described in #38, I could see all classes from the aar file's classes.jar from the Project view.
Can anyone verify if this works in 1.2? Thanks!
pe...@gmail.com <pe...@gmail.com> #34
I have the problen importing an AAR as new module using 1.2.1.1. The module is imported correctly but the classes can't be used, they appear in red. Then, it doesn't compile.
ra...@gmail.com <ra...@gmail.com> #35
I am also facing same issue. I have 1 android library project and have added volly library dependencies inside android library project gradle file. while i include aar file to other project it complies successfully but when i run the application it throws runtime exception that volly class not found. please suggest if any solution
jo...@gmail.com <jo...@gmail.com> #36
#43 is a proguard configuration issue?
ni...@gmail.com <ni...@gmail.com> #37
As of Android Studio v1.3, this issue has been solved.
Checkout my answer herehttp://stackoverflow.com/a/28816265/2745762
Checkout my answer here
jd...@gmail.com <jd...@gmail.com> #38
I am seeing the similar behavior in AS 1.3 & 1.4 where my *.aar dependency is compiled from a public maven repo. The module is imported correctly but the classes can't be used, they appear in red. Then, it doesn't compile. Seems this issue did not resolve my issue, any ideas?
lo...@gmail.com <lo...@gmail.com> #39
Did you add in your app a dependency to the module conatining the aar?
If not, click on the "project structure" icon, select "app" on the left (or any other module within which you want to use the library), click on the "Dependencies" tab and then on the "+" icon, select "3. Module dependency" and choose the correct module in the dialog box.
That did it for me.
If not, click on the "project structure" icon, select "app" on the left (or any other module within which you want to use the library), click on the "Dependencies" tab and then on the "+" icon, select "3. Module dependency" and choose the correct module in the dialog box.
That did it for me.
bu...@gmail.com <bu...@gmail.com> #40
I'm using Android Studio 1.3.2 and am seeing this problem. Like #43 I looked into the "classes.jar" file there, which seems to contain all my library's classes. However I still get "cannot find symbol class 'class_name'" in the Messages window when trying to Build.
il...@gmail.com <il...@gmail.com> #41
Hi, I am using Android Studio 2.0 and i am trying to build an Android Library Project having activities,fragments etc. Now my requirement is to build an .aar file and use it with any other application. The aar gets generated and one of the activity of our library project gets called too.
But it gives an error: NoClassDefFoundError with other activities. We have defined the activities in the Application too where we are importing this aar.
Tried solution #38 too but it didn't work.
Also tried another approach with just one activity and rest fragments in my library project but still it gives the same error.
Please suggest any working approach.
But it gives an error: NoClassDefFoundError with other activities. We have defined the activities in the Application too where we are importing this aar.
Tried solution #38 too but it didn't work.
Also tried another approach with just one activity and rest fragments in my library project but still it gives the same error.
Please suggest any working approach.
to...@nepatec.de <to...@nepatec.de> #42
I got it finally to work:
1.)
(File -> New Module -> Import .JAR/.AAR) and import the .AAR.
2.
Then add to the build.gradle (not the top level one, the one under 'app') the following (dependencies section):
dependencies {
compile project(':Name-Of-Your-Module-aar')
}
1.)
(File -> New Module -> Import .JAR/.AAR) and import the .AAR.
2.
Then add to the build.gradle (not the top level one, the one under 'app') the following (dependencies section):
dependencies {
compile project(':Name-Of-Your-Module-aar')
}
ha...@gmail.com <ha...@gmail.com> #43
#38 method builds my Gradle without any warnings. But I still cannot import any classes from *.aar file. I'm using Android Studio 1.5.1 stable version. When will this be fixed? We developers have waited for a long time...
se...@gmail.com <se...@gmail.com> #44
this is still happening in 2.1
mo...@gmail.com <mo...@gmail.com> #45
[Comment deleted]
mo...@gmail.com <mo...@gmail.com> #46
Please fixed this problem. We have multi module project and we are facing this problem every day and it's wasting our lots of time. This problem is still present in android studio 2.2 beta 3.
ch...@gmail.com <ch...@gmail.com> #47
[Comment deleted]
ch...@gmail.com <ch...@gmail.com> #48
With Android Studio 2.1, the issue can be fixed with this solution http://stackoverflow.com/questions/24506648/adding-local-aar-files-to-gradle-build-using-flatdirs-is-not-working/28816265#28816265 .
The solution in short is:
- The aar file is compiled into an own libary module e.g. 'smpmod'
- Add the module directory in settings.gradle with "project(':smpmod').projectDir = new
- Add project as repository for aar-files in the main build.gradle like "flatDir { dirs project(':smpmod').file('aars')"}
File(rootProject.projectDir, 'smpmod')"
- Bind the module into your other dependent modules by "compile project(':smpmod')" in the build.gradle file of that modules.
Works also for multiple aars files in 'smpmod'.
The solution in short is:
- The aar file is compiled into an own libary module e.g. 'smpmod'
- Add the module directory in settings.gradle with "project(':smpmod').projectDir = new
- Add project as repository for aar-files in the main build.gradle like "flatDir { dirs project(':smpmod').file('aars')"}
File(rootProject.projectDir, 'smpmod')"
- Bind the module into your other dependent modules by "compile project(':smpmod')" in the build.gradle file of that modules.
Works also for multiple aars files in 'smpmod'.
sh...@gmail.com <sh...@gmail.com> #49
aar is not working in android.
aar file issue has not still resolved in android 2.2.3
as I am creating a new project in gradle and doing follow code but it's not working.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.2.0'
testCompile 'junit:junit:4.12'
compile "tv.ustream.player:ustream-player-android:0.5.1@aar"
}
i=In project Gradle module
allprojects {
repositories {
flatDir {
dirs 'libs'
}
jcenter()
}
}
It's not working at all.
aar file issue has not still resolved in android 2.2.3
as I am creating a new project in gradle and doing follow code but it's not working.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.2.0'
testCompile 'junit:junit:4.12'
compile "tv.ustream.player:ustream-player-android:0.5.1@aar"
}
i=In project Gradle module
allprojects {
repositories {
flatDir {
dirs 'libs'
}
jcenter()
}
}
It's not working at all.
[Deleted User] <[Deleted User]> #50
Following answer at StackOverflow helped me:
http://stackoverflow.com/a/24894387/
Just make sure that you replace "Name-Of-Your-Project" with the name of your aar file (without the extension).
Just make sure that you replace "Name-Of-Your-Project" with the name of your aar file (without the extension).
gu...@gmail.com <gu...@gmail.com> #51
arr引入了另外的库会丢失
sh...@steamclock.com <sh...@steamclock.com> #52
For those having issue getting a local aar to update try the following:
1. Comment out the implementation files('../libs/yourlib.aar') line in gradle
2. Sync gradle
3. Update yourlib.aar in the libs folder
4. Uncomment out the implementation files('../libs/yourlib.aar') line in gradle
5. Sync again
6. Build project
Now the changes in yourlib.aar should be available in your project. If you have this lib included in multiple modules I am guessing you'll have to do it for each module. Not ideal, but I spent at least 5 hours on this issue and these steps were the only way I could seemingly force the changes.
1. Comment out the implementation files('../libs/yourlib.aar') line in gradle
2. Sync gradle
3. Update yourlib.aar in the libs folder
4. Uncomment out the implementation files('../libs/yourlib.aar') line in gradle
5. Sync again
6. Build project
Now the changes in yourlib.aar should be available in your project. If you have this lib included in multiple modules I am guessing you'll have to do it for each module. Not ideal, but I spent at least 5 hours on this issue and these steps were the only way I could seemingly force the changes.
di...@gmail.com <di...@gmail.com> #53
I tried all the ways mentioned in various answers but in vain.
1. Added my aar file as via File-->New Module-->Add a jar/aar
2. Added in my libs folder and tried compiling.
However, none of them works. Is there a solution for this?
1. Added my aar file as via File-->New Module-->Add a jar/aar
2. Added in my libs folder and tried compiling.
However, none of them works. Is there a solution for this?
ak...@gmail.com <ak...@gmail.com> #54
With Android Studio 3.X.X, adding local .AAR file to Gradle build is not working (Build is success but getting runtime exceptions). Tried below methods (From: https://stackoverflow.com/a/23326397/5685911 , https://stackoverflow.com/a/24894387/5685911 , etc.), but none worked for me:
1. Import the local aar file:
(I) File>New>New Module>Import the .AAR Package
On "Finish" click the .AAR gets included automatically into settings.gradle file as below:
include ':app', ':myAAR'
(II) Add AAR module dependency in app level build.grdle file as below:
implementation project(":myAAR")
2. Using flatDir method:
(I) keep aar file in libs folder
(II) Add flatDir{dirs 'libs'} into the project level build.gradle file as below:
allprojects {
repositories {
jcenter()
flatDir {
dirs 'libs'
}
}
}
(III) Add AAR dependency in app level build.gradle file as below:
dependencies {
implementation(name:'myAAR', ext: 'aar')
}
Worked around: Need to include all the library imported by the AAR module into the app level gradle. It seems imports from the AAR file are not propagated using any of the above method.
BUT, I think it is not the proper solution. Any help would be appreciated here with a big THANKS :)
1. Import the local aar file:
(I) File>New>New Module>Import the .AAR Package
On "Finish" click the .AAR gets included automatically into settings.gradle file as below:
include ':app', ':myAAR'
(II) Add AAR module dependency in app level build.grdle file as below:
implementation project(":myAAR")
2. Using flatDir method:
(I) keep aar file in libs folder
(II) Add flatDir{dirs 'libs'} into the project level build.gradle file as below:
allprojects {
repositories {
jcenter()
flatDir {
dirs 'libs'
}
}
}
(III) Add AAR dependency in app level build.gradle file as below:
dependencies {
implementation(name:'myAAR', ext: 'aar')
}
Worked around: Need to include all the library imported by the AAR module into the app level gradle. It seems imports from the AAR file are not propagated using any of the above method.
BUT, I think it is not the proper solution. Any help would be appreciated here with a big THANKS :)
za...@gmail.com <za...@gmail.com> #55
Was a solution found for this? Same issue persisting when importing classes even despite having AAR file in libs folder and having declared dependencies (as instructed in https://developer.android.com/studio/projects/android-library ). Tried every solution above and every one on stack overflow. Android gradle plug in: 3.2.0 / gradle version 4.9. Getting desperate here. thanks.
Description
To be specific, if you use a class in a layout/resource - that works absolutely fine. BUT if you try to reference it in code - the compile task will complain with "cannot find symbol".
Interestingly enough, if I reference the library directly, then the classes will be picked up, and the project builds.
Host OS: Windows 8 x64
SDK tools version: Revision 22
Gradle version: 0.4, 0.4.1
Eclipse version: --
ADT plug-in version: --
Platform targeted by your project: Android SDK 4+
Version of the platform running in the emulator: --
STEPS TO REPRODUCE:
1. Create a multi project solution in Gradle - an app and a library
2. Add some classes to the library, and try to use them in your app's code (e.g. onCreate in an activity)
3. This should work so far
4. Go to the build.gradle of your app, and change the dependency so it references the compiled .aar instead of the library project
5. Building the project will fail
EXPECTED RESULTS:
The .aar package contains the classes from the library. These classes should be available to reference from projects that use it as a dependency
OBSERVED RESULTS:
While the classes from the .aar are easy to reference from layouts/xml, the gradle compile step doesn't seem to be picking them up (only if using .aar)
ADDITIONAL INFORMATION:
I attached one of the demo projects (it was in the demo packages for android gradle 0.3) updated to use android gradle 0.4.1
The project builds fine. I compiled the library project, and put the packaged .aar into app/libs
Now, if you update the build.gradle from /apps/
from:
dependencies {
compile project(':library')
}
to:
dependencies {
compile files('libs/library-1.0.aar')
}
The project will stop building with the following:
D:\Development\test\multiproject>gradle clean build
The TaskContainer.add() method has been deprecated and is scheduled to be removed in Gradle 2.0. Please use the create() method instead.
:app:clean UP-TO-DATE
:baseLibrary:clean UP-TO-DATE
:library:clean UP-TO-DATE
:util:clean UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:generateDebugBuildConfig
:app:mergeDebugAssets
:app:compileDebugRenderscript
:app:mergeDebugResources
:app:processDebugManifest
:app:processDebugResources
:app:compileDebug
D:\Development\test\multiproject\app\src\main\java\com\example\android\multiproject\MainActivity.java:8: error: package com.example.android.multiproject.library does not exist
import com.example.android.multiproject.library.ShowPeopleActivity;
D:\Development\test\multiproject\app\src\main\java\com\example\android\multiproject\MainActivity.java:18: error: cannot find symbol
Intent intent = new Intent(this, ShowPeopleActivity.class);
symbol: class ShowPeopleActivity
location: class MainActivity
2 errors
:app:compileDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebug'.