如何将《神探夏洛克》的动作条导入到等级项目中?

时间:2023-01-17 13:57:56

I've imported Module to Android Studio using steps posted this question: Problems importing project into Android Studio regarding ActionBarSherlock

我已经将模块导入到Android Studio,使用的步骤是:关于ActionBarSherlock,将项目导入到Android Studio的问题

The IDE is working well, but It doesn't affect the build. From Android Studio: Are Library Project dependencies picked from project.properties?

IDE运行良好,但它不会影响构建。从Android Studio:是否从Project .properties中选择库项目依赖项?

If you use Gradle, project.properties is completely ignored. You should not use the Module Settings to add dependencies now as it only changes the IDE but not the Gradle based build system (we'll fix this in later versions).

如果你使用等级,项目。属性是完全忽略。现在不应该使用模块设置来添加依赖项,因为它只更改IDE,而不是基于等级的构建系统(我们将在以后的版本中对此进行修正)。

I've modified dependencies of build.gradle

我修改了build.gradle的依赖性

dependencies {
    compile files('libs/android-support-v4.jar')
    compile project(":ActionBarSherlock")
}

But it build prints different error now: Gradle:

但是它现在打印出来的错误不同:

FAILURE: Build failed with an exception.
* Where:
Build file '...PATH.../PROJECT_NAME/PROJECT_NAME/build.gradle' line: 13
* What went wrong:
A problem occurred evaluating project ':PROJECT_NAME'.
> Project with path ':ActionBarSherlock' could not be found in project ':PROJECT_NAME'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

3 个解决方案

#1


11  

Just a notice: at the moment proper support for importing external libraries that include resources (aar library files) does not seem to be supported properly yet. It is the reason why ActionBarSherlock is not yet releasing their project as an aar file. However if you put the code of the external library (ActionBarSherlock) in the directory of your project it should be able to work.

请注意:目前还没有适当支持导入包含资源(aar库文件)的外部库。这就是为什么ActionBarSherlock还没有以aar文件的形式发布他们的项目。但是,如果将外部库(ActionBarSherlock)的代码放到项目的目录中,它应该能够工作。

Now, to get multiple projects working create a file called 'settings.gradle' in the root of your project and put the following lines in there:

现在,要让多个项目工作,创建一个名为“settings”的文件。在你的项目的基础上加上以下几行:

include 'actionbarsherlock'
include 'yourproject'

Now make sure you have the two subdirectories in the same folder as gradle.settings: actionbarsherlock and yourproject. In those subdirectories should be the build file (build.gradle) and the rest of your project. The structure should be something like this:

现在,请确保将两个子目录放在与gradle相同的文件夹中。设置:actionbarsherlock和志愿者项目。在这些子目录中应该是构建文件(build.gradle)和项目的其他部分。结构应该是这样的:

Project
|-- settings.gradle
|-- actionbarsherlock
|   |-- build.gradle
|   |-- AndroidManifest.xml
|   |-- src
|   |   `-- *
|   |-- res
|   |   `-- *
|   `-- ...
`-- yourproject
    |-- build.gradle
    `-- src
        `-- main
            |-- AndroidManifest.xml
            |-- java
            |   `-- *
            `-- res
                `-- *

Hopefully that makes sense, though this is usually the way you build multiple depending projects of your own. You usually do not want the code of external libraries (like ActionBarSherlock) to be in your project-repository, but like I said, doing it properly isn't ready yet.

希望这是有意义的,尽管这通常是您构建多个依赖于您自己的项目的方式。您通常不希望外部库(如ActionBarSherlock)的代码出现在项目存储库中,但是正如我所说,正确地执行它还没有准备好。

Also, just a notice, ActionBarSherlock's stable versions do not yet have a gradle build file. Use ActionBarSherlock's dev branch from git to get the right source files: https://github.com/JakeWharton/ActionBarSherlock/tree/dev/actionbarsherlock

另外,请注意,ActionBarSherlock的稳定版本还没有一个渐变构建文件。使用来自git的ActionBarSherlock的dev分支获取正确的源文件:https://github.com/JakeWharton/ActionBarSherlock/tree/dev/actionbarsherlock

#2


23  

THIS ANSWER IS DEPRICATED: Please check out AppCompat as a replacement!

这个答案被剥夺了:请查看AppCompat作为替换!

dependencies {
    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
    compile 'com.android.support:support-v4:18.0.+'
}

Found that on the ActionBarSherlock site and ActionBar Sherlock with Android Studio 0.2.2

发现在ActionBarSherlock网站和ActionBarSherlock与Android Studio 0.2.2

ABS has released their aar.

ABS已经发布了aar。

Also a sample using it on github:

还有一个在github上使用它的例子:

https://github.com/JakeWharton/ActionBarSherlock-Gradle-Sample

https://github.com/JakeWharton/ActionBarSherlock-Gradle-Sample

The support library version number is not critical make sure you always use the most up to date version permitted by your project. The actual inclusion of the support jar as a whole is NOT optional

支持库版本号并不重要,请确保始终使用项目允许的最新版本。实际包含支持jar作为一个整体是不可选的。

#3


2  

I hope we can have a way of showing people that some of these libraries are deprecated.

我希望我们能有一种方法向人们展示这些库中的一些已经被废弃了。

AppCompat should now be used instead of the deprecated ActionbarSherlock.

现在应该使用AppCompat,而不是不赞成的ActionbarSherlock。

#1


11  

Just a notice: at the moment proper support for importing external libraries that include resources (aar library files) does not seem to be supported properly yet. It is the reason why ActionBarSherlock is not yet releasing their project as an aar file. However if you put the code of the external library (ActionBarSherlock) in the directory of your project it should be able to work.

请注意:目前还没有适当支持导入包含资源(aar库文件)的外部库。这就是为什么ActionBarSherlock还没有以aar文件的形式发布他们的项目。但是,如果将外部库(ActionBarSherlock)的代码放到项目的目录中,它应该能够工作。

Now, to get multiple projects working create a file called 'settings.gradle' in the root of your project and put the following lines in there:

现在,要让多个项目工作,创建一个名为“settings”的文件。在你的项目的基础上加上以下几行:

include 'actionbarsherlock'
include 'yourproject'

Now make sure you have the two subdirectories in the same folder as gradle.settings: actionbarsherlock and yourproject. In those subdirectories should be the build file (build.gradle) and the rest of your project. The structure should be something like this:

现在,请确保将两个子目录放在与gradle相同的文件夹中。设置:actionbarsherlock和志愿者项目。在这些子目录中应该是构建文件(build.gradle)和项目的其他部分。结构应该是这样的:

Project
|-- settings.gradle
|-- actionbarsherlock
|   |-- build.gradle
|   |-- AndroidManifest.xml
|   |-- src
|   |   `-- *
|   |-- res
|   |   `-- *
|   `-- ...
`-- yourproject
    |-- build.gradle
    `-- src
        `-- main
            |-- AndroidManifest.xml
            |-- java
            |   `-- *
            `-- res
                `-- *

Hopefully that makes sense, though this is usually the way you build multiple depending projects of your own. You usually do not want the code of external libraries (like ActionBarSherlock) to be in your project-repository, but like I said, doing it properly isn't ready yet.

希望这是有意义的,尽管这通常是您构建多个依赖于您自己的项目的方式。您通常不希望外部库(如ActionBarSherlock)的代码出现在项目存储库中,但是正如我所说,正确地执行它还没有准备好。

Also, just a notice, ActionBarSherlock's stable versions do not yet have a gradle build file. Use ActionBarSherlock's dev branch from git to get the right source files: https://github.com/JakeWharton/ActionBarSherlock/tree/dev/actionbarsherlock

另外,请注意,ActionBarSherlock的稳定版本还没有一个渐变构建文件。使用来自git的ActionBarSherlock的dev分支获取正确的源文件:https://github.com/JakeWharton/ActionBarSherlock/tree/dev/actionbarsherlock

#2


23  

THIS ANSWER IS DEPRICATED: Please check out AppCompat as a replacement!

这个答案被剥夺了:请查看AppCompat作为替换!

dependencies {
    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
    compile 'com.android.support:support-v4:18.0.+'
}

Found that on the ActionBarSherlock site and ActionBar Sherlock with Android Studio 0.2.2

发现在ActionBarSherlock网站和ActionBarSherlock与Android Studio 0.2.2

ABS has released their aar.

ABS已经发布了aar。

Also a sample using it on github:

还有一个在github上使用它的例子:

https://github.com/JakeWharton/ActionBarSherlock-Gradle-Sample

https://github.com/JakeWharton/ActionBarSherlock-Gradle-Sample

The support library version number is not critical make sure you always use the most up to date version permitted by your project. The actual inclusion of the support jar as a whole is NOT optional

支持库版本号并不重要,请确保始终使用项目允许的最新版本。实际包含支持jar作为一个整体是不可选的。

#3


2  

I hope we can have a way of showing people that some of these libraries are deprecated.

我希望我们能有一种方法向人们展示这些库中的一些已经被废弃了。

AppCompat should now be used instead of the deprecated ActionbarSherlock.

现在应该使用AppCompat,而不是不赞成的ActionbarSherlock。