Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gradle 8.x kts tomls 依赖失败 #172

Open
GuoFeilong opened this issue May 15, 2024 · 5 comments
Open

gradle 8.x kts tomls 依赖失败 #172

GuoFeilong opened this issue May 15, 2024 · 5 comments

Comments

@GuoFeilong
Copy link

无法依赖
image

@ChenSiWu
Copy link

ChenSiWu commented Nov 5, 2024

1.第一步 在libs.versions.toml文件中定义,示例代码如下

[versions]
# *======== 插件版本 ========
agp = "8.6.1"
kotlin = "2.0.0"
googleDevtoolsKsp = "2.0.0-1.0.24"
#腾讯渠道包 https://github.com/Tencent/VasDolly
tencentVasDolly = "3.0.6"

[libraries]
#腾讯渠道包 https://github.com/Tencent/VasDolly
tencent-vasdolly-helper = { module = "com.tencent.vasdolly:helper", version.ref = "tencentVasDolly" }
tencent-vasdolly-plugin = { module = "com.tencent.vasdolly:plugin", version.ref = "tencentVasDolly" }

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
android-library = { id = "com.android.library", version.ref = "agp" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
tencent-vasdolly = { id = "com.tencent.vasdolly", version.ref = "tencentVasDolly" }

第二步在工程的build.gradle.kts,示例代码如下

Tip

注意: 需要把buildscript{} 放在plugins {}的上方

buildscript {
    dependencies {
        //腾讯渠道打包https://github.com/Tencent/VasDolly
        classpath(libs.tencent.vasdolly.plugin)
    }
}


// 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.android.library) apply false
    alias(libs.plugins.kotlin.android) apply false
}

第三部在app目录下的build.gradle.kts 示例代码如下

plugins {
    alias(libs.plugins.android.application)
    alias(libs.plugins.kotlin.android)
    ···
    id(libs.plugins.tencent.vasdolly.get().pluginId)
}


android {
    namespace = ···
    compileSdk = ···

    defaultConfig {
        applicationId = ···
        minSdk = ···
        targetSdk = ···
        versionCode = ···
        versionName = ···

        ndk {
            // 设置支持的SO库架构
            //abiFilters 'armeabi', 'x86', 'armeabi-v7a', 'x86_64', 'arm64-v8a'
            abiFilters.addAll(setOf("armeabi-v7a", "arm64-v8a"))
        }
    }

    buildFeatures {
        buildConfig = true
        viewBinding = true
    }

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_17.toString()
    }

}

dependencies {
    ···
    implementation(libs.tencent.vasdolly.helper)

}

最后就可以导入成功了
企业微信截图_0dd814ab-b8a9-4f47-b16a-0f9fe47c0db8

或者参考 #171 的写法也可以同样达到效果

@GuoFeilong
Copy link
Author

谢谢大佬,我现在就是试一下。

@GuoFeilong
Copy link
Author

按照你的方法接入成功了,但是有个问题,打包速度并没有提升,和在gradle里面用传统 flavor 速度一样,也是非常慢,
image

@GuoFeilong
Copy link
Author

接入成功之后,没有一键打全部渠道包的命令
image

@GuoFeilong
Copy link
Author

只有你txt 文档里面写的几个渠道。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants