Java 将项目导入 Android Studio 关于 ActionBarSherlock 的问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16577580/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-16 07:32:01  来源:igfitidea点击:

Problems importing project into Android Studio regarding ActionBarSherlock

javaandroidintellij-ideaactionbarsherlockandroid-studio

提问by wired00

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.

还有其他人在导入项目时遇到问题ActionBarSherlock吗?我总共有 100 个错误和 17 个警告。这在Eclipse. 我按照步骤创建了Gradle 构建文件。在我尝试构建项目之前没有导入错误。

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

我还尝试重新下载新鲜的 ABS 并替换到我的项目中。

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

ABS 和 是否存在已知问题IntelliJ?(当然现在基于 Android Studio)

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

编辑:使用标准 IntelliJ IDEA 似乎没有问题。许多在线指南用于使用 ABS 进行设置。同样正如 Jake 提到的,他实际上一直在用 IntelliJ 开发这个东西

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

这是一个示例指南: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

但是,我仍然不确定为什么它在 Android Studio 中不起作用

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

Edit2:下面答案中的解决方案。简而言之:(我下载了abs最新版本,abs从我的项目中提取,删除了旧版本,然后file > import module...actionbarsherlock目录导入到我现有的项目中。注意,在我的特殊情况下,我遇到了 junit 编译错误的问题,需要删除 \test\ junit\ )

采纳答案by wired00

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)

似乎有很多关于将模块导入 的一般问题Android Studio,而不仅仅是ActionBarSherlock,这个答案也可能解决这些问题。(但是与 junit 相关的最后步骤是特定的abs

The steps below allowed me to get ActionBarSherlockrunning with no issues.

下面的步骤让我可以毫无问题地ActionBarSherlock运行。

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

1)在这里下载最新的 ABS: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\

2)提取 ABS,您应该在其中有一个名为“actionbarsherlock”的目录。将其复制到您的 Android Studio 工作区。并重命名为ActionBarSherlock (changed casing)--> 我现在有我的 Android Studio 项目,\*documents*\Android Workspace\而不是\Eclipse Workspace\

So you should now have something like :

所以你现在应该有类似的东西:

\*documents*\Android Workspace\ActionBarSherlock\

\*documents*\Android Workspace\ActionBarSherlock\

Along with your main project maybe:

与您的主要项目一起可能:

\*documents*\Android Workspace\TestProject\

\*documents*\Android Workspace\TestProject\

3)Open Android Studio load your TestProjectthen 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

3)打开 Android Studio 加载您的TestProject然后 goto File> Import Module..。现在导航到\*documents*\Android Workspace\ActionBarSherlock\单击确定下的ActionBarSherlock ,然后一路完成。它会询问您是否要为新模块设置依赖项(或至少我的),单击“确定”

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

4)在这一点上,在编译时我在\ActionBarSherlock\test\抱怨Junit. 我只是\Test\从项目视图下的 ABS 模块中删除了该目录。Right click \test\ > Delete.... 您还可以包含 junit jar 文件,但我认为没有必要

5)you should now be able to compile without errors

5)您现在应该可以无错误地编译了

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

但本质上,我需要重新下载一个全新的 ABS,清除我旧项目的 ABS(可能很旧),然后导入模块...

回答by azgolfer

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

我遇到了类似的问题,但由于一个单独的问题,我无法下载最新的 ActionBarShelock 来解决wired00 描述的问题。

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

如果您需要坚持使用现有的 ABS 版本,请查看这是否适合您:

  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.
  1. 单击文件-> 项目结构。
  2. 您应该在模块列表中看到“ActionBarSherlock”,单击它。
  3. 单击“依赖项”选项卡,很可能您在那里没有 android 支持库 v4。
  4. 单击底部的“+”按钮,并添加 android-support-v4 作为依赖项。如果你是从Eclipse导入的项目,Android Studio可能已经把support JAR文件作为库导入了,可以直接使用。否则,您可能需要使用“jars 或目录”选项并从目录中选择支持 jar 文件。
  5. 如果您的主模块或其他模块也在使用支持库,并且出现“DEX 已添加”错误,则可能需要将设置“编译”更改为“提供”。
  6. 您现在应该可以编译您的 ABS 手机了。如果您收到 'hamcrest' 或 'junit' 编译错误,您可以删除 ABS 项目中的 'test' 文件夹,如wired00 所述。

回答by Kuool

This works for me..

这对我有用..

first, followed an answer provided by wired00

首先,按照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.

我通过从 Eclipse 生成 Gradle 构建文件在 ActionBarSherlock 库项目中创建了一个 build.gradle 文件。

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

编辑 build.gradle(for ActioBarSherlock library project) ,在 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.

编辑 build.gradle(对于我的项目),删除compile files('libs/android-support-v4.jar')和添加compile project(':abs')abs 应该是 ActionBarSherlock 库项目名称。

edit settings.gradle, add ,':abs'

编辑 settings.gradle,添加 ,':abs'

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

删除除 ActionBarSherlock 库项目中的 android-support-v4.jar 文件

回答by Yasir Ali

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,

我也面临同样的问题。我什至按照类似于导入 ABS 库的步骤进行操作。但我仍然遇到同样的错误。最后我解决了这个问题。解决方法:按照类似导入ABS库的步骤后,

  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" ')
  1. 重新编译您的项目(右键单击您的项目,然后单击“编译模块“YourApp””)
  2. 重新编译库项目(右键单击库项目,然后单击“编译模块“库””)

That's it..

就是这样..