How to Import Eclipse Library Project from Github to Android Studio Project

How to import eclipse library project from github to android studio project?

If you're importing a library as source code into a Gradle-based project, then at the moment there's no super-easy way to do it (sorry, it's on the to-do list, see https://code.google.com/p/android/issues/detail?id=62122) so you'll have to author your own build file for the library. Actually, it might be easier to use the New Module wizard to set up the build file and directory structure, then you can trim it down and copy the files over. This set of steps should get you up and running. It seems like a lot of steps but it should hopefully go pretty quick.

  1. From the File menu, choose New Module...
  2. From the wizard that comes up, choose Android Library
  3. From the next page of the wizard, give it the module name HoloCircularProgressBar, and uncheck the options for Create custom launcher icon and Create activity.
  4. Click Finish on the wizard.

It should add the new module to your project, so you'll end up with something like this:

Project view after adding new empty library


  1. Delete everything inside the src/main folder.
  2. Now copy AndroidManfiest.xml, ic_launcher-web.png, res, and src from the HoloCircularProgressBar source into the src/main folder.
  3. Rename the src folder that you just copied into src/main to java.
  4. The New Module wizard left some things in the build.gradle file in your HoloCircularProgresBar module/directory (make sure you're editing that one, not the one for your main app module) we don't need. Remove the dependencies block and the release block.

At this point you should hopefully be able to build successfully. Now if you want to actually use the module:


  1. Go to File > Project Structure... > Modules > Your main module > Dependencies.
  2. Click on the + button to add a dependency, choose Module dependency, and select HoloCircularProgressBar from the list.

Now import statements and usages of the library should work, and you should be good to go.

Import Eclipse Project from Github to Android Studio - Parse.com tutorial

You should add to your app build.gradle google play services dependencies:

compile 'com.google.android.gms:play-services:+'

This is my app build.gradle after importing project

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
applicationId "com.parse.anywall"
minSdkVersion 11
targetSdkVersion 23
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:23.1.0'
compile 'com.google.android.gms:play-services:+'
compile files('libs/Parse-1.6.0.jar')
}

How to import open source library as an external project into Android Studio?

File-->New-->import Module.

File -->Project Structure-->click on '+' Left Corner-->Module Dependency.

Import an eclipse android project with version control system into Android Studio

Here is the step by step solution to do it.

  1. Open Android Studio -> Import Project-> Select your project directory. (In above case "MyApp")
    Remember Select the directory which contains Manifest file otherwise new "direct import wizard" doesn't
    get triggered and android studio uses old import wizard.
  2. Android Studio will create a copy of your project "MyApp_imported" with new directory structure.
  3. Copy your existing ".git" directory inside "MyApp_imported"
  4. Android Studio -> VCS -> Enable version control
    This will make Android Studio use your existing repository for imported project. Though imported project has
    different directory structure but git handles them pretty well.
    You might want to also call git add . and git add -u in the root folder of the imported project to make sure all new files are added and existing file moves are detected by git.
  5. Android Studio -> Changes
    Review all files and commit. Git will automatically handle new directory structure and file history etc will not be lost.
  6. Now you can share it on github/Bitbucket by
    VCS-> Share it on GitHUb
    Note:- For bitbucket you will have to install "Bitbucket plugin" for Android Studio.


Related Topics



Leave a reply



Submit