0

I'm migrating a large, complicated android library project to gradle, and am having trouble incorporating library projects into the large project. This has been discussed in other questions, but no one has yet (to my knowledge) posted about this problem. I have several applications, a bunch of third party libraries, and my own shared library. The folder structure is as follows:

--Root
   -build.gradle
   -settings.gradle
   |--apps
      |--MyApp
   |--libraries
      |--thirdparty
         |--actionbarsherlock
            -build.gradle
         |--facebook
            -build.gradle
         |--google-play-services-lib
            -build.gradle
      |--personal
         |--commons
            -build.gradle
            - AndroidManifest.xml
            |--src
               |--main, blah blah
         |--proprietary

Now, the personal/commons library depends on all of the third party libs (ABS, Facebook, etc). Each third party lib depends only on common jar files that can be brought in from mavenCentral, and each of those builds perfectly. It's important to have the separation of thirdparty from personal libraries, and equally important that neither that nor the "libraries" folder is actually an android project in its own right.

(Update: removed everything but the base build.gradle and settings.gradle files to simplify.)

Note that I'm trying to follow a similar solution in a slightly simpler problem.

In my /root/ folder, the settings.gradle file reads:

include ':libraries:personal:commons'  
include ':libraries:thirdparty:actionbarsherlock'
include ':libraries:thirdparty:facebook'
include ':libraries:thirdparty:google-play-services-lib'
include ':apps:MyApp'

and the build.gradle file at that same level (/root/) is simply empty.

Edit: removed calls to evaluationDependsOn(':thirdparty:facebook') and the other sub-projects. Compiling yields the same answer dependency failure issue.

When I run gradle build at the /root/libraries/personal level (again, following the linked example), it first successfully compiles all of the thirdparty libraries (hooray!). Then, it gives what looks like an actual java compile error: /Root/libraries/personal/commons/src/main/java/com/personal/commons/dialog/AlertDialogFragment.java:19: cannot find symbol symbol : method dismissAllowingStateLoss() location: class com.personal.commons.dialog.AlertDialogFragment instance.dismissAllowingStateLoss();

I suspect this is a linking problem, though, since (1) it's been compiling for over a year in Eclipse with no change in code, and (2) AlertDialogFragment extends SherlockDialogFragment, which itself extends DialogFragment, which is where dismissAllowingStateLoss() is defined. It doesn't complain, though, about the class definition

public class AlertDialogFragment extends SherlockDialogFragment {

or the import com.actionbarsherlock.app.SherlockDialogFragment at the top of the file, so somehow it thinks all is well, but can't resolve the dependencies. When I look at the build folder of /root/libraries/thirdparty/actionbarsherlock, a class file is indeed output for SherlockDialogFragment. Why won't my poor custom library see this?

All attempts to settle this issue thus far have failed, as my gradle-fu is still weak. Does anyone know where my fatal error is?

Community
  • 1
  • 1
mrmcduff
  • 163
  • 8
  • 1
    why do you have 2 settings.gradle that seem to include the same modules (besides the empty :thirdparty and :personal which are not needed anyway)? I think that might be making things more complicated than they need to be. – Xavier Ducrohet Jul 17 '13 at 19:02
  • also you really don't need to use evaluationDependsOn('...') – Xavier Ducrohet Jul 17 '13 at 19:02
  • @Xav - adding the higher one hasn't made a difference one way or another, but other linked solutions have said that you have to require all projects at all levels. Also, the reason I'm using evaluationDependsOn is from the solution to a complicated project formatting problem [here] (http://stackoverflow.com/questions/17536652/gradle-and-multi-project-structure?lq=1) – mrmcduff Jul 17 '13 at 19:12
  • @Xav - if I remove all of the evaluationDependsOn calls, it fails in one of the thirdparty builds: `Could not determine the dependencies of task ':thirdparty:facebook:mergeReleaseResources'.`. If I remove all of them but `evaluationDependsOn(':thirdparty'), I get the same error as above. – mrmcduff Jul 17 '13 at 19:21

0 Answers0