Android Studio re-arranges the structure of projects imported from eclipse. I have just joined a team which is using Eclipse but I would like to use Android Studio and impact their current work practices as little as possible. Is there anyway it is possible for a team to use the 2 IDEs and share the same repo?
Asked
Active
Viewed 387 times
1 Answers
3
You'll need to set up a Gradle build file for use by Android Studio, and maintain the Eclipse project files separately; there will be no automated way of keeping the two synchronized.
Gradle-based projects like to have a different directory structure than old-style Eclipse projects; you'll need to adapt the Gradle project to use Eclipse-style directories.
There's some advice on how to do that at Maintaining directory structure during Android Studio import but the basic idea is to set up your build file like this:
android {
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')
}
}

Community
- 1
- 1

Scott Barta
- 79,344
- 24
- 180
- 163
-
Okay Scott I will try this soon, quick question though do I need to export from Eclipse and then change the build.gradle to look like this? Or is it easier / more manageable to import the eclipse project itself? Thanks. – Daniel Wilson Jul 09 '14 at 19:41
-
I would import the eclipse project itself. I know it's not really documented, but at the moment, Eclipse import from Android Studio is much more robust than Gradle export from Eclipse. – Scott Barta Jul 09 '14 at 21:20
-
Thanks Scott, I was put off by importing directly into Android Studio because it makes a copy of the whole project and that would have made it kind of awkward to commit to our repo with my terrible knowledge of Git :D So luckily I managed to export the Eclipse gradle files without too much hassle at all actually so now I'm pretty happy. – Daniel Wilson Jul 14 '14 at 14:10