Skip to content

最新AndroidStudio如何gradle如何配置matrix啊? #901

@EvenDai

Description

@EvenDai

救命啊,现在最新Android Studio的配置已经发生翻天覆地的变化了,官方能不能给最新的gradle版本如何配置Matrix给更新一下啊,这东西,问DeepSeek根本没有用,实现是解决不了,头痛!

我目前的Android Studio版本为:Android Studio Meerkat | 2024.3.1

现在项目根目录中的settings.gradle.kts是这样的:

pluginManagement {
    repositories {
        google {
            content {
                includeGroupByRegex("com\\.android.*")
                includeGroupByRegex("com\\.google.*")
                includeGroupByRegex("androidx.*")
            }
        }
        mavenCentral()
        gradlePluginPortal()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.name = "MatrixDemo"
include(":app")

根目录的build.gradle.kts是这样的:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    alias(libs.plugins.android.application) apply false
    alias(libs.plugins.kotlin.android) apply false
}

app模块的build.gradle.kts是这样的:

plugins {
    alias(libs.plugins.android.application)
    alias(libs.plugins.kotlin.android)
}

android {
    namespace = "cn.android666.matrixdemo"
    compileSdk = 35

    defaultConfig {
        applicationId = "cn.android666.matrixdemo"
        minSdk = 24
        targetSdk = 35
        versionCode = 1
        versionName = "1.0"

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            isMinifyEnabled = false
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_11
        targetCompatibility = JavaVersion.VERSION_11
    }
    kotlinOptions {
        jvmTarget = "11"
    }
}

dependencies {
    val matrixVersion = "2.1.0"
    implementation("com.tencent.matrix:matrix-android-lib:$matrixVersion")
    implementation("com.tencent.matrix:matrix-trace-canary:$matrixVersion")
    implementation(libs.androidx.core.ktx)
    implementation(libs.androidx.appcompat)
    implementation(libs.material)
    implementation(libs.androidx.activity)
    implementation(libs.androidx.constraintlayout)
    testImplementation(libs.junit)
    androidTestImplementation(libs.androidx.junit)
    androidTestImplementation(libs.androidx.espresso.core)
}

现在只会配置依赖,但是那个插件是如何配置的,真是搞不明白了,官方的插件配置代码是这样的:

dependencies {
      classpath ("com.tencent.matrix:matrix-gradle-plugin:${MATRIX_VERSION}") { changing = true }
}
apply plugin: 'com.tencent.matrix-plugin'
  matrix {
    trace {
        enable = true	//if you don't want to use trace canary, set false
        baseMethodMapFile = "${project.buildDir}/matrix_output/Debug.methodmap"
        blackListFile = "${project.projectDir}/matrixTrace/blackMethodList.txt"
    }
}

现在这两项要怎么写了,对gralde不是很了解,百度、DeepSeek根本找不到答案了,怎么改怎么出错,头疼!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions