Android Studio Usage Tips

Source: Internet
Author: User
Tags jcenter

To tell the truth start touching this tool really think very disgusting after all, the mainland is a lot of things to use the wall is not very convenient and eclipse to move to Android studio or a span of crap don't say the following about the problems I encountered

1. Installation time (Setup Wizard-download components) this to download for a very long time or even download (PS: This selection and download 2.25G component is a bug in studio, the comments are reminded, thank the classmate.

Suppose the speed is not enough to skip this step can add a line in the Bin folder idea.properties: Disable.android.first.run=true. Right-click on the Mac platform->show package Contents to find the Bin folder. )

2. After the success of the new project will download Gradle, it seems that the process is not FQ is also able to download, but the visit is particularly slow, recommended FQ download.  So where does the downloaded gradle go? Open C:\USERS\ADMINISTRATOR\.GRADLE\WRAPPER\DISTS\GRADLE-1.10-ALL\D90A2YJKNZZHPCFGM937ZPCTE you will see the required Gradle version number Like mine is gradle-1.10 I will go to Baidu search this download a lot of download after the Gradle-1.10-all.zip copy to this folder (C:\Users\Administrator\.gradle\wrapper\dists\ GRADLE-1.10-ALL\D90A2YJKNZZHPCFGM937ZPCTE)

Note: Assume that the import of a project has been in building so go to change the project Gradle folder in the Gradle-wrapper.properties file in the side of the Distributionurl the last edge of the Gradle version has been downloaded, such as I've got gradle-2.2.1-all.zip, but there's no gradle-2.4-all.zip, so I'll change to distributionurl=https\://services.gradle.org/. Distributions/gradle-2.2.1-all.zip

If you download Android studio after importing the project, then end the task and change the Build.gradle under the project root folder.
Change to your version number now.

dependencies {
Classpath ' com.android.tools.build:gradle:1.2.2 '

Note:do not place your application dependencies here; They belong
In the individual module Build.gradle files
}

3. About the configuration of the Build.gradle:

Main Projectapp:

Apply plugin: ' com.android.application ' declares that this project is the main project

Dependencies {

Compile Filetree (dir: ' Libs ', include: [' *.jar ']) The default does not require much explanation

Compile project (': Studioklowerbase ')} affirms that the main project relies on the library note the spelling rules, the name should be the same as your library name

Buildtypes {    Release {        
      Proguardfiles getdefaultproguardfile (' proguard-android.txt'proguard-rules.pro '
      Define code Obfuscation file Note: Proguard-rules.pro to be placed under the folder of the main project
    }}
Complete code such as the following:
Apply plugin: ' Com.android.application ' android {    compilesdkversion    buildtoolsversion "19.1.0"    defaultconfig {        ApplicationID "com.klowerbase.test"        minsdkversion        targetsdkversion        Versioncode 1        versionname "1.0"    }    buildtypes {        release {            minifyenabled true            Proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' Proguard-rules.pro '        }    }}dependencies {    Compile Filetree (dir: ' Libs ', include: [' *.jar '])    Compile project (': Studioklowerbase ')}

Configuration of the--library project
plugin ' android-library ' defined as library
dependencies {    ' com.android.tools.build:gradle:1.2.2 ' defines the compiled Gradle version number
}
Complete code such as the following:
Buildscript {repositories {mavencentral ()} dependencies {classpath ' Com.android.tools.build:gra     dle:1.2.2 '}}apply plugin: ' android-library ' dependencies {compile filetree (include: ' *.jar ', dir: ' Libs ')}android { Compilesdkversion buildtoolsversion "19.1.0" sourcesets {main {manifest.srcfile ' ANDROIDM            Anifest.xml ' java.srcdirs = [' src '] resources.srcdirs = [' src '] aidl.srcdirs = [' src ']        Renderscript.srcdirs = [' src '] res.srcdirs = [' res '] assets.srcdirs = [' Assets ']}        Move the tests to Tests/java, tests/res, etc ... Instrumenttest.setroot (' tests ')//Move The build types to build-types/<type>//For instance, build-t Ypes/debug/java, Build-types/debug/androidmanifest.xml, ...//This moves them out of them the default location under s rc/<type>/which would//conflict with src/being used by the MAIN Source set.        Adding New build types or product flavors should be accompanied//by a similar customization. Debug.setroot (' Build-types/debug ') release.setroot (' Build-types/release ')}}

The configuration code for the project such as the following
Top-level build file where can add configuration options common to all Sub-projects/modules.buildscript {    repos itories {        jcenter ()    }    dependencies {        classpath ' com.android.tools.build:gradle:1.2.2 '        //NOTE: Do not place your application dependencies here; They belong        //In the individual module Build.gradle files    }}allprojects {    repositories {        jcenter ()    }}
Resolve task ' not found in root project ' * * *. Method 1: Delete the <component name= "Facetmanager" > ... </component> Method 2: Erase . iML and the. Idea directory once again the importer is experimenting: Another method is effective because I use the GRADLE-2.2.1 project structure for some changes, such as the following:

Finally, attach some frequently used shortcut keys:

Ctrl+alt+l Formatting Code

Ctrl+alt+space Code Hints

Ctrl+alt+o Optimizing imported classes and Packages

Alt+insert generate code (such as Get,set method, constructor, etc.)

Ctrl+shift+space Self-complement code

CTRL + Space Code hints

Ctrl+r replacement

Ctrl+y Delete Row (ctrl+x is not a delete row.) is cut.

If unchecked, the cut is the row.

Ths for seemingly dropped lines) ctrl+d copy line ctrl+/or ctrl+shift+/gaze (//or/*...*/)

Android Studio Usage Tips

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.