score:1
Maybe I'm missing something very obvious, but isn't the eclipse plugin what you're looking for? This generates a .project file as well as a .classpath file and updates these as needed when run subsequent times.
There is also an IDEA plugin, though I haven't used this one and can't speak to it.
Hope that helps.
score:2
As answered in Issue 57668 by Android team (raised by @arcone)
Project Member #2 x...@android.com
The eclipse plugin is not compatible with the android plugin.
You will not be able to import an Android gradle project into Eclipse using the default Gradle support in Eclipse.
To make it work in Eclipse we will have to change the Gradle plugin for Eclipse, the same way we are modifying the Gradle support in IntelliJ
That is Android team is working on gradle plugin for IntelliJ and gradle plugin for Eclipse needs to be updated too.
What is possible with Eclipse now is
.1. import the project as general project
.project
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>OpenSpritz-Android</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>
.2. Put 2 Eclipse . "dot" files into modules into /OpenSpritz-Android/app/src/main
and /OpenSpritz-Android/lib/src/main
.project
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>OpenSpritz-Android-app</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
.classpath
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="java"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
.3. Import as Existing Android Code into Workspace
you can then browse code in familiar way, but even after that you won't be able to run with Eclipse ADT.
.4.
Now you can run build and tasks with gradle
CLI or Nodeclipse/Enide Gradle for Eclipse
(marketplace)
discuss at https://github.com/Nodeclipse/nodeclipse-1/issues/148
score:2
The following worked for me
eclipse.classpath.plusConfigurations += configurations.compile
eclipse.classpath.file {
beforeMerged { classpath ->
classpath.entries.removeAll() { c ->
c.kind == 'src'
}
}
withXml {
def node = it.asNode()
node.appendNode('classpathentry kind="src" path="src/main/java"')
node.appendNode('classpathentry kind="src" path="src/debug/java"')
node.appendNode('classpathentry kind="src" path="gen"')
node.children().removeAll() { c ->
def path = c.attribute('path')
path != null && (
path.contains('/com.android.support/support-v4')
)
}
}
}
eclipse.project {
name = 'AndroidGradleBasic'
natures 'com.android.ide.eclipse.adt.AndroidNature'
buildCommand 'com.android.ide.eclipse.adt.ResourceManagerBuilder'
buildCommand 'com.android.ide.eclipse.adt.PreCompilerBuilder'
buildCommand 'com.android.ide.eclipse.adt.ApkBuilder'
}
Source - http://blog.gouline.net/2013/11/02/new-build-system-for-android-with-eclipse/
score:2
I've created a new Gradle plugin that generates the appropriate Eclipse .project
and .classpath
files, based on the answer provided by Johannes Brodwall on this stack overflow.
See https://github.com/greensopinion/gradle-android-eclipse for details.
score:3
There are four issues with the combination of the Gradle plugins 'com.android.application' and 'eclipse': First, the configuration classpaths are not added to Eclipse's classpath, but this is easy to fix. Second, something must be done about the .AAR-dependencies. This was a bit trickier. Third, we need to include the generated sources for things like R.java. Finally, we need to include Android.jar itself.
I was able to hack together a gradle configuration that would generate proper .classpath
files for Eclipse from an Android Studio build.config
. The effects were very satisfying to my CPU fan, which had been running constantly with Android Studio. Eclipse sees the resulting project as a fully functional Java project, but only that.
I ended up putting the following directly in build.gradle in my app-project:
apply plugin: 'eclipse'
eclipse {
pathVariables 'GRADLE_HOME': gradle.gradleUserHomeDir, "ANDROID_HOME": android.sdkDirectory
classpath {
plusConfigurations += [ configurations.compile, configurations.testCompile ]
file {
beforeMerged { classpath ->
classpath.entries.add(new org.gradle.plugins.ide.eclipse.model.SourceFolder("src/main/java", "bin"))
// Hardcoded to use debug configuration
classpath.entries.add(new org.gradle.plugins.ide.eclipse.model.SourceFolder("build/generated/source/r/debug", "bin"))
classpath.entries.add(new org.gradle.plugins.ide.eclipse.model.SourceFolder("build/generated/source/buildConfig/debug", "bin"))
}
whenMerged { classpath ->
def aars = []
classpath.entries.each { dep ->
if (dep.path.toString().endsWith(".aar")) {
def explodedDir = new File(projectDir, "build/intermediates/exploded-aar/" + dep.moduleVersion.group + "/" + dep.moduleVersion.name + "/" + dep.moduleVersion.version + "/jars/")
if (explodedDir.exists()) {
explodedDir.eachFileRecurse(groovy.io.FileType.FILES) {
if (it.getName().endsWith("jar")) {
def aarJar = new org.gradle.plugins.ide.eclipse.model.Library(fileReferenceFactory.fromFile(it))
aarJar.sourcePath = dep.sourcePath
aars.add(aarJar)
}
}
} else {
println "Warning: Missing " + explodedDir
}
}
}
classpath.entries.removeAll { it.path.endsWith(".aar") }
classpath.entries.addAll(aars)
def androidJar = new org.gradle.plugins.ide.eclipse.model.Variable(
fileReferenceFactory.fromPath("ANDROID_HOME/platforms/" + android.compileSdkVersion + "/android.jar"))
androidJar.sourcePath = fileReferenceFactory.fromPath("ANDROID_HOME/sources/" + android.compileSdkVersion)
classpath.entries.add(androidJar)
}
}
}
}
// We need build/generated/source/{r,buildConfig}/debug to be present before generating classpath
// This also ensures that AARs are exploded
eclipseClasspath.dependsOn "generateDebugSources"
// Bonus: start the app directly on the device with "gradle startDebug"
task startDebug(dependsOn: "installDebug") << {
exec {
executable = new File(android.sdkDirectory, 'platform-tools/adb')
args = ['shell', 'am', 'start', '-n', android.defaultConfig.applicationId + '/.MainActivity']
}
}
Run gradle eclipse
and you will have an Eclipse-project that can be imported and compiled. However, this project acts as a normal Java-project. In order to build the apk, I have to drop back to gradle command line and execute gradle installDebug
. gradle processDebugResources
picks up changes in Android XML files and regenerates the files under build/generated/source
. I use the "monitor" program with Android SDK to view the app logs. I have so far not found any way to debug without Android Studio.
The only features I miss from Android Studio are debugging (but who has time for bugs!) and editing resources visually.
score:9
Gradle itself is a generic build tool, it is not created specifically for Android.
All the functionality is enabled using plug-ins. Traditionally, build plug-ins don't generate project structure. That's the job of project specific tools. The Android plug-in for Gradle follows this.
The problem is that current android
tool in SDK generates old type of project structure (ant builds). The new project structure can only be generated via Android Studio.
There is a concept of archetypes in tools like Maven, which allow using project templates. Gradle does not support that yet (requests have been made for this feature).
Refer to this thread: http://issues.gradle.org/browse/GRADLE-1289 , some users have provided scripts to generate structure.
Build Initialization feature is in progress: https://github.com/gradle/gradle/blob/master/design-docs/build-initialisation.md
Hopefully some one can write a script to do that, refer to this guide for new project structure: http://tools.android.com/tech-docs/new-build-system/user-guide
Update
There is now an official Android IDE: Android Studio . It is based on Intellij and the new build system is Gradle based.
Source: stackoverflow.com
Related Query
- How to use Gradle to generate Eclipse and Intellij project files for Android projects
- How to use Linked Files in Eclipse for PhoneGap project with Android
- How to generate a jar file for a java project and use the jar in an android project
- How to version control an Android project on Github and use intellij and eclipse IDE by different team members?
- How to convert an Eclipse Android project to use Ant for build?
- How to use the same source from PhoneGap Build and PhoneGap Android project in Eclipse
- How create a java project for both intellij and eclipse ide's
- How to generate Ant and Maven build files for an Eclipse Java project?
- How to use the same SDK for Android Studio and Eclipse (MAC version)
- How can I co-locate files between an sbt project and an Eclipse Android project?
- How to build and run android project with gradle in eclipse
- How do I migrate my Android Eclipse project to using Gradle and Android Studio?
- Android Eclipse library project and the library project's type resolution for project specific config files
- How to use Subversive for team development and code management in Eclipse for Android project?
- How to use new layout editor for Android project in Eclipse
- How do I build a Java Github Project in Eclipse with no maven & gradle files and no .jar files in the repo
- How to use eclipse project from github for Android development
- How to use unique AndroidSDK resources for each Android Project in Eclipse
- How to build eclipse project files for android project
- How to generate an executable jar file for a maven servlet project in eclipse and execute a class using the jar file?
- What causes imported Maven project in Eclipse to use Java 1.5 instead of Java 1.6 by default and how can I ensure it doesn't?
- How to change the background color for changed files in eclipse project explorer?
- "Selection cannot be launched and there are no recent launches” when Eclipse for Android Project Dev
- How to use sbt-eclipse to create Eclipse project files of a project?
- What is the difference between Eclipse "Import" and "Create project from existing source" for Android projects?
- How to use Eclipse for both Java and PHP?
- How to use different line wrapping for strings and other items in Eclipse for Java
- Eclipse - how to simultaneously switch working set for project explorer, call hierarchy, and search?
- How to create new android project in eclipse and share in local git repository?
- Eclipse: how to keep project source files and ant build.xml seperate from eclipse workspace?
More Query from same tag
- Set JUnit timeout in eclipse
- How to run JUnit test in Eclipse
- How to deploy an Eclipse java project into a jar file
- Counterclockwise and :gen-class
- How to ignore 'table already exists' error in eclipse
- IntelliJ Idea - How to specify options while generating domain objects from DB tables
- Need help getting simple node.js express to run
- Ruby colon hash syntax highlighting
- How to translate "consists of" into an EMF model?
- How to include hibernate jars into WEB-INF
- Programatically manipulating the Eclipse RCP EditorArea Sashes
- How do I build two android app versiosn with different API endpoints without editing code every time?
- Where is the SMS Database in Eclipse emulator
- ClassLoader.getSystemClassLoader().getResourceAsStream returns null after cloning Project
- admob adds aren't showing up in android eclipse please help
- How can I start Eclipse Neon/Oxygen under Ubuntu 17.10?
- How to teach eclipse custom pre-processor directives?
- How to add dependencies to libgdx project?
- How to bring IRunnableWithProgress always to front layer?
- Eclipse cdt couldn't resolve extern entities in c++ project
- Android project working on Motodev but crashes on Eclipse
- Activiti Diagramm Editor lacks some elements?
- Eclipse Download on Ubuntu error
- Eclipse reported "Failed to load JNI shared library"
- Java Security Exception Invalid SHA1 Jar file
- Configure Eclipse to use bash login shell for Cygwin toolchain
- adding external jars with bundles to project only in Eclipse
- Why can't java find twilio?
- Eclipse - How to change Syntax Coloring of .jrxml file for JasperReports plugin
- Eclipse merge issue with Android (Java) project