问题
I have Android project with standard build.gradle (also I added android annotations).
Also I installed Gradle plugin (from http://dist.springsource.org/release/GRECLIPSE/e4.3/) to my Eclipse (Kepler) and converted project to Gradle project.
Unfortunately I cannot run Gradle build on my Eclipse (in cmd line everything works).
My question is how to make Eclipse works with Gradle just like with Maven.
回答1:
In order to be able to build an Android gradle project with Eclipse I followed these instructions:
Install these Eclipse plugins:
- Gradle IDE (3.4.0)
- Android Development Tools (22.3.0)
If you have an old-style android project layout, change your build.gradle to configure source directories as explained in the Android Gradle User Guide.
If you have a gradle android project layout, create two symbolic links into the root of your project.
ln -s src/main/res res
ln -s src/main/AndroidManifest.xml AndroidManifest.xml
I hope it helps!
回答2:
Read Is it possible to use the Gradle build system for Android with Eclipse?
try Nodeclipse/Enide Gradle for Eclipse (marketplace)
Some screenshots for Gradle for Eclipse:


回答3:
I use neon eclipse for android developer with gradle integration. Also, I use gradle plugin (com.github.ginvavilon:android-eclipse) for generating .project and .classpath for new structure of android project (src/main/java; src/main/res ...). Flavors and build types are supported. And use that project as gradle-project
回答4:
- Install Gradle:
a. http://gradle.org/gradle-download/ b. Choose 2.1 from previous releases section. c. Unzip at convenient folder.(Ex : D:\Graddle\gradle-2.1) d. Set system environment variables. i. GRADLE_HOME as D:\Graddle\gradle-2.1) ii. GRADLE_OPTS as -XX:MaxPermSize=512m iii. %GRADLE_HOME%\bin to Path iv. Set ANDROID_HOME ( Ex: D:\android-sdk) v. Append “%ANDROID_HOME %\platform-tools” to path.
e. Open command prompt and check gradle is set. May use gradle -version to check.
Install Gradle eclipse PlugIn: a. Launch Eclipse b. Help > Eclipse Market Place c. Search “gradle” d. In that choose “Nodeeclipse/enide” e. Select all listed, accept & install. f. Restart eclipse once installed.
Set Gradle & Java Homes : a. Launch eclipse. b. Window > Preferences > Gradle EnIDE c. Set these if not set : i. Gradle home to use is set ( Ex: D:\Graddle\gradle-2.1) ii. Alternate JAVA_HOME to use is set ( Ex : C:\Program Files (x86)\Java\jdk1.7.0_60) iii. JVM options for GRADLE_OPTS is set to “-XX:MaxPermSize=512m”
Build the Project: a. Expand PhoneDishAnywhere in eclipse Java explorer. b. Right click on build.gradle c. Run As > Gradle GUI d. Comand Line : gradle clean build e. Wait for build to complete : First time build will take several minutes. f. If Build dex error or Java heap space error : i. Open build.gradle in editor. ii. Set appropriate javaMaxHeapSize based on your java (javaMaxHeapSize=1024M for 32bit Java,2048M for 64bit Java) iii. May comment signing (//apply from: "$rootProject.projectDir/jenkins_config/gradle/signing.gradle";) to avoid signing for debug build. iv. Build again after these fixes.
Install Build On device: a. Connect the device to m/c. b. Right click on build.gradle c. Run As > gradle installDebug Gradle Android start d. Wait for install to complete
来源:https://stackoverflow.com/questions/19912393/is-there-any-way-to-integrate-eclipse-with-gradle-in-android-project