我将Android Studio
项目转换为Eclipse
项目后, build.gradle 中的Android Studio
出现问题。
我花了2个多小时找到一个解决方案,没有结果!!
build.gradle code:
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.
屏幕截图
任何帮助将不胜感激......
答案 0 :(得分:4)
此错误消息表示它根本无法找到该插件。在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创建的项目中,“新建项目”向导会将其放入项目中的顶级构建文件中,但根据屏幕截图,您的项目看起来只有一个构建文件,因此&#39;只有一个地方可以放置它。