Search code examples
javaandroidandroid-studiosdk

No variants found for ':app'. Check build files to ensure at least one variant exists


I created a new project and don't know why it doesn't build. It gives me error while gradle syncing.

My build.gradle(project) file :-

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        // Make sure that you have the following two repositories
        google()  // Google's Maven repository

        mavenCentral()  // Maven Central repository

    }
    dependencies {
        // Add the dependency for the Google services Gradle plugin
        classpath 'com.google.gms:google-services:4.3.15'
    }
}
plugins {
    id 'com.android.application' version '8.0.2' apply false
    id 'com.android.library' version '8.0.2' apply false
}

My build.gradle(module) file :-

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

android {
    namespace 'com.dccodes.choivpn'
    compileSdk 33

    defaultConfig {
        applicationId "com.dccodes.choivpn"
        minSdk 24
        targetSdk 33
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        buildConfigField "String", "BASE_HOST", "\"https://awebhtpo3u8g5t.ecoweb-network.com\""

        buildConfigField "String", "BASE_CARRIER_ID", "\"touchvpn\""

        buildConfigField "String", "BASE_OAUTH_METHOD", "\"anonymous\""

        buildConfigField "String", "SHARED_PREFS", "\"NORTHGHOST_SHAREDPREFS\""
        buildConfigField "String", "STORED_HOST_URL_KEY", "\"com.northghost.afvclient.STORED_HOST_KEY\""
        buildConfigField "String", "STORED_CARRIER_ID_KEY", "\"com.northghost.afvclient.CARRIER_ID_KEY\""


        buildConfigField "Boolean", "USE_IN_APP_PURCHASE", "true"
        buildConfigField "String", "IN_APPKEY", "\"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAl5uXMT/9fIpE/SZvg2/5TeAgwtaCoUhyfZTff2UZqJaUN48fhr6Rev71Jyptw8ZswyOmR+E7y6JBxpxkOgw9BSUYaYmLwzJfcVaLBlU8dceFNGIEuToICMrJdRFCKjs2EfvFHjzg6uRFUUB4K+XikYlQE3plSAxxMpuuAwFaUYTqBB/ZOQVQDZF73kA7xaksePDex+yILc8+Sm5C/tfwVxx1aj1ISZmHj2S1ZYI4zHPMquO3hfxNxYMW+2VOzBrGu2ZbUnz8v1rPmHqMOQhV7mMLKTZRi53BsZ9OgfN+ObSnNw4rrGY3iOEUtaelHax0c1Dz2diyqO61luFKaoOcuwIDAQAB\""
        buildConfigField "String", "MONTHLY", "\"oll_feature_for_onemonth\""
        buildConfigField "String", "SIX_MONTH", "\"oll_feature_for_sixmonth\""
        buildConfigField "String", "YEARLY", "\"oll_feature_for_year\""

        buildConfigField "Boolean", "GOOGlE_AD", "true"
        buildConfigField "String", "GOOGLE_BANNER", "\"ca-app-pub-2776230443748497/8187740226\""
        buildConfigField "String", "GOOGLE_INTERSTITIAL", "\"ca-app-pub-2776230443748497/1897664040\""

        //one Signal
        manifestPlaceholders = [
                onesignal_app_id               : 'd9ff47d2-56c6-4afe-be81-ffdc107e6f66',
                // Project number pulled from dashboard, local value is ignored.
                onesignal_google_project_number: 'REMOTE'
        ]
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    packagingOptions {
        exclude 'lib/arm64-v8a/libopenvpn.so'
        exclude 'lib/arm64-v8a/libopvpnutil.so'
        exclude 'lib/arm64-v8a/libjbcrypto.so'
        exclude 'lib/arm64-v8a/libstlport_shared.so'
        exclude 'lib/armeabi-v7a/libopenvpn.so'
        exclude 'lib/armeabi-v7a/libopvpnutil.so'
        exclude 'lib/armeabi-v7a/libjbcrypto.so'
        exclude 'lib/armeabi-v7a/libstlport_shared.so'
        exclude 'lib/x86/libopenvpn.so'
        exclude 'lib/x86/libopvpnutil.so'
        exclude 'lib/x86/libjbcrypto.so'
        exclude 'lib/x86/libstlport_shared.so'
        exclude 'lib/x86_64/libopenvpn.so'
        exclude 'lib/x86_64/libopvpnutil.so'
        exclude 'lib/x86_64/libjbcrypto.so'
        exclude 'lib/x86_64/libstlport_shared.so'
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
    implementation platform('com.google.firebase:firebase-bom:32.1.1')
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'com.github.AnchorFreePartner.hydra-sdk-android:sdk-core:4.1.8'
    implementation 'com.github.AnchorFreePartner.hydra-sdk-android:hydra:4.1.8'
    implementation 'com.github.AnchorFreePartner.hydra-sdk-android:openvpn:4.1.8'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.appcompat:appcompat:1.4.2'
    implementation 'com.google.android.material:material:1.7.0-alpha02'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'com.jakewharton:butterknife:10.2.3'
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'
    implementation "com.airbnb.android:lottie:4.1.0"
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    implementation 'com.onesignal:OneSignal:3.15.4'
    implementation 'com.google.android.gms:play-services-location:21.0.1'

    //billing library
    implementation 'com.github.akshaaatt:Google-IAP:1.2.2'

    //bidding
    implementation 'com.google.ads.mediation:facebook:6.14.0.0'
    implementation 'com.google.android.gms:play-services-ads:22.1.0'
}

My settings.gradle file :-

pluginManagement {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}
rootProject.name = "Choi VPN"
include ':app'

I read all other solutions and also have downloaded API 33 sdk.

Proof:-

SDK Manager

I don't know why the project is not building. I hope you will help me.


Solution

  • Put this code in your build.gradle(Module:app) file :-

    constraints {
            implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") {
                because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
            }
            implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") {
                because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
            }
        }
    

    Add this in the dependency....