Android Studio Import the GitHub download project

Source: Internet
Author: User

Now, most of the current projects from GitHub are Android studio projects, so the question is, how do I import Android studio from a project down from GitHub?

There are a number of issues that you may encounter with children's shoes that have just been transferred from Eclipse to Android studio.        Here's a quick and easy way to import a project from GitHub to Android studio and run it. First of all, Android Studio is based on Gradle to build the project, this is different from eclipse, so you want to master the use of Android Studio, it is best to familiarize yourself with Gradle first. Here is just introduction to Android studio how to import engineering, about Gradle, can self Baidu.    The following describes how Android studio imports Project.     First, install Android Sudio and create a new projectAfter you install Android Studio, you create project, and the Gradle is downloaded automatically. The project directory structure is as follows:          Second, replace the gradle version of the GitHub-downloaded project with the local version    If you import project into Android Studio directly, you will download the Gradle of the project version, which is very slow and sometimes there are various errors. So use the local existing gradle directly.The replacement method is simple, just copy the appropriate folder from the locally created project to the project that you downloaded from GitHub to replace it.      Iii. Importing project to Android Studio    File-->new-->import Project, the following dialog box will pop up, select the GitHub download project and click OK. I use Volley's demo as an example here.         After import such as:         Iv. target SDK for replacement module    You may also compile an error after the project is imported, possibly because the target SDK in the Gradle configuration in the app module is higher than the version of your local SDK. The solution is simple, open the App/build.gradle file
Apply plugin: ' Com.android.application ' android {    compilesdkversion    buildtoolsversion "22.0.1"    defaultconfig {        ApplicationID "com.timliu.volleyactivity"        minsdkversion        targetsdkversion        Versioncode 1        versionname "1.0"    }    buildtypes {        release {            minifyenabled false            Proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' Proguard-rules.pro '        }    }}dependencies {    Compile Project (': Volleysrc ')    compile Filetree (dir: ' Libs ', include: [' *.jar '])    compile ' Com.android.support:appcompat-v7:22.2.0 '}

  

    Because my local SDK version is up to 21 and this module has a targetsdkversion of 22, there is a compilation error. We just have to change the file a little bit, the following files are changed:
Apply plugin: ' Com.android.application ' android {    compilesdkversion    buildtoolsversion "20.0.0"   // You also need to modify   defaultconfig {        ApplicationID "com.timliu.volleyactivity"        minsdkversion        Targetsdkversion        versioncode 1        versionname "1.0"    }    buildtypes {        release {            minifyenabled false            proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' Proguard-rules.pro '        }    }}dependencies {    compile project (': Volleysrc ')    compile Filetree (dir: ' Libs ', include: [' *.jar '])    compile ' com.android.support:appcompat-v7:21.0.2 '  //here also need to modify}

  

    Because the app module relies on the Volleysrc Library, the Volleysrc/build.gradle file also makes the same changes.     Five, recompile    Click the button to recompile the project. There is no error in compiling at this time. After compiling, you will find the icon in the bottom right corner of the app directory with the icon of a mobile phone, the directory structure is as follows:        At this point, you can run the project that GitHub has downloaded.

Android Studio Import the GitHub download project

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.