Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems importing project into Android Studio regarding ActionBarSherlock

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\ )

like image 685
wired00 Avatar asked May 16 '13 01:05

wired00


People also ask

Why can't I run my project in Android Studio?

Clean and then rebuild your project. Make your project (it should work by now) Check your dependencies in gradle. At the very end you can try invalidating the cache and restarting (Recommended)

How do I organize imports in Android Studio?

In Android Studio, there is a way to automatically organize imports as you type. If you are on a Mac, go to Android Studio -> Preferences (on Windows I think it's under File -> Settings), and then under Editor -> Auto Import, you can change the settings to look like this.


2 Answers

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...

like image 143
wired00 Avatar answered Sep 29 '22 07:09

wired00


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

like image 40
Kuool Avatar answered Sep 29 '22 08:09

Kuool