9

I have migrated a project from Eclipse. The project still has the "old" project file structure from eclipse (see http://developer.android.com/tools/projects/index.html). Is there a way to automatically change the file structrue to the new system (see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Project-Structure)? If I understand http://developer.android.com/sdk/installing/studio-tips.html Project Structure section correctly this should have happended when migrating but it did not (maybe a mistake by me). So once again my questions: is it possible to change the file structure automatically? If not, what do I have to change? What do I have to change in the build.gradle? What are obsolete files / directories?

Thanks!

Stephan

1
  • 1
    Welcome to Stackoverflow! If you find a response is helpful, please up vote it. If the response successfully answers your question, please click the green check mark next to it to accept the answer. Also please look at stackoverflow.com/questions/how-to-ask for advice on how to write a good question
    – Rémi F
    Aug 20, 2013 at 19:24

1 Answer 1

4

While migrating your project from Eclipse to Android Studio, no change have been done on project structure. The only that have changed are new .iml and .gradle files.

Your java code stays in project/src/ folder, and has not been moved in project/src/main/java folder (like in a new created project from AndroidStudio).

Your AndroidManifest file also stays in the project/ folder and has not been moved in project/src/main/ folder (like in a new created project from AndroidStudio).

At migration, the build.gradle file is customized in order to be able to compile with the old structure is described in the gradle documentation : Configuring the Structure

For a new created project in AndroidStudio, the sourceSets part of the build.gradle file :

sourceSets {
    main.java.srcDirs = ['src/java']
    main.resources.srcDirs = ['src/resources']
}

For a migrated project from Eclipse, the sourceSets part of the build.gradle file must be that :

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']
        }

        instrumentTest.setRoot('tests')
    }
}

With that, you should be able to customize your project structure and build accordingly.

4
  • 1
    Why is Eclipse not migrating to Studio with main? What's the reason? Pros/Cons?
    – powder366
    Nov 23, 2013 at 19:40
  • 1
    I am not sure but I think this is for retrocompatibility : perhaps Ant is not able to compile idea-style projects (with main folder). You can do it manually and then simplify your build.gradle file
    – Rémi F
    Nov 25, 2013 at 22:27
  • 1
    I did it manually, a bit tricky but it worked (generated a dummy project in Studio for comparison), would be good with an option to choose... Thanks...
    – powder366
    Nov 26, 2013 at 10:33
  • did the same thing : a good way to learn how an idea project is made.
    – Rémi F
    Nov 27, 2013 at 21:57

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.