How to import project into Android Studio

Source: Internet
Author: User

Android Studio has now developed to the 0.8+ version, and has recently tried to use it for many reasons, one of which is the future trend, and the second is that more and more of the open source projects on GitHub are based on Android studio, So using Android Studio becomes a necessary task.

About the download and installation of Android studio, a lot of articles on the Web, this article is not prepared to talk about these problems, mainly on how to import existing projects in Android studio into.

Before the specific work, there are two concepts that are not the same as Eclipse, project and module. In Android studio, a project is not project for Eclipse, but it's a bit like workspace (or a task bar), and the module is similar to Eclipse's project. So, a project can contain multiple module, and multiple module together form a project, each module can be a library, or it can be a running module (corresponding to a running apk).

Okay, now get to the point.

1, start Android Studio, this article is using the version 0.8.0.

2. Prepare items that need to be opened in Android Studio. Here take https://github.com/AndroidAlliance/EdgeEffectOverride/as an example, please download the corresponding zip file and unzip it, This is a scrolling control such as ScrollView scrolling to items that have a highlight phenomenon when they are out of bounds. The reason for this project is that there are several issues that need to be addressed when importing this project.

3. Modify the required Gradle package requirements in the project.

Locate the Edgeeffectoverride-master\gradle\wrapper. gradle-wrapper.properties file below, and use the text File tool like notepad++ to open it, inside this line (Red section):

#Wed Oct 23:50:13 BST 2013
Distributionbase=gradle_user_home
Distributionpath=wrapper/dists
Zipstorebase=gradle_user_home
Zipstorepath=wrapper/dists
Distributionurl=http\://services.gradle.org/distributions/gradle-1.8-all.zip

Please change the Red section to the installed version of Gradle on your machine, for example, I am gradle-1.12-all.zip here, (in C:\Users\Administrator\.gradle\wrapper\dists\ Gradle-1.12-all\2apkk7d25miauqf1pdjp1bm0uo, your machine may be slightly different from this, because the last folder name is randomly generated):


If you do not do this, the different projects require different versions of the Gradle version, Android Studio has to download multiple copies of the Gradle package on the C: disk, in fact, it is not necessary, because each project will present its required minimum version of the Gradle requirements, You can open the Build.gradle file in project to see (in the Red section):

Buildscript {
repositories {
Mavencentral ()
}
dependencies {
Classpath ' com.android.tools.build:gradle:0.6.+ '
}
}

Here's an example of a requirement of more than 0.6 versions of Gradle, because our machine may already have a higher gradle than this version, so you don't need to go to the next Gradle-1.8-all.zip file as required above, and you can use it directly from the machine. By the way, it can be http://services.gradle.org/distributions/ Xxx.zip (Please change the blue part xxx.zip to the desired file name, such as Gradle-1.12-all.zip, the other version is the same), so manually downloaded, and then put to C:\Users\Administrator\.gradle\ Wrapper\dists\gradle-1.12-all\2apkk7d25miauqf1pdjp1bm0uo inside, no decompression is required, and Android studio will unzip itself.

4. Click Import Project.


Navigate to the directory where the project is located, locate the Build.gradle file, and then click the OK button.



5. Problems encountered

First, you will be prompted with an error to the effect that the unsupported version of Gradle is used, please use Gradle1.10, as follows:



At this point, click on the "Gradle Settings" blue link below and the following window appears:



Select the option recommended by "Use default Gradle wrapper (recommended)" and click the OK button. When you go back to the previous interface, click the Fix Gradle wrapper and re-import Project blue link to start correcting and building project automatically.

In the Gradle build project process, the following appears at the bottom of the prompt message, see the red exclamation mark two lines:



The first of these is that Defaultgroovmavendeployer lacks the nexususername attribute, and the second is that you must use the newer version of the Android Gradle plugin.

First, correct the first question, open the Build.gradle file in the Edgeeffectoverride module in Android Studio, and delete the last line (see the Blue selected section at the bottom):



OK, delete the last line, and Android Studio will save it automatically. Note that if the error is modified, you can press CTRL + Z back, but to move forward, the shortcut is ctrl+shift+z, rather than the usual ctr+y,ctrl+y in Android Strdio is to delete the current line meaning.

Next deal with the second issue, open the Build.gradle file below the Edgeeffectoverride-master project, as shown in:



The blue selection is what you want to modify, and it's strange that Android studio has automatically changed it for us and is already the current version of the Gradle plugin.

Finally, click on the "Try Again" link at the top.



However, there are new problems:



This means that the project uses the SDK build tools version 18.0.1 is too low, the minimum to use 19.1.0, no way, had to follow the instructions changed.

Continue on Android In studio, open the Build.gradle file under the two modules of Edgeeffectoverride and edgeeffectoverridesample, and change the numbers behind the buildtoolsversion to 19.1.0, such as the red mark in section, remember that two build.gradle files are to be changed.



OK, click "Try Again" at the top of the editor, after gradle a busy, everything finally good, download finally can run.



6, click the green triangle arrow, edgeeffectoverridesample run up, Where Edgeeffectoverride is the module that Edgeeffectoverridesample runs on (equivalent to the library in Eclipse).

How to import project into Android Studio

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.