Android Studio, android Studio, and Android

Source: Internet
Author: User
Tags jcenter

Android Studio, android Studio, and Android

1. Download Android Studio

If you have installed eclipse and the Android SDK, go to Android Studio IDE only: http://tools.android.com/download/studio/canary/1-3-1.

For easy download, we will attach a link to Baidu online storage, which is a windows version. Click to open the link.


2. Execute the downloaded exe file and follow the next step to install Android Studio.

During this process, I encountered a problem: for example, if android-23 is not installed in the SDK, Android Studio automatically downloads the android-23 version that I have not installed, but in this SDK version, some of them cannot be downloaded. Even if it is already on the wall, we can configure to prevent Android Studio from automatically downloading the remaining versions of the SDK. For details, refer to the first Fetching Android sdk component information started by android Studio.


3. Modify the font size

Use Ctrl + Alt + S to call out the Setings dialog box. You can also click the Setting Dialog Box in the toolbar and find Editor> Colors & Fonts> Font. Because the default topic cannot be changed, we need to use Sava As to recreate a topic, then you can set the Size.


4. We have modified the font size. We have not modified the font size of the structure font of the left-side project directory. The modification method is Appearance & Behavior, and then click Override defautl fonts, then you can set the Size.


5. Select Editor> Appearance> Show line numbers.


6. Change the shortcut key to eclipse, and select Keymap-> Keymaps as Eclipse.


7. Modify the automatic prompt. The default Android Studio is installed. The code prompt is as follows. If intent is entered, the upper-case Intent will not be displayed. How can we avoid the size-sensitive prompt?

Editor-> General-> Code Completion, and select None.


8. Add a jar package to Android Studio

(1) Right-click the Project directory, select Project Structure, select Dependencies, click the plus sign, and select Library dependency to select the jar package to be added, then, Android Studio downloads data from the jcenter repository.


Let's look at com. android. support. appcompat-v7: 22.2.1 is not very familiar with where appeared, right, in the app directory build. gradle has it. Every time you add Library Dependency, it will be in build. add one in gradle. Currently, we can also add one in build. you can configure it in gradle. Android Studio will also go to jcenter to automatically download it, so that you can easily update the version number.

The added jar package appears in the bottom External Libraries.


Build. gradle in the app directory:

apply plugin: 'com.android.application'android {    compileSdkVersion 22    buildToolsVersion "22.0.1"    defaultConfig {        applicationId "com.example.youku.helloworld"        minSdkVersion 15        targetSdkVersion 22        versionCode 1        versionName "1.0"    }    buildTypes {        release {            minifyEnabled false            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'        }    }}dependencies {    compile fileTree(dir: 'libs', include: ['*.jar'])    compile 'com.android.support:appcompat-v7:22.2.1'}

Therefore, we can draw a conclusion that the Properties Signing Flavors Build Types Dependences correspond to build. gradle in the app directory.

(2) refer to the structure of the entire project and directly add the jar package to the libs under the app directory to use the jar package. Why? We can see the following code for build. gradle in the app directory:

Dependencies {compile fileTree (dir: 'libs', include :['*. jar ']) // This is the key. compile 'com. android. support: appcompat-v7: 22.2.1 '}

9. Add a dependency project to Android Studio, which is the same as the above, but select Module dependency here.


After successful addition, a line will be added to build. gradle in the app directory, as shown below:

Dependencies {compile fileTree (dir: 'libs', include :['*. jar ']) // This is the key. compile 'com. android. support: appcompat-v7: 22.2.1 'compile project (': appcenter') // Add this line, we see the prefix is project}

10. Add so to Android Studio. Create jniLibs In the src/main directory. The default so file should be placed in this directory.


What should I do if I don't want to put it in this directory, for example, jniLibs, which is the same as libs? The answer is to modify build. gradle in the app directory and add the following code:

sourceSets {        main {            jniLibs.srcDirs = ['jniLibs']        }

11. Explain the parameters of build. gradle in the app directory and build. gradle in the project directory.

Build. gradle in the app directory, as follows:

Apply plugin: 'com. android. application '// indicates that this is an application, not a library. If it is a library, it should be apply plugin: 'com. android. library 'android {compileSdkVersion 22 // sdk version, which is android under the project directory External Libraries. jar version number buildToolsVersion "22.0.1" // the version number of the tool compiled by the sdk. gradle is only a build tool. In the end, you must compile defaultConfig {applicationId "com. example. youku. helloworld "// package name minSdkVersion 15 // The following are in AndroidManifest. there is no definition in xml. This information will be put into AndroidManifest during gradle construction. in xml, targetSdkVersion 22 versionCode 1 versionName "1.0"} buildTypes {release {minifyEnabled false // do not use obfuscation proguardFiles getdefaproproguardfile('proguard-android.txt '), 'proguard-rules. pro' // location of the obfuscation rule }}dependencies {compile fileTree (dir: 'libs', include :['*. jar ']) // All jar packages in libs must be built into compile 'com. android. support: appcompat-v7: 22.2.1 '// The referenced third-party jar package}
Build. gradle in the project directory:

// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript {repositories {jcenter () // repository of the downloaded gradle plug-in} dependencies {classpath 'com. android. tools. build: gradle: 1.3.0 '// the plug-in version number of gradle, not the version number of gradle. // NOTE: Do not place your application dependencies here; they belong // in the individual module build. gradle files} allprojects {repositories {jcenter () // repository for downloading third-party jar packages }}

12. gradlew. bat and gradle-wrapper


The gradle-wrapper.properties, as follows:

#Thu Sep 10 10:00:04 CST 2015distributionBase=GRADLE_USER_HOMEdistributionPath=wrapper/distszipStoreBase=GRADLE_USER_HOMEzipStorePath=wrapper/distsdistributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
Gradlew. bat first through gradlew-wrapper in the gradle version number, here is the gradle-2.4-all, find the corresponding gradle command, and then through this command to execute. So why not directly place the gradle command in the environment variable? Because the gradle version changes frequently, it is inconvenient to change the environment variable every time. Here you only need to modify the version number of the gradle-wrapper.properties.

So where is the gradle-2.4-all?


If this directory does not contain gradle-2.4-all.zip, gradle-2.4-all.zip will be downloaded first. Because the download speed of this file is slow, we will automatically decompress this zip file from Alibaba Studio.

Tip: If Android Studio already has gradle2.4 and you are also downloading gradle, please change the gradle-wrapper.properties to a gradle-2.4-all and won't go to auto download.

13. We often click this button to sync Projects with Gradle Files.

This button is used to check whether the Gradle build has a syntax error.


Use gradlew. bat clean to clear the apk generated by build in the app directory. Use gradlew. bat build to generate an apk. The generated apk is as follows:

The dubug version uses the debug certificate signature. The release version has no signature (unsigned ).


14. Generate the get set toString method and right-click Generate in the code. Another useful method is to right-click and select Refactor.

15. For Eclipse import projects, refer to idea.

16. To delete a Module, you must delete it in Project Structure (right-click the Project and select Open Module Settings) before deleting it in the Project directory.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.