15

There are numerous Q&A about IntelliJ 12 + ABS(ActionBarSherlock) settings.

similar case to this question but shows different errors.

Overall compilation and runnings are OK but only Activity using Tab Navigation(SherlockActivity implements ActionBar.TabListener) gives following error and crash. Note that I can use general SherlockActivity shows well.

"Could not find class 'android.support.v4.app.FragmentActivity', referenced from method com.actionbarsherlock.internal.app.ActionBarWrapper$TabWrapper.onTabReselected" on every overriden methods (onTabUnselected, onTabSelected, onTabReselected).

It seems like android-support-v4 is not sucessfully referenced but hard to find with check/uncheck trial-and-errors.

My IntelliJ project settings are as below.

1. Library is a name of ABS library folder. library settings

2. My project settings. my settings

I set both android-support-v4 to provided. What can I do more?

Some answers said to remove android-support-v4 to my own project but it shows reference errors on import android.support.v4.app.FragmentTransaction because implements ActionBar.TabListener requires it.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Youngjae
  • 24,352
  • 18
  • 113
  • 198
  • Please share your view here http://stackoverflow.com/q/18427768/2624806 .. i am also facing same issue. – CoDe Aug 25 '13 at 09:53

4 Answers4

14

This configuration is not correct, the scope of the android-support-v4 library must be set to Compile as it's not present on Android and must be included in your application.

Second copy of android-support-v4 must be removed from the application dependencies, it will be available to your application via a library module that has Export option enabled for android-support-v4.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
  • Thanks for the answer from JetBrains! :) Strangely, as I noted, `import android.support.v4.app.FragmentTransaction;` shows red (cannot resolve symbol error) in my project. I can see the ABS compile result folder libary(ABS)/bin/classes/android/support/v4/app only has Watson.class and its the only reference-able import in my project. any other thing that I need to check? (but I can see `android-support-v4` is well listed in Libraries tab of the Project Structure window). – Youngjae May 06 '13 at 18:57
  • 3
    Try `File` | `Invalidate Caches` and restart, double check `android-support-v4` library actually includes `android-support-v4.jar` file. – CrazyCoder May 06 '13 at 19:11
  • CrazyCoder // The problem was that I tried to add some libraries using **Maven**, as we can see in second figure. I did not realize that maven changes build result path and manage dependencies not related with Project Structure settings. (maven output /target did not include android-support-v4.jar) – Youngjae May 07 '13 at 02:25
  • Maybe the problem was that, ABS was added to my project as a **module**, but maven build did not recognize it (maybe requires additional settings in `pom.xml`). – Youngjae May 07 '13 at 02:30
  • 2
    You shouldn't manage dependencies manually in the Maven imported project, all the manual changes will be discarded on the next reimport. So, either manage all the dependencies via Maven or via IDEA, not both at the same time. – CrazyCoder May 07 '13 at 02:31
  • I marked your answer as correct because you clearly introduce meanings of my quizziness on settings each by each. thanks. – Youngjae May 07 '13 at 02:33
  • 1
    Remove all maven related things and it worked. Any of you tried to manage modules with fancy maven, I recommend that **do NOT use maven with Android development** (because many of Android references are not maven-ready and settings are sparsed) or use it from fresh start. – Youngjae May 07 '13 at 02:39
  • @CrazyCoder The advice to "invalidate the cache" saved me from another hour of stress -- thank you! – Ralphleon Sep 02 '13 at 21:12
2

I also had this problem in Android Studio (Version 1.1.0) when I wanted to check/test the "EffectiveNavigation"-App from the google examples (Link: http://developer.android.com/training/implementing-navigation/lateral.html)

What I had to do was to add this code snippet at the path ".\EffectivNavigation\app\builde.gradle":

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:20.0.0'
}

So the whole build.gradle looks like this:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.example.android.effectivenavigation"
        minSdkVersion 14
        targetSdkVersion 14
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:20.0.0'
}

You can also use

compile 'com.android.support:support-v4:20.+'

instead of

compile 'com.android.support:support-v4:20.0.0'

Maybe this answer is more helpfull for you than the other answers.

KingAlex1985
  • 659
  • 1
  • 8
  • 9
0

I added adt/sdk/extras/android/support/v4/android-support-v4.jar (adt should point to the android sdk) to the classpath of the Android SDK in Idea.

Thomas
  • 1,622
  • 17
  • 24
0

Just for the record - this solved the problem for me: (via https://stackoverflow.com/a/35248120/2409397 )

Build > Rebuild Project.

Community
  • 1
  • 1
alwe
  • 1,485
  • 17
  • 22