简体   繁体   中英

Importing Android Project from Eclipse into Android Studio

I have two Android apps that share several Android libraries. I have tried several ways of importing my apps from Eclipse into Android Studio (2.1.1) but I always end up with local copies of the "shared" projects in each of the two application projects. Isn't there a way to end up with only one copy? While in the project for app1, it would be nice to be able to edit a file from a dependent project and have that change be readily available when inside the project for app2.

As i understand from your question, you want to move development from Eclipse to AS (i had to do the same a while back).

I had the same issue and the only thing possible was to move one project, then use Product flavours and manually create the build.gradle file so it can share the files.

You can find more details about this on the android developers site: https://developer.android.com/studio/build/build-variants.html

Short description:

  1. Import the first project
  2. Create different folders under src with separate names: main (will be the common one for both apps), differentName1 for each flavour (probably the first app) and differentName2 (probably the second app)
  3. add in the build.gradle file the flavours as in the following example:

productFlavors {
    demo {
        applicationId "com.example.myapp.demo"
        versionName "1.0-demo"
    }
    full {
        applicationId "com.example.myapp.full"
        versionName "1.0-full"
    }
}

PS:

  1. This way, you can even have different Android Manifest files, or use just a main one, and then declare extra components under a private manifest for each build.

  2. If you need to sign each app with a different key, it has to be done also in the build.gradle app, specifying the location and extra details as in this example:

signingConfigs {
    fullRelease {
        keyAlias 'fullRelease'
        keyPassword 'fullPass'
        storeFile file('C:\\Dev_Projects\\Android\\certificateFull.jks')
        storePassword 'fullPass'
    }
    demoRelease {
        keyAlias 'demoRelease'
        keyPassword 'demoPass'
        storeFile file('C:\\Dev_Projects\\Android\\certificateDemo.jks')
        storePassword 'demoPass'
    }
}

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