HighCapable/SweetDependency

你好,使用自动生成的,配置后找不到 libs.plugins.com.android.application

RookieExaminer opened this issue · 12 comments

image

image

你好,使用自动生成的,配置后找不到 libs.plugins.com.android.application

fankes commented

Gradle 版本和系统环境,请提供更多有效信息

id("com.highcapable.sweetdependency") version "1.0.4"

gradle-8.0

compileSdk = 34

compileSdk = 34

defaultConfig {
    applicationId = "com.azheng.hooktools"
    minSdk = 24
    targetSdk = 34
    versionCode = 1
    versionName = "1.0"

}

compileOptions {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
    jvmTarget = "1.8"
}
fankes commented

请使用 8.2+ 以上的版本,修复了 version catalogs 的问题

fankes commented

libs.plugins 的生成依赖于 version catalogs,你也可以使用 autowire 直接填写名称或别名装载插件,类似 autowire("com.android.application")

升级到8.3后。出现了新的问题
Caused by: java.lang.RuntimeException: Namespace not specified. Specify a namespace in the module's build file. See https://d.android.com/r/tools/upgrade-assistant/set-namespace for information about setting the namespace.

If you've specified the package attribute in the source AndroidManifest.xml, you can use the AGP Upgrade Assistant to migrate to the namespace value in the build file. Refer to https://d.android.com/r/tools/upgrade-assistant/agp-upgrade-assistant for general information about using the AGP Upgrade Assistant.

fankes commented

有没有一种可能,你发的内容里有链接,你可以自己去看就能解决呢

问题是namespace已经在build.gradle.kts 中设置过了

fankes commented

该问题不属于插件的问题,所以该问题将被关闭,如有其它问题可以继续留言

fankes commented

你可以参考这个模板 https://github.com/BetterAndroid/android-app-template
这个项目的 samples 也有提供用例

fankes commented

问题是namespace已经在build.gradle.kts 中设置过了

刚才没看到这一条,你提供分代码里没有 namespace

plugins {

// 迁移后的写法
autowire(libs.plugins.com.android.application)
autowire(libs.plugins.org.jetbrains.kotlin.android)

}

android {
namespace = "com.azheng.hooktools"
compileSdk = 33

defaultConfig {
    applicationId = "com.azheng.hooktools"
    minSdk = 24
    targetSdk = 33
    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_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
    jvmTarget = "1.8"
}

}

dependencies {

implementation(androidx.core.core.ktx)
implementation(androidx.appcompat.appcompat)

// implementation(androidx.lifecycle.lifecycle.viewmodel.ktx)
implementation(com.google.android.material.material)
implementation(androidx.constraintlayout.constraintlayout)
testImplementation(junit.junit)
androidTestImplementation(androidx.test.ext.junit)
androidTestImplementation(androidx.test.espresso.espresso.core)

}

fankes commented

agp 插件的问题和本插件无关,我也无法解决,建议自行搜索解决方案或者用我发给你的模板做参考,不要浪费时间重新配置项目了