Android NDK开发详解之调试和性能分析的为库创建基准配置文件

Android NDK开发详解之调试和性能分析的为库创建基准配置文件

如需为库创建基准配置文件,请使用基准配置文件 Gradle 插件。

为库创建基准配置文件时涉及以下三个模块:

示例应用模块:包含使用库的示例应用。
库模块:要为库生成配置文件的模块。
基准配置文件模块:生成基准配置文件的测试模块。
如需为库生成基准配置文件,请执行以下步骤:

1、创建一个新的 com.android.test 模块,例如 :baseline-profile。
2、为 :baseline-profile 模块配置 build.gradle.kts 文件。该配置与应用的配置基本相同,但请务必将 targetProjectPath 设为示例应用模块。
3、在 :baseline-profile 测试模块中创建基准配置文件测试。此测试需要特定于示例应用,并且必须使用该库的所有功能。
4、更新库模块中 build.gradle.ktss 文件中的配置,例如 :library。
a、应用插件 androidx.baselineprofile。
b、将 baselineProfile 依赖项添加到 :baseline-profile 模块。
c、应用您需要的使用方插件配置,如以下示例所示。
Kotlin

plugins {
    id("com.android.library")
    id("androidx.baselineprofile")
}

android { ... }

dependencies {
    ...
    // Add a baselineProfile dependency to the `:baseline-profile` module.
    baselineProfile(project(":baseline-profile"))
}

// Baseline Profile Gradle plugin configuration.
baselineProfile {

    // Filters the generated profile rules.
    // This example keeps the classes in the `com.library` package all its subpackages.
    filter {
        include "com.mylibrary.**"
    }
}

Groovy

plugins {
    id("com.android.library")
    id("androidx.baselineprofile")
}

android { ... }

dependencies {
    ...
    // Add a baselineProfile dependency to the `:baseline-profile` module.
    baselineProfile(project(":baseline-profile"))
}

// Baseline Profile Gradle plugin configuration.
baselineProfile {

    // Filters the generated profile rules.
    // This example keeps the classes in the `com.library` package all its subpackages.
    filter {
        include "com.mylibrary.**"
    }
}

5、将 androidx.baselineprofile 插件添加到应用模块 :sample-app 中的 build.gradle.kts 文件。
Kotlin

plugins {
    ...
    id("androidx.baselineprofile")
}

Groovy

plugins {
    ...
    id("androidx.baselineprofile")
}

6、运行以下代码,生成配置文件:./gradlew :library:generateBaselineProfile。
在生成任务结束时,基准配置文件会存储在 library/src/main/generated/baselineProfiles 中。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

五一编程

程序之路有我与你同行

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值