17

I am currently migrating all my projects from Eclipse to IntelliJ Idea.

When I was using Eclipse, the package was only included in ActionBarSherlock library and when the library was included in my project, everything was automatically added.

With IntelliJ, once the android-support-v4.jar is added to ABS, that does not seems enough, as all my imports are broken.

Screenshot of ActionBarSherlock (LibABS) imports:

enter image description here

Everything seems fine, all the SherlockActivity are fine, but all the stuff related to support is not recognized in my application:

java: /home/user/workspace/....
cannot access android.support.v4.app.FragmentActivity
class file for android.support.v4.app.FragmentActivity not found

So, I have to copy manually the jar into a libs folder and include it to my project once again.

Screenshot of my project imports:

enter image description here

The imports are recognized, nut I now get this error:

Android Dex: [BeTrains-for-Android] UNEXPECTED TOP-LEVEL EXCEPTION:
Android Dex: [BeTrains-for-Android] java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/ShareCompat$ShareCompatImplJB;

Thank a lot for any help.

Waza_Be
  • 39,407
  • 49
  • 186
  • 260
  • Try to remove remove `android-support-v4.jar` from dependencies now. It's already included via `LibABS` dependencies. – Mikita Belahlazau Dec 31 '12 at 08:33
  • As explained, I get a : java: /home/user/workspace/.... cannot access android.support.v4.app.FragmentActivity class file for android.support.v4.app.FragmentActivity not found – Waza_Be Dec 31 '12 at 08:33
  • in the first case you don't have `LibABS` dependencies as in the second case. – Mikita Belahlazau Dec 31 '12 at 08:34
  • First case in a screenshot of LibABS dependencies, second case is a screenshot of my application dependencies – Waza_Be Dec 31 '12 at 08:36
  • 4
    Try to change `android-support-v4.jar` dependency to scope provided in your project. – Mikita Belahlazau Dec 31 '12 at 08:39
  • Can you elaborate this answer? I don't understand... – Waza_Be Dec 31 '12 at 08:40
  • On the screenshot at the right there is a column names `Scope`. It's now `compile` for every dependency. If you change it to `Provided` then idea won't include it to jar. Check this page [dependencies tab](http://www.jetbrains.com/idea/webhelp/dependencies-tab.html) – Mikita Belahlazau Dec 31 '12 at 08:45
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/21941/discussion-between-waza-be-and-nikita-beloglazov) – Waza_Be Dec 31 '12 at 08:49
  • Nikita's solution worked for me. – Kent Andersen Mar 08 '13 at 19:44
  • after make scope compile to provided...it giving me same reference library problem...any idea?..I mention my prblm here http://stackoverflow.com/q/18427768/2624806 ..please share ur views..thanks – CoDe Aug 25 '13 at 10:16

1 Answers1

15

Try to play with dependencies scopes and export flags. Check this page for the description: dependency tab.

Mikita Belahlazau
  • 15,326
  • 2
  • 38
  • 43
  • 4
    Waouw, everything is fixed. The issue was that I was using SlidingMenu, so the trick was to include only Slidingmenu in My main project, the Slidingmenu included ABS that needed to be exported, and ABS icluded support jar that also needed to be exported. – Waza_Be Dec 31 '12 at 09:46
  • 1
    As an FYI, this boils down to needing to set _Export_ within any referenced project, such as ActionBarSherlock in which you want to leverage _that_ projects references, in this case android-support-v4.jar. – Aaron McIver Jan 06 '13 at 05:45
  • 15
    I had the same problem while using Facebook and ActionBarSherlock as modules. I solved this by setting the Scope to Provided in both modules. – mparaz Feb 13 '13 at 12:56
  • @mparaz I am not getting android.support.v4 in both module option...any idea why? – CoDe Aug 25 '13 at 10:22