Android Studio imports the github download project, androidgithub

Source: Internet
Author: User

Android Studio imports the github download project, androidgithub

Currently, most of the current projects on github are Android Studio projects. The question is, how can I import android studio after a project is down on github?

For kids shoes that have just switched from eclipse to Android Studio, various problems may occur. The following method can be used to import a github project to android studio and run it. First of all, Android Studio builds a project based on Gradle. This is different from eclipse, so it is best to be familiar with Gradle first if you want to master the usage of Android Studio. Here we will only introduce how Android Studio imports the project. For Gradle, you can use Baidu. The following describes how to import a project to Android Studio. 1. Install Android Sudio and create a projectAfter Android Studio is installed, the Project is created and Gradle is automatically downloaded. The project directory structure is as follows: 2. Replace the gradle version in the project downloaded from github with the local version.If you directly import a project to Android Studio, it will download the corresponding version of gradle of the project. This process is very slow and sometimes There will be various errors. Therefore, use the local existing gradle directly. The replacement method is simple. You only need to copy the corresponding folder in the locally created project to the project downloaded from github and replace it. 3. Import a project to Android StudioFile --> new --> import project. The following dialog box is displayed. Select the project downloaded from github and click OK. Here I use volley's demo as an example. After import, for example: 4. Replace the target SDK of the ModuleAfter the project is imported, compilation errors may occur because the target sdk in the gradle configuration of the app Module is later than your local SDK version. The solution is simple. Open the app/build. gradle file.
apply plugin: 'com.android.application'android {    compileSdkVersion 22    buildToolsVersion "22.0.1"    defaultConfig {        applicationId "com.timliu.volleyactivity"        minSdkVersion 21        targetSdkVersion 22        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'}

  

The compilation error occurs because the local sdk version is 21 and the targetSdkVersion of this Module is 22. You only need to change the file a little. The modified file is as follows:
Apply plugin: 'com. android. application 'android {compileSdkVersion 21 buildToolsVersion "255.0.0" // here you also need to modify defaconfig config {applicationId "com. timliu. volleyactivity "minSdkVersion 21 targetSdkVersion 21 versionCode 1 versionName" 1.0 "} buildTypes {release {minifyEnabled false proguardFiles getdefaproproguardfile('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 needs to be modified}

  

Because the app Module depends on the volleysrc Library, the volleysrc/build. gradle file is also modified. 5. recompileClick the button to re-compile the project. At this time, the compilation will not go wrong. After compilation, you will find that there is a mobile phone icon in the lower right corner of the app directory. The directory structure is as follows: Now you can run the project downloaded from github normally.

 

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.