无法获取扩展名 'android' 的未知 属性 'experimentalProperties' | Android Jetpack 宏基准测试

Could not get unknown property 'experimentalProperties' for extension 'android' | Android Jetpack Macrobenchmark

我正在关注来自 - 的宏基准设置配置 https://developer.android.com/studio/profile/macrobenchmark#configuration

在我的宏基准测试中的以下代码中 build.gradle

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        minSdkVersion 29
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles "consumer-rules.pro"
    }

    targetProjectPath = ":app" // Note that your module name may be different
    experimentalProperties["android.experimental.self-instrumenting"] = true
    buildTypes {
        release {
            debuggable = true
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

在 gradle 同步时抛出以下构建错误:

A problem occurred evaluating project ':macrobenchmark'.
> Could not get unknown property 'experimentalProperties' for extension 'android' of type com.android.build.gradle.TestExtension.

我是 android 的新手,非常感谢任何帮助,在此先感谢。

通过以下 -

修复了错误
  1. 已将 Android Studio 更新为 Arctic Fox Beta 版
  2. 已将项目 build.gradle 中的 gradle 版本更新为 7.0 beta4

通过 google 提供的 documentation of benchmark samples 存储库找到解决方案并比较 gradle 个文件。

由于其他依赖项,我不得不更新到项目 build.gradle 文件中 gradle 插件的版本 7.1.0-alpha02。

这个 属性 得到了认可。