Android Studio:未找到“:app”的变体

问题描述 投票:0回答:0

我正在做我的期末项目,我想用 android studio 做项目,我是 android studio 的新手,我遇到了一个错误,说 No variants found for ':app' 我试过更改或下载其他版本的SDK,但都没有解决

这里是build.gradle代码:

buildscript {

   repositories {

   google()  // Google's Maven repository

   mavenCentral()  // Maven Central repository

  }

   dependencies {
   
   classpath 'com.android.tools.build:gradle:4.2.1'

   classpath 'com.google.gms:google-services:4.3.15'

  }

}


allprojects {

   repositories {

   google()  // Google's Maven repository

   mavenCentral()  // Maven Central repository

 }

}

这里是 app/build.gradle 的代码:

plugins {
    id 'com.android.application'
    id 'com.google.gms.google-services'
}

android {
    namespace 'com.example.chatapp'
    compileSdk 33

    defaultConfig {
        applicationId "com.example.chatapp"
        minSdk 24
        targetSdk 33
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildFeatures{
        viewBinding true
        compose true
    }
//    kotlinOptions {
//        jvmTarget = '1.8'
//    }
    composeOptions {
        kotlinCompilerExtensionVersion '1.3.2'
    }
    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.8.0'
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
    implementation 'androidx.activity:activity-compose:1.5.1'
    implementation platform('androidx.compose:compose-bom:2022.10.00')
    implementation 'androidx.compose.ui:ui'
    implementation 'androidx.compose.ui:ui-graphics'
    implementation 'androidx.compose.ui:ui-tooling-preview'
    implementation 'androidx.compose.material3:material3'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
    implementation 'com.intuit.sdp:sdp-android:1.0.6'
    implementation 'com.intuit.ssp:ssp-android:1.0.6'
    implementation 'com.makeramen:roundedimageview:2.3.0'
    androidTestImplementation platform('androidx.compose:compose-bom:2022.10.00')
    androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
    androidTestImplementation platform('androidx.compose:compose-bom:2022.10.00')
    androidTestImplementation platform('androidx.compose:compose-bom:2022.10.00')
    debugImplementation 'androidx.compose.ui:ui-tooling'
    debugImplementation 'androidx.compose.ui:ui-test-manifest'
}

这是 Settings.gradle 的代码:

pluginManagement {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}
dependencyResolutionManagement {
//    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
//    repositories {
//        google()
//        mavenCentral()
//    }
}
rootProject.name = "ChatApp"
include ':app'
android android-studio gradle android-gradle-plugin variant
© www.soinside.com 2019 - 2024. All rights reserved.