工欲善其事摩桶,必先利其器晚凿≡持浚——《論語·衛(wèi)靈公》
概覽
- 基于Gradle的靈活構(gòu)建系統(tǒng)
- 可針對(duì)所有Android設(shè)備進(jìn)行開發(fā)的統(tǒng)一環(huán)境
- Instant Run,可將變更推送到正在運(yùn)行的應(yīng)用,無需構(gòu)建新的APK
- 豐富的測(cè)試工具和框架
- C++和NDK支持
配置build
dependencies {
// Dependency on a local library module
implementation project(":mylibrary")
// Dependency on local binaries
implementation fileTree(dir: 'libs', include: ['*.jar'])
// Dependency on a remote binary
implementation 'com.example.android:app-magic:12.3'
}
Debug
- Show Execution Point
-
Step Over
:單步執(zhí)行焕毫。如果當(dāng)前行為方法調(diào)用(不會(huì)跳到方法內(nèi)部)蹲坷,方法執(zhí)行完后跳到下一行。 -
Step Into
:與Step Over不同的是邑飒,會(huì)跳到方法內(nèi)部(非類庫的方法)循签。 -
Force Step Into
:與Step Into不同的是,始終跳到方法內(nèi)部疙咸。 -
Step Out
:跳出方法县匠,返回到該方法調(diào)用處。 - Drop Frame
- Run to Cursor
-
Resume Program
:程序執(zhí)行到下一個(gè)斷點(diǎn)處撒轮。 -
Stop
:停止調(diào)試乞旦。
變量觀察
- 選中變量,右鍵選擇Add to Watches
- 修改變量值题山,調(diào)試結(jié)果兰粉。選擇Set Value
條件斷點(diǎn)
循環(huán)體內(nèi)設(shè)置。
日志斷點(diǎn)
Suspend取消選中顶瞳,顯示日志輸入框玖姑。
異常斷點(diǎn)
單擊如下圖標(biāo),在彈窗中新建異常斷點(diǎn)浊仆。
變量斷點(diǎn)
方法斷點(diǎn)
在方法名所在行添加斷點(diǎn)客峭。
Plugins
其他
配置Logcat顏色
Assert:#8F0005 深紅
Debug:#0070BB 藍(lán)
Error:#FF0006 紅
Info:#48BB31 綠
Verbose:#BBBBBB 白
Warning:#BBBB23 黃
Android Gradle plugin
簡介
buildscript {
repositories {
// Gradle 4.1 and higher include support for Google's Maven repo using
// the google() method. And you need to include this repo to download
// Android Gradle plugin 3.0.0 or higher.
google()
jcenter()
...
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
The following table lists which version of Gradle is required for each version of the Android Gradle plugin. For the best performance, you should use the latest possible version of both Gradle and the plugin.
|Plugin version|Gradle version|Build Tools|
|:-|:-|
|1.0.0 - 1.1.3|2.2.1 - 2.3|
|1.2.0 - 1.3.1|2.2.1 - 2.9|
|1.5.0|2.2.1 - 2.13|
|2.0.0 - 2.1.2| 2.10 - 2.13|
|2.1.3 - 2.2.3|2.14.1+|
|2.3.0+|3.3+|
|3.0.0+|4.1+|26.0.2+|
|3.1.0+|4.4+|
|3.2.0 - 3.2.1|4.6+|
|3.3.0 - 3.3.2|4.10.1+|
|3.4.0+|5.1.1+|
3.4.0 (April 2019)
This version of the Android plugin requires the following:
- Gradle 5.1.1 or higher.
- SDK Build Tools 28.0.3 or higher.
3.3.0 (January 2019)
3.2.0 (September 2018)
3.1.0 (March 2018)
3.0.0 (October 2017)
This version of the Android plugin requires the following:
- Gradle 4.1 or higher. To learn more, read the section about updating Gradle.
- Build Tools 26.0.2 or higher. With this update, you no longer need to specify a version for the build tools—the plugin uses the minimum required version by default. So, you can now remove the
android.buildToolsVersion
property.
Optimizations
歷史版本
3.4 (April 2019)
3.4.2 (July 2019)
3.4.1 (May 2019)
3.4.0
- IntelliJ IDEA 2018.3.4
- Android Gradle plugin 3.4.0
- New Project Structure Dialog
- Variables
- Modules
- Dependencies
- Build Variants
- Suggestions
- New Resource Manager
- R8 enabled by default
- New intention action to quickly import dependencies
R8
gradle.properties可以做如下設(shè)置:
# Disables R8 for Android Library modules only.
android.enableR8.libraries = false
# Disables R8 for all modules.
android.enableR8 = false
**Note: **For a given build type, if you set useProguard to false in your app module's build.gradle file, the Android Gradle plugin uses R8 to shrink your app's code for that build type, regardless of whether you disable R8 in your project's gradle.properties file.
3.3 (January 2019)
- IntelliJ IDEA 2018.2.2
- Delete unused Android Studio directories
- Lint improvements
- Create New Project wizard
- Profiler updates
- Automatic downloading of SDK components
- Support for Clang-Tidy
- CMake version 3.10.2
3.0 (October 2017)
- Android Plugin for Gradle 3.0.0
- Kotlin support
- Java 8 language features support
- Android Profiler replaces the Android Monitor tool
- APK profiling and debugging
- Device File Explorer This replaces the filesystem tool available in DDMS.
- Instant Apps support
- Android Things modules 物聯(lián)網(wǎng)設(shè)備上的應(yīng)用開發(fā)
- Adaptive Icons wizard
- Support for font resources
- URL intent-filter validator
- Preview for D8 DEX compiler
- Google's Maven repository
Android Studio 3.0 includes an optional new DEX compiler called D8. It will eventually replace the DX compiler, but you can opt-in to use the new D8 compiler now.
Native debugging with Android Studio no longer supports 32-bit Windows.