美文网首页工具
Android-Studio

Android-Studio

作者: 闲云a | 来源:发表于2019-08-15 22:02 被阅读0次

    原文链接

    工欲善其事,必先利其器。——《论语·卫灵公》

    概览

    探索 Android Studio

    • 基于Gradle的灵活构建系统
    • 可针对所有Android设备进行开发的统一环境
    • Instant Run,可将变更推送到正在运行的应用,无需构建新的APK
    • 丰富的测试工具和框架
    • C++和NDK支持

    配置build

    Gradle 依赖项管理指南

    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:单步执行。如果当前行为方法调用(不会跳到方法内部),方法执行完后跳到下一行。
    3. Step Into:与Step Over不同的是,会跳到方法内部(非类库的方法)。
    4. Force Step Into:与Step Into不同的是,始终跳到方法内部。
    5. Step Out:跳出方法,返回到该方法调用处。
    6. Drop Frame
    7. Run to Cursor
    8. Resume Program:程序执行到下一个断点处。
    9. Stop:停止调试。

    变量观察

    • 选中变量,右键选择Add to Watches
    • 修改变量值,调试结果。选择Set Value

    条件断点

    循环体内设置。

    日志断点

    Suspend取消选中,显示日志输入框。

    异常断点

    单击如下图标,在弹窗中新建异常断点。

    变量断点

    方法断点

    在方法名所在行添加断点。

    Plugins

    其他

    配置Logcat颜色

    Assert:#8F0005 深红
    Debug:#0070BB 蓝
    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可以做如下设置:

    # 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 物联网设备上的应用开发
    • 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.

    相关文章

      网友评论

        本文标题:Android-Studio

        本文链接:https://www.haomeiwen.com/subject/bnntsctx.html