简体   繁体   中英

Migrating from eclipse + SVN to Android Studio

We currently use Eclipse for Android development , and our projects are synchronized to an SVN .

Current structure :

  • Android Application 1
  • Android Application 2
  • Android library 1
  • Android library 2

It is therefore independent projects on SVN.

Details :

Android Android app 1 need library 1 Android Android app 2 need library 1 and 2 , etc ...

Until then, it is quite normal.

The challenge is to move to the project structure in Android Studio / IntelliJ , while ensuring compatibility with eclipse . So changing NOTHING in the current structure of SVN .

And I just can't handle how to do this with the IntelliJ structure (projects, modules, ... ) .

In addition there appears to have a problem with Android Studio, it is impossible for me to IMPORT module , I can create one, but not import one...

And that's not all , in "Open Module settings" , only Android SDK Appears for EACH project. So I can not handle modules ...

I tried to import each project one by one with a checkout from Subversion, it works, but how to link projects to each other then ? I end up with a project structure as in eclipse, and I guess that is not good.

In Android Studio, a module is dependent on a project (right ?), but I do not want a library dependent of any project.

Please, do not hesitate to ask any information. I'm sure that I didn't say everything, because I try that from 2 days now, so I've try many many things... I just can't get it.

What's wrong ?

Thanks a lot

Best Regards

Firstly you should generate a gradle build file for each of your projects. You can do this in Eclipse. Go to File > Export > Android Gradle Files.

At the end you should have this architecture on you project :

root
    build.gradle
    settings.gradle

    AndroidProj1
        build.gralde
    AndroidProj2
        build.gradle
    AndroidLib1
        build.gralde
    AndroidLib2
        build.gradle

Make sure that all your projects are refereced in your settings.gradle. You should have these lines:

:AndroidProj1
:AndroidProj2
:AndroidLib1
:AndoridLib2

Then, in build.gradle files of your projects, you can make references of other projects. If AndroidProj1 depends on AndroidLib1, then you should have these lines in build.gradle of AndroidProj1:

apply plugin: 'com.android.application'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':AndroidLib1')
}

When Eclipse generate gradle files, it keeps the old directory structure so you can keep using Eclipse.

In Android Studio, you should import only the root project. It will find the underlying projects.

Then you can try to build your projects.

For each project within Eclipse, you should go to File > Export > Android Gradle Files and then use these files to import into Android Studio.

However, I think once imported into Android Studio, it is then not compatible with Eclipse. I have had many issues trying to reference libraries for my apps in Android Studio and I eventually gave up. Android Studio is still in a very early release and therefore there are still lots of bugs and issues within Android Studio. Therefore, I wouldn't recommend moving to Android studio as yet and stick to Eclipse for the time being until a stable version is released.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM