Reputation: 5039
In my team, we developed a library in Eclipse with ADT plugin.
We have a "big" demo application and several "mini" applications using the library to test different aspects.
Since the official IDE for Android is now Android Studio and ADT plugin seems to be abandoned (last update on October '14), we are studying the migration to Android Studio.
On Eclipse, we can load projects from different locations in the disk within the same workspace. We like this because this allows us to have our library project loaded aside with our demos and we can also load temporal projects in the same workspace referencing the project library.
I see there are two ways to migrate, but I find cons in both:
Importing the Eclipse project directly into Studio
This option works but:
This changes the folders structure of all the projects. It copies the eclipse projects into the Android Studio project folder, and this would mean making changes to our internal repository.
If we want to add a temporal project to test it with our library, we'd need to import it so it will also be copied next to the "main" library and demos.
Exporting the Eclipse project from Eclipse as a Gradle project.
This option keeps the folder structure of our Eclipse projects (#1 above) but #2 above is still valid here and I also get this error when I try to Import a project from a different location.
Error:FAILURE: Build failed with an exception. * What went wrong: Task 'compileDebugSources' not found in project ':TestMemCons'. * Try: Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
So, can we migrate to Android Studio keeping the folder structure and allowing us to load other Eclipse/Android Studio projects in the same instance so they can reference our library project?
Upvotes: 1
Views: 587
Reputation: 5039
Answering my own question...
So, can we migrate to Android Studio keeping the folder structure and allowing us to load other Eclipse/Android Studio projects in the same instance so they can reference our library project?
I found you can add a temporal project as follows:
Copy the temporal test project where you want it, it only has to be inside your main project tree.
Add the test project relative path to the settings.gradle
file of the main project. Ie, if you moved the test project to \Demos\Tests\Test1
:
include ':Demos:Tests:Test1'
So you can have something like this:
include ':Sources:Android' //library
include ':Demos:Android' //Features Demo
include ':Demos:Tests:Test1' //Test1
Create a build.gradle
file for the test project. Ie, \Demos\Tests\Test1\build.gradle
:
apply plugin: 'android'
dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
compile project(':Sources:Android')
}
android {
compileSdkVersion 7
buildToolsVersion "21.1.2"
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')
}
}
In this case, I'm adding a dependence to my library, that is a library module in the main project at \Sources\Android
.
So, if you want to keep your folder structure, you can go for the option 2 "Exporting the Eclipse project from Eclipse as a Gradle project" and still load test/temporal projects as described above.
The only problems I see here are:
settings.gradle
in your main project and remove the test project folder to get the main project clean as before the test.Upvotes: 1