• Android Studio版本升级后的问题 gradle降级、jdk升级


    Cannot use @TaskAction annotation on method IncrementalTask.taskAction$gradle_core() because interface org.gradle.api.tasks.incremental.IncrementalTaskInputs is not a valid parameter to an action method.

    修改下面两处地方分别为7.0.3、7.3.3
    
    • 1

    在这里插入图片描述
    在这里插入图片描述

    Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.

    An exception occurred applying plugin request [id: 'com.android.application']
    > Failed to apply plugin 'com.android.internal.application'.
       > Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
         You can try some of the following options:
           - changing the IDE settings.
           - changing the JAVA_HOME environment variable.
           - changing `org.gradle.java.home` in `gradle.properties`.
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    在这里插入图片描述

    Can’t determine type for tag '

    AGPBI: {“kind”:“error”,“text”:“Can’t determine type for tag ‘<macro name=“m3_comp_switch_disabled_selected_handle_color”>?attr/colorSurface’”,“sources”:[{“file”:“/Users/fausto/.gradle/caches/transforms-3/4948d05d0ff6027d2e3c9f4a6010103b/transformed/material-1.7.0-alpha02/res/values/values.xml”}],“tool”:“Resource and asset merger”}

    降级 androidx.appcompat:appcompat
    降级 com.google.android.material:material
    为以下版本

        implementation 'androidx.appcompat:appcompat:1.4.1'
        implementation 'com.google.android.material:material:1.6.0'
    
    • 1
    • 2

    Unexpected tokens (use ‘;’

    e: D:\work\HappyBirthday\settings.gradle.kts:3:21: Unexpected tokens (use ';' to separate expressions on the same line)
    
    • 1

    国内镜像如此配置

    pluginManagement {
        repositories {
            maven { url = uri('https://maven.aliyun.com/repository/google') };
            maven { url = uri('https://maven.aliyun.com/repository/jcenter') };
            maven { url = uri('https://maven.aliyun.com/repository/gradle-plugin') }
        }
    }
    dependencyResolutionManagement {
        repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
        repositories {
            maven { url = uri('https://maven.aliyun.com/repository/google') };
            maven { url = uri('https://maven.aliyun.com/repository/jcenter') };
            maven { url = uri('https://maven.aliyun.com/repository/gradle-plugin') }
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15

    org.jetbrains.kotlin.android 版本

    plugins {
        id("com.android.application") version "7.0.3" apply false
        id("org.jetbrains.kotlin.android") version "1.5.31" apply false
    }
    
    • 1
    • 2
    • 3
    • 4

    在这里插入图片描述

    Compose 与 Kotlin 的兼容性对应关系

    在这里插入图片描述

    build.gradle.kts

    注释package。

    plugins {
        id("com.android.application")
        id("org.jetbrains.kotlin.android")
    }
    
    android {
        namespace = "cn.jj.happybirthday"
        compileSdk = 33
    
        defaultConfig {
            applicationId = "cn.jj.happybirthday"
            minSdk = 24
            targetSdk = 33
            versionCode = 1
            versionName = "1.0"
    
            testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
            vectorDrawables {
                useSupportLibrary = true
            }
        }
    
        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"
        }
        buildFeatures {
            compose = true
        }
        composeOptions {
            kotlinCompilerExtensionVersion = "1.4.3"
        }
    //    packaging {
    //        resources {
    //            excludes += "/META-INF/{AL2.0,LGPL2.1}"
    //        }
    //    }
    }
    
    dependencies {
    
        implementation("androidx.core:core-ktx:1.9.0")
        implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1")
        implementation("androidx.activity:activity-compose:1.7.0")
        implementation(platform("androidx.compose:compose-bom:2023.03.00"))
        implementation("androidx.compose.ui:ui")
        implementation("androidx.compose.ui:ui-graphics")
        implementation("androidx.compose.ui:ui-tooling-preview")
        implementation("androidx.compose.material3:material3")
        testImplementation("junit:junit:4.13.2")
        androidTestImplementation("androidx.test.ext:junit:1.1.5")
        androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
        androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00"))
        androidTestImplementation("androidx.compose.ui:ui-test-junit4")
        debugImplementation("androidx.compose.ui:ui-tooling")
        debugImplementation("androidx.compose.ui:ui-test-manifest")
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
  • 相关阅读:
    Chat GPT是什么,初学者怎么使用Chat GPT,需要注意些什么
    【Linux operation 55】centos 9 steam 在线安装docker
    APS高级排程具有哪些功能?
    【博客448】OVN (Open Virtual Network)
    集合的父亲之Map------(双列集合顶级接口)和遍历方式
    学习一下 常说的节流
    PyTorch设置可复现/重复实验
    自动驾驶项目 ASLAN
    HTML网页规划与设计【冬季奥林匹克运动会——带报告5200字】HTML+CSS+JavaScript
    daisyUI - 主题漂亮、代码纯净,免费开源的 Tailwind CSS 组件库,不需要堆砌 class 名
  • 原文地址:https://blog.csdn.net/qq_42015021/article/details/133714547