Android-Studio

原文鏈接

工欲善其事摩桶,必先利其器晚凿≡持浚——《論語·衛(wèi)靈公》

概覽

探索 Android Studio

  • 基于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

Gradle 依賴項(xiàng)管理指南

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

  1. Show Execution Point
  2. Step Over:單步執(zhí)行焕毫。如果當(dāng)前行為方法調(diào)用(不會(huì)跳到方法內(nèi)部)蹲坷,方法執(zhí)行完后跳到下一行。
  3. Step Into:與Step Over不同的是邑飒,會(huì)跳到方法內(nèi)部(非類庫的方法)循签。
  4. Force Step Into:與Step Into不同的是,始終跳到方法內(nèi)部疙咸。
  5. Step Out:跳出方法县匠,返回到該方法調(diào)用處。
  6. Drop Frame
  7. Run to Cursor
  8. Resume Program:程序執(zhí)行到下一個(gè)斷點(diǎn)處撒轮。
  9. 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

簡介

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:

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
    1. Variables
    2. Modules
    3. Dependencies
    4. Build Variants
    5. 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.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末豫领,一起剝皮案震驚了整個(gè)濱河市抡柿,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌等恐,老刑警劉巖洲劣,帶你破解...
    沈念sama閱讀 219,110評(píng)論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異课蔬,居然都是意外死亡囱稽,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,443評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門二跋,熙熙樓的掌柜王于貴愁眉苦臉地迎上來战惊,“玉大人,你說我怎么就攤上這事扎即⊥袒瘢” “怎么了?”我有些...
    開封第一講書人閱讀 165,474評(píng)論 0 356
  • 文/不壞的土叔 我叫張陵谚鄙,是天一觀的道長各拷。 經(jīng)常有香客問我,道長闷营,這世上最難降的妖魔是什么烤黍? 我笑而不...
    開封第一講書人閱讀 58,881評(píng)論 1 295
  • 正文 為了忘掉前任知市,我火速辦了婚禮,結(jié)果婚禮上速蕊,老公的妹妹穿的比我還像新娘嫂丙。我一直安慰自己,他們只是感情好规哲,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,902評(píng)論 6 392
  • 文/花漫 我一把揭開白布奢入。 她就那樣靜靜地躺著,像睡著了一般媳叨。 火紅的嫁衣襯著肌膚如雪腥光。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,698評(píng)論 1 305
  • 那天糊秆,我揣著相機(jī)與錄音武福,去河邊找鬼。 笑死痘番,一個(gè)胖子當(dāng)著我的面吹牛捉片,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播汞舱,決...
    沈念sama閱讀 40,418評(píng)論 3 419
  • 文/蒼蘭香墨 我猛地睜開眼伍纫,長吁一口氣:“原來是場噩夢(mèng)啊……” “哼!你這毒婦竟也來了昂芜?” 一聲冷哼從身側(cè)響起莹规,我...
    開封第一講書人閱讀 39,332評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎泌神,沒想到半個(gè)月后良漱,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,796評(píng)論 1 316
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡欢际,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,968評(píng)論 3 337
  • 正文 我和宋清朗相戀三年母市,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片损趋。...
    茶點(diǎn)故事閱讀 40,110評(píng)論 1 351
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡患久,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出浑槽,到底是詐尸還是另有隱情蒋失,我是刑警寧澤,帶...
    沈念sama閱讀 35,792評(píng)論 5 346
  • 正文 年R本政府宣布括荡,位于F島的核電站高镐,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏畸冲。R本人自食惡果不足惜嫉髓,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,455評(píng)論 3 331
  • 文/蒙蒙 一观腊、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧算行,春花似錦梧油、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,003評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至量淌,卻和暖如春骗村,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背呀枢。 一陣腳步聲響...
    開封第一講書人閱讀 33,130評(píng)論 1 272
  • 我被黑心中介騙來泰國打工胚股, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人裙秋。 一個(gè)月前我還...
    沈念sama閱讀 48,348評(píng)論 3 373
  • 正文 我出身青樓琅拌,卻偏偏與公主長得像,于是被迫代替她去往敵國和親摘刑。 傳聞我的和親對(duì)象是個(gè)殘疾皇子进宝,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,047評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容