Frustrating linking issues when doing command line builds for Android- missing parent methods from SherlockFragmentActivity


(Michael McDuffee) #1

Frustrating linking issues when doing command line builds for Android- Gradle fails to recognize SherlockFragmentActivity having method onResumeFragments, getChildFragmentManager, etc.

Gradle fails to build an android project depending on several compiled library projects. (Everything builds in Eclipse). I have a structure as follows:

/root
  build.gradle
  settings.gradle
  /apps
    /MyApp
    build.gradle
  /libraries
    /thirdparty
       /actionbarsherlock
        build.gradle
      /proprietary
       /mylib
       build.gradle

Everything works when I build at the library level, but when I build at the /root level (whose settings includes all of the appropriate subprojects), I get errors like those that follow:

:apps:MyApp:compileDebug
/path_to_my_activity/MainActivity.java:529: cannot find symbol
symbol
: method onResumeFragments()
location: class com.actionbarsherlock.app.SherlockFragmentActivity
  super.onResumeFragments();

It doesn’t believe that MyActivity, which descends from MyProprietaryActivity, which descends from SherlockFragmentActivity, which descends from Watson, which descends from (support) FragmentActivity, has method onResumeFragments (or getChildFragmentManager).

Now, all of my build.gradle files have the same

dependencies {
 compile 'com.google.android:support-v4:r7'
}

And they all reference MavenCentral (I didn’t get to this point in compilation until that happened). Why is this the case? I have heard of interfering libraries causing problems in this case, but if, instead of pulling from MavenCentral, I include copes of the same android support library, I get tons of these:

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/ActivityCompatHoneycomb;

Why is this happening, and what is the solution? I’m building from the command line because I’m trying to use gradle to make an automated build. (Note: I am including the android-library and android plugins appropriately. I have done this with hand-made build.gradle files as well as Eclipse-exported build.gradle files. None of them build.)