Module dependency broken as of plugin 1.1.0

1,686 views
Skip to first unread message

Greg Macdonald

unread,
Mar 16, 2015, 4:45:48 PM3/16/15
to adt...@googlegroups.com
We have external jar and aar libraries added to our project using this technique:
1. In AS do New Module and select Import .JAR or .AAR Package
   This creates project folder with a simple build.gradle, proj_name.iml and the jar or aar file
2. In dependent module's module dependencies setting, add Module dependency
   i.e. compile project(':proj_name')

This works fine thru plugin 1.0.1, but if I change to 1.1.0 or later, then I get 'cannot resolve symbol' errors in the editor.  The imports are resolved and the project builds and runs, but, since the AS ide is confused, all symbols from the library show red with the cannot resolve error, and both code completion and the ability to follow a symbol (cmd-click) are broken.

In the case where the lib is a jar, I find I can resolve this by adding to the dependent libr's gradle file:
dependencies {
    compile fileTree(dir: '../proj_name_dir', include: ['*.jar'])
}

Which surely seems a hack, and it doesn't work for aar files.

In the release notes for 1.1.0 comments under "Fixes and changes to the dependency management", there are comments about how dependencies have been made correct.  Are there some notes somewhere on what correct looks like and how I should be doing dependencies on these external libs?

thanks,
greg

Greg Macdonald

unread,
Mar 16, 2015, 5:32:01 PM3/16/15
to adt...@googlegroups.com
BTW, I notice that when I change gradle plugin version, it changes the AS iml file like this:

from:
   <orderEntry type="library" exported="" name="volley-1.0-SNAPSHOT" level="project" />

to:
   <orderEntry type="module" module-name="ext_volley" exported="" />

Hmmm, is it possible that the newer versions of the plugin only work with a dev build of AS ?  I'm configured for the beta channel, maybe 1.1.0 and later are only for the Canary channel?

Greg Macdonald

unread,
Mar 16, 2015, 5:57:08 PM3/16/15
to adt...@googlegroups.com
Ah, yes, I see it works with the Canary build.  A comment in the release notes for the plugin could be useful.

thanks,
greg

Xavier Ducrohet

unread,
Mar 16, 2015, 7:21:10 PM3/16/15
to adt...@googlegroups.com
What happened:

- While we fixed dependencies resolution in the 1.1 plugin, we changed the way we report dependencies on these type of projects from flat (local) jars to actual project dependencies.
The way it's reported is technically better/more accurate. This means the Gradle Plugin is technically not broken, but...

- This broke the Gradle/Studio integration, as Studio wasn't designed to handle modules that are just a wrapper over pure local jar/aar files with no Java nor android plugin applied. This was subsequently fixed in Studio 1.2.

Xav

--
You received this message because you are subscribed to the Google Groups "adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.
http://developer.android.com | http://tools.android.com

Please do not send me questions directly. Thanks!

Greg Macdonald

unread,
Mar 17, 2015, 1:55:01 PM3/17/15
to adt...@googlegroups.com
Yep, makes sense.  I had verified using the canary channel, so got a brief peek.  Look forward to 1.2.

thanks,
greg

Lawrence Bautista

unread,
Mar 18, 2015, 5:57:37 PM3/18/15
to adt...@googlegroups.com
Are you sure this is fixed? I am using 1.2 on canary and I'm still having the same problem.

Greg Macdonald

unread,
Mar 18, 2015, 8:27:34 PM3/18/15
to adt...@googlegroups.com
I can only say that the failure as I was seeing it was resolved by the Canary build - then I reverted to the beta channel and plugin 1.0.1, so I didn't investigate at length

Thomas Thyberg

unread,
Mar 23, 2015, 4:10:18 PM3/23/15
to adt...@googlegroups.com
I also run into this today using AS 1.2 on canary.

Cody Mace

unread,
Apr 1, 2015, 1:19:15 PM4/1/15
to adt...@googlegroups.com
The canary channel doesn't seem to fix this issue for me either. Does anybody know of a temporary solution if not a good solid one? I really to get this working because I need to finish up a project that is full of library dependencies.

Adrian Opyrchał

unread,
Apr 1, 2015, 3:38:54 PM4/1/15
to adt...@googlegroups.com
For now use gradle build tools 1.0.1
classpath 'com.android.tools.build:gradle:1.0.1' in  project build.gradle

Add jar or aar package from File -> New Module -> Import jar/aar

Dont forget to add imported module to your build.gradle as dependency 

dependencies {
    ....
    compile project(':NameOfImportedModule')
    ....

Kevin Lim

unread,
Apr 6, 2015, 3:17:23 PM4/6/15
to adt...@googlegroups.com
I am seeing this too, specifically with the urbanairship SDK (imported using aar wrapper project).

Here's the bug in Google's tracker, currently assigned to Tor:

Staying on 1.0.x gradle plugin is workaround for me.

Kevin Lim

unread,
Apr 20, 2015, 5:17:28 PM4/20/15
to adt...@googlegroups.com
Issue still happens on gradle plugin 1.2.0-beta2

Alex Ruiz

unread,
Apr 20, 2015, 11:46:25 PM4/20/15
to adt...@googlegroups.com
Kevin, I verified that the bug is fixed in 1.2.0 beta 3, please give this version a try. If you can still experience the issue, please provide steps to reproduce and I'll look at it right away.

Thanks.

--

Kevin Lim

unread,
Apr 22, 2015, 4:41:50 PM4/22/15
to adt...@googlegroups.com
Alex, 

Still doesn't work for me.

When you say you've verified it, are you talking about a 1.2.0-beta3 of gradle plugin? Or Android Studio 1.2b3? 

I'm using Android Studio 1.2 RC and Gradle plugin 1.2.0-beta2 

To repro, you just import an AAR using the Android Studio "New Module" GUI.  

For us, it's Urban Airship's Android SDK, which comes as an AAR.  
http://docs.urbanairship.com/platform/android.html#add-the-library-to-your-project

While the gradle build is fine, the Android Studio editor UI shows the referenced classes as unresolvable.

Classes unresolvable:

Kevin


You received this message because you are subscribed to a topic in the Google Groups "adt-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/adt-dev/1Ho_c8dALQQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adt-dev+u...@googlegroups.com.

Xavier Ducrohet

unread,
Apr 22, 2015, 7:36:55 PM4/22/15
to adt...@googlegroups.com
I just tried it with Studio 1.2 RC1 and Gradle plugin 1.2.0-rc1 and it's working fine.

Kevin Lim

unread,
Apr 27, 2015, 3:18:41 PM4/27/15
to adt...@googlegroups.com
Using Studio 1.2 RC3 and Gradle plugin 1.2 and it's fine.

Thanks for your work guys

Kevin Lim

unread,
May 11, 2015, 3:50:08 PM5/11/15
to adt...@googlegroups.com
IDE looks fine, symbols are resolved correctly, but now the imported AAR produces an error in running unit tests with error: 

'testClasses" not found in urbanairship-lib-gradle
Error:Could not execute build using Gradle installation '/Applications/Android Studio.app/Contents/gradle/gradle-2.2.1'.


On Monday, March 16, 2015 at 1:45:48 PM UTC-7, Greg Macdonald wrote:
Reply all
Reply to author
Forward
0 new messages