我想对我的Android / Eclipse项目使用gradle,因为我希望能够在已发布版本的旁边安装我的应用程序的开发版本(如此处所示:What is a practical way to install stable and development app versions simultaneously?)
对我来说,使用命令行可以。
因此,我将项目的src文件夹移至src / main / java并创建了一个build.gradle
文件(如此处所述:http://www.nodeclipse.org/projects/gradle/android/Make-Android-Eclipse-project-ready-for-Android-Studio):
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
androidTest.setRoot('tests')
}
}
但是当我运行
gradle build
时,出现此错误:FAILURE: Build failed with an exception.
...
> Could not create plugin of type 'AppPlugin'.
我已经在stackoverflow上发现了该错误。有人说这是因为使用了错误版本的gradle。 (Gradle is issuing an error "Could not create plugin of type 'AppPlugin'")
我的问题:
最佳答案
经过更多研究后,最终我成功使用gradle编译了我的应用程序。
以防万一其他人有相同的问题,这是我所做的:
build.gradle
,gradlew
,gradlew.bat
和settings.gradle
(在我的情况下,是在项目上方的某些级别)。不要将这些文件移到您的项目文件夹中。 ./gradlew build
。这将自动下载gradle插件(afaik),并在[PROJECT FOLDER]/build/outputs/apk
中创建三个apk。 关于android - 将gradle用于Android/Eclipse项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28862890/