为什么不支持Android库在我的项目工作吗? [英] Why won't Android Support Libraries work in my project?

查看:236
本文介绍了为什么不支持Android库在我的项目工作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

采用Android工作室,我也跟着在 https://developer.android步骤.COM /工具/支持库/ setup.html 为acurately尽我所能,但它告诉我下面的错误:

Using Android Studio, I followed the steps at https://developer.android.com/tools/support-library/setup.html as acurately as I could, but it told me the following error:

错误:找不到方法编译()的参数[com.android.support:appcompat-v7:18.0.+]上org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated@18899229

Error:Could not find method compile() for arguments [com.android.support:appcompat-v7:18.0.+] on org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated@18899229.

请从Android SDK管理器安装Android支持库。   开放的Andr​​oid SDK管理器   

Please install the Android Support Repository from the Android SDK Manager. Open Android SDK Manager

不过,我已经安装了支持库和资料库!因为我也得到了一个错误说编译相关性不属于块,所以我改成了的classpath ,并得到以下,类似的错误:

But I have already installed the Support Repository and Library! Since I also got an error saying compile doesn't belong in the dependencies block, so I changed it to classpath, and got the following, similar error:

错误:找不到任何匹配com.android.support:appcompat-v7:18.0.+版本。   要求:       :ExpenseTracker:未指定

Error:Could not find any version that matches com.android.support:appcompat-v7:18.0.+. Required by: :ExpenseTracker:unspecified

请从Android SDK管理器安装Android支持库。   开放的Andr​​oid SDK管理器   

Please install the Android Support Repository from the Android SDK Manager. Open Android SDK Manager

正如你可以在这里看到,它仍认为未安装ASR,但由于截图证明,它是。所以我在做什么错在这里?

As you can see here, it still thinks the ASR isn't installed, but as the screenshot proves, it is. So what am I doing wrong here?

推荐答案

我觉得你把这些线路中的错误的文件。

I think you're placing these lines in the wrong file.

他们应该在模块 build.gradle 文件,而不是在项目的一(此会似乎,从截图)。

They should go in the module's build.gradle file, not in the project's one (which this would seem to be, from the screenshot).

此外,依赖标签不应该是别的孩子。是这样的:

Also, the dependencies tag should not be a child of anything else. something like:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 20
    ...
}

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

修改你有没有看到有何评论? :)

EDIT Did you see the comment? :)

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

这篇关于为什么不支持Android库在我的项目工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆