4

I am working on my final project and I wanted to do project with android studio, I'm really new to android studio, i encountered an error saying No variants found for ':app' I've tried to change or download another version of the SDK, but it solves nothing

Here is the build.gradle code:

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

 }

}

here is the code for 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'
}

and here is for the code for Settings.gradle:

pluginManagement {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}
dependencyResolutionManagement {
//    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
//    repositories {
//        google()
//        mavenCentral()
//    }
}
rootProject.name = "ChatApp"
include ':app'
Gita
  • 41
  • 3
  • Does this answer your question? [Android Studio: No build variant found error](https://stackoverflow.com/questions/64366729/android-studio-no-build-variant-found-error) Or [this](https://stackoverflow.com/questions/65979536/android-studio-error-no-variants-found-for-app)? – dominicoder Apr 22 '23 at 02:43
  • i have tried those but it didn't work – Gita Apr 22 '23 at 15:11

1 Answers1

0

Solution: Adding a Configuration to Resolve "No Variants Found for ':app'" Error

Step 1: Open Android Studio

Launch Android Studio and open your project.

Step 2: Access Run/Debug Configurations

Click "Run" in the top menu. Choose "Edit Configurations" from the dropdown.

Step 3: Add a New Configuration

In the "Run/Debug Configurations" window, locate existing configurations. As the error is related to app execution, focus on the "app" module configuration. Click the "+" (Add Configuration) on the top left. Select "Android App" from the dropdown.

Step 4: Configure the New Configuration

In the "General" tab: Choose the correct "app" module from the "Module" dropdown. Configure "Deploy" and "Launch" options as needed.

Step 5: Apply and Save

Click "Apply" at the bottom right to save. Click "OK" to close the window.

Step 6: Run or Debug

Now, run or debug your app. Use the green "Run" button (or hotkeys) with the newly added configuration. This process should resolve the "No Variants Found for ':app'" error in Android Studio.