build.gradle Android Studio 中的文件错误无法应用主要和依赖项
build.gradle file error in Android Studio can't applied main & dependencies
在将 Eclipse
项目转换为 Android Studio
项目后,build.gradle 中的 Android Studio
出现问题。
我花了2个多小时寻找解决方案,没有结果!!
build.gradle代码:
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 19
buildToolsVersion "17.0.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
它给出:Error:(1, 0) Plugin with id 'com.android.application' not found.
屏幕截图
任何帮助将不胜感激...
这个错误信息意味着它根本找不到插件。在Gradle中,你需要告诉它去哪里找插件,这和告诉它去哪里解决模块依赖是不同的。将此块添加到构建文件的开头:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
在 Android Studio 创建的项目中,新建项目向导会将其放入项目的顶级构建文件中,但根据屏幕截图,您的项目似乎只有一个构建文件, 所以只能放一处。
在将 Eclipse
项目转换为 Android Studio
项目后,build.gradle 中的 Android Studio
出现问题。
我花了2个多小时寻找解决方案,没有结果!!
build.gradle代码:
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 19
buildToolsVersion "17.0.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
它给出:Error:(1, 0) Plugin with id 'com.android.application' not found.
屏幕截图
任何帮助将不胜感激...
这个错误信息意味着它根本找不到插件。在Gradle中,你需要告诉它去哪里找插件,这和告诉它去哪里解决模块依赖是不同的。将此块添加到构建文件的开头:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
在 Android Studio 创建的项目中,新建项目向导会将其放入项目的顶级构建文件中,但根据屏幕截图,您的项目似乎只有一个构建文件, 所以只能放一处。