问题描述
添加V4支持库到Android的工作室,我跟着这个文件:https://developer.android.com/tools/support-library/setup.html#libs-without-res但我得到一个错误。这是我做的
- 在SDK管理器>已安装Android的支持库和Android资源库。
- 转到Build.Gradle并加入该行,在dcoument给出。 Build.Gradle现在看起来是这样的:
//顶级构建文件,你可以添加常用的配置选项,所有分项目/模块。
buildscript {
库{
jcenter()
}
依赖{
类路径com.android.tools.build:gradle:0.13.2
//注意:不要在这里放置应用程序依赖;他们属于
//在单个模块build.gradle文件
}
}
allprojects {
库{
jcenter()
依赖{
编译com.android.support:support-v4:18.0.+
}
}
}
然后,我得到的建议,我同步摇篮弹出。当我同步摇篮,我得到这个错误:
错误:(20,0)未找到摇篮DSL的方法:编译()可能的原因:
我失去了任何一步?请建议。
Build.Gradle(应用程序)
应用插件:com.android.application
安卓{
compileSdkVersion 20
buildToolsVersion20.0.0
defaultConfig {
的applicationIDcom.appt.shreyabisht.staymax
的minSdkVersion 15
targetSdkVersion 20
版本code 1
VERSIONNAME1.0
}
buildTypes {
推出 {
runProguard假
proguardFiles getDefaultProguardFile('ProGuard的-android.txt'),'proguard-rules.pro
}
}
}
依赖{
编译文件树(导演:库,包括:['的* .jar'])
}
在几乎所有情况下,你的依赖,应放入单独的模块build.gradle文件,而不是在最顶层build.gradle文件。在你的情况,这意味着依赖,应加入应用
模块的build.gradle文件:
相关性{
编译文件树(导演:库,包括:['的* .jar'])
编译com.android.support:support-v4:18.0.+
}
和您应该删除整个 allprojects
顶级build.gradle的一部分。
To add V4 support libraries to android studio, i followed this document:https://developer.android.com/tools/support-library/setup.html#libs-without-res but I get an error. Here is what i did
- SDK manager> Installed Android Support Library and Android Repository.
- Go to Build.Gradle and added the line as given in the dcoument. Build.Gradle now looks like this:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.13.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
dependencies {
compile "com.android.support:support-v4:18.0.+"
}
}
}
Then, I get a popup that suggest that I sync gradle. When i sync Gradle, i get this error:
Error:(20, 0) Gradle DSL method not found: 'compile()'Possible causes:
Am i missing any step? Please suggest.
Build.Gradle(app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.appt.shreyabisht.staymax"
minSdkVersion 15
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
In almost all cases, your dependencies should be put into the individual module's build.gradle files rather than at the top most level build.gradle file. In your case, that means the dependency should be added to the app
module's build.gradle file:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:support-v4:18.0.+"
}
And you should remove the entire allprojects
part of the top level build.gradle.
这篇关于收到错误"摇篮DSL方法未找到:“编译()'"正在同步Build.Gradle时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!