27

Is anyone else having problems importing a project with ActionBarSherlock? I have a total of 100 errors and 17 warnings. This worked perfectly in Eclipse. I followed the steps to create a Gradle build file. There were no import errors until I tried to build the Project.

I also tried re-downloading ABS fresh and replace into my project.

Were there known issues with ABS and IntelliJ? (which of course Android Studio is now based)

Here are a few errors I'm seeing:

        java: ...
        Workspace/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockFragment.java:4: cannot find symbol
        symbol  : class Fragment
        location: package android.support.v4.app

        java: ...  Workspace/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockListFragment.java:4: cannot find symbol
        symbol  : class ListFragment
        location: package android.support.v4.app

        java: ...
        Workspace/ActionBarSherlock/src/com/actionbarsherlock/widget/SuggestionsAdapter.java:33:
        package android.support.v4.widget does not exist

Any help really appreciated

Edit: Seems there are no issues using Standard IntelliJ IDEA. Many guides online for setting it up with ABS. Also as Jake mentioned, he's actually been developing the thing in IntelliJ

Here is an example guide: http://android-wtf.com/2012/09/how-to-configure-actionbarsherlock-with-intellij-idea/

However, I'm still unsure why its not working in Android Studio

Edit2: solution in answer below. In Short: (I downloaded abs latest version, extracted, deleted the old version of abs from my project, then file > import module... to import actionbarsherlock directory into my existing project. Nb, in my particular case I had an issue with junit compilation error and needed to delete \test\junit\ )

wired00
  • 13,930
  • 7
  • 70
  • 73
  • 1
    I've developed ABS in IntelliJ for two years and used it in many projects via Maven in IntelliJ. Looks like the support library is missing there. – Jake Wharton May 16 '13 at 01:55
  • @JakeWharton Thanks Jake, Yeah and in fact after posting this i found quick guides via google on getting your ABS working with standard IntelliJ with no problem. I'm still looking into this for Android Studio. I think it has something to do with File > Project Structure ... Modules etc. – wired00 May 16 '13 at 02:04
  • Ok cool i got it working I needed to re-download the ActionBarSherlock Package. Completely Delete the old one from my previous package. then File > Import Module ... and import again overriding any existing module files it had – wired00 May 16 '13 at 02:28
  • Did you import the module using maven? If I import it using "Create module from existing sources" I get an error compiling ABS saying it can't find junit. I could delete the tests but doesn't seem right to me. – alex May 16 '13 at 10:19
  • @alex unfortunately I couldn't get rid of that junit error without removing it but from what I remember it was just directory. I was able to run abs fine without it. You could always add junit module to your project I guess I might test that when back at work – wired00 May 16 '13 at 20:15
  • 1
    If you want to fix the problem with the junit library you have two choices: 1 - delete the test directory of the ABS project or 2 - include the junit jar file located in the Android Studio/lib/junit-4.10.jar. – Seishin May 16 '13 at 20:19

4 Answers4

26

Seems there's a lot of general issues on importing modules to Android Studio, not just ActionBarSherlock, this answer might also address those. (However the last steps relating to junit are particular to abs)

The steps below allowed me to get ActionBarSherlock running with no issues.

1) Download latest ABS here: http://actionbarsherlock.com/

2) Extract ABS you should have a directory in there called "actionbarsherlock". Copy that to your Android Studio workspace. and rename to ActionBarSherlock (changed casing) -- > I now have my Android Studio Projects under \*documents*\Android Workspace\ As opposed to \Eclipse Workspace\

So you should now have something like :

\*documents*\Android Workspace\ActionBarSherlock\

Along with your main project maybe:

\*documents*\Android Workspace\TestProject\

3) Open Android Studio load your TestProject then goto File> Import Module... Now navigate to ActionBarSherlock under \*documents*\Android Workspace\ActionBarSherlock\ Click Ok and next all the way to finish. It will ask if you want to set a dependancy to the new Module (or at least mine did) click OK

4) at this point when compiling I was getting errors in \ActionBarSherlock\test\ complaining about Junit. I simply deleted the \Test\ directory from my ABS Module under project view. Right click \test\ > Delete.... You could also include the junit jar file but I don't think its necessary

5) you should now be able to compile without errors

Hopefully that helps someone.

Essentially though, I needed to re-download a completely fresh ABS, expunge my old project's ABS (which was probably quite old) then Import Module...

wired00
  • 13,930
  • 7
  • 70
  • 73
  • 2
    I'm confused why I see two modules for my project, "ABSTest" and "ABSTest-ABSTest" and which one do I use in this case? – Parth Mehrotra May 21 '13 at 01:09
  • And another question I keep seeing floating around Module importing using AndroidStudio is: At should I create the module from existing sources? Or shall I use the Maven option? – Parth Mehrotra May 21 '13 at 01:15
  • 2
    I have no `Import Module` in the `File` menu (on Android Studio 0.2.8) – Konrad Morawski Sep 15 '13 at 21:36
  • @KonradMorawski Hi I've just updated to the latest version of `Android Studio` and it definately still shows `Import Module`. It should be the 4th item down the list, File > New Project, New Module, Import Project, Import Module. Make sure your running the latest version Android Studio > Check for Updates... Hope that helps – wired00 Sep 16 '13 at 00:35
  • @wired00 thanks for an answer. I tried looking for this option under the `File` menu. See the screenshot: http://i39.tinypic.com/2w74ktj.jpg. As for making sure I have the latest version installed - I'm using 0.2.8, as I wrote. It's latest as of now - see http://tools.android.com/recent – Konrad Morawski Sep 16 '13 at 21:16
  • @KonradMorawski Ok I think windows version is laid out differently. Try using `File` > `Project Structure` > `Module` > `Import Module` This thread seems to have that outlined (http://stackoverflow.com/questions/16588064/how-do-i-add-a-library-project-to-the-android-studio). If that works for you I'll update this answer with those details for windows. – wired00 Sep 16 '13 at 23:26
  • OK so the mistery is unsolved :) I'm on Windows. Thanks. I have happily resolved the issue following the guidelines in this answer http://stackoverflow.com/a/16639227/168719 +1 for explanations anyhow – Konrad Morawski Sep 17 '13 at 08:52
  • My problem is I cant even import the project, its the ArduDroid from here (https://github.com/xgxzatx/ArduDroid) which uses the sherlock library, but when I open Android Studio (1.5.1 Dec 1-2015) I get an unrecoverable error and nothing ever gets imported into the new AS project folder. Any ideas? – marciokoko Mar 22 '16 at 18:39
  • I am getting Error:Execution failed for task ':abs_lib:processDebugResources'. > Unknown android attribute 'SherlockSpinner' error. I am new to android. I got old code developed in eclise. Tried to import to studio. Stuck with this error. – Durgaprasad Mar 09 '18 at 09:54
6

This works for me..

first, followed an answer provided by wired00

and I made some changes from here.

I made a build.gradle file in ActionBarSherlock library project by Generate Gradle build files from Eclipse.

edit build.gradle(for ActioBarSherlock library project) , Add a line in dependencies {} compile files('libs/android-support-v4.jar')

edit build.gradle(for my project), delete compile files('libs/android-support-v4.jar') and add compile project(':abs') abs should be ActionBarSherlock library project name.

edit settings.gradle, add ,':abs'

delete android-support-v4.jar files except the one in the ActionBarSherlock library project

Kuool
  • 621
  • 5
  • 2
2

I encountered similar issue, but due to a separate problem, I can't download the latest ActionBarShelock to fix the problem as wired00 described.

If you need to stick with your existing ABS version, see if this works for you:

  1. Click File->Project Structure.
  2. You should see 'ActionBarSherlock' in the module list, click it.
  3. Click the 'Dependencies' tab, very likely you do not have android support library v4 in there.
  4. Click the '+' button at the bottom, and add android-support-v4 as a dependency. If you imported the project from Eclipse, Android Studio may have already imported the support JAR file as a library and you can use it directly. Otherwise, you may need to use the 'jars or directories' option and select the support jar file from a directory.
  5. If your main module or other modules are also using the support library, you may need to change the setting 'Compile' to 'Provided' if you get 'DEX Already Added' errors.
  6. You should be able to compile your ABS mobule now. If you get 'hamcrest' or 'junit' compilation errors, you may delete the 'test' folder in your ABS project as wired00 mentioned.
azgolfer
  • 15,087
  • 4
  • 49
  • 46
0

i also faced the same issue. i even follow the steps similar to importing ABS Library. But i was still getting the same error. Finally i solved this issue. Solution: After following the steps similar for importing ABS Library,

  1. Re-compile your project (Right click on your project and click on 'Compile Module "YourApp" ')
  2. Re-compile the Library Project (Right click on Library project and click on 'Compile Module "library" ')

That's it..

WarrenFaith
  • 57,492
  • 25
  • 134
  • 150
Yasir Ali
  • 1,785
  • 1
  • 16
  • 21
  • after doing this also...it started to give same error "cannot find symbol class FragmentActivity"...error count 100 and warning 17..any solution? – CoDe Aug 25 '13 at 10:34