Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio: No build variant found error

i am new to android development, i started developing from scratch on a project i bought online, following the documentation, i encountered a error saying No variants found for 'app'. Check build files to ensure at least one variant exists.

Here is the build.gradle code

apply plugin: 'com.android.application'  android { compileSdkVersion 29 buildToolsVersion "29.0.1" defaultConfig {     applicationId "com.app-10.app"     minSdkVersion 23     targetSdkVersion 29     versionCode 1     versionName "1.0"     testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes {     release {         minifyEnabled false         proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'     } } }  dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'androidx.appcompat:appcompat:1.0.2' implementation 'com.google.android.material:material:1.0.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.vectordrawable:vectordrawable:1.0.1' implementation 'androidx.legacy:legacy-support-v4:1.0.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' // Third Party Libraries //Glide library for image fetching from the web implementation 'com.github.bumptech.glide:glide:4.9.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0' //Material library for styling blocks implementation 'com.google.android.material:material:1.0.0' // Google Gson implementation 'com.google.code.gson:gson:2.8.5' // Retrofit implementation 'com.squareup.retrofit2:retrofit:2.6.1' implementation 'com.squareup.retrofit2:converter-gson:2.6.1' // Android-SpinKit implementation 'com.github.ybq:Android-SpinKit:1.4.0'  implementation files('libs/YouTubeAndroidPlayerApi.jar')  // gotev/android-upload-service implementation "net.gotev:uploadservice:3.5.2"  //A fast circular ImageView perfect for profile images implementation 'de.hdodenhof:circleimageview:3.0.1'  implementation 'org.apache.commons:commons-io:1.3.2'  } 
like image 725
Deepak Marpak Avatar asked Oct 15 '20 07:10

Deepak Marpak


People also ask

Where is build variants in Android Studio?

To change the build variant Android Studio uses, select Build > Select Build Variant in the menu bar. For projects without native/C++ code, the Build Variants panel has two columns: Module and Active Build Variant.

What is build variant in Android?

Build variants are the result of Gradle using a specific set of rules to combine settings, code, and resources configured in your build types and product flavors. Although you do not configure build variants directly, you do configure the build types and product flavors that form them.

How do I get the current build type in Gradle?

In your build. gradle (:app): tasks. all { Task task -> if (task.name == "preDebugBuild") { doFirst { //for debug build } } else if (task.name == "preReleaseBuild") { doFirst { //for release build } } } dependencies { ... }

What is Productflavors Android?

Android Product Flavors are used to create different app versions. App versions can be free or paid. They can have different themes and texts. They can use different environments or APIs. Let's assign two product flavors free and paid in our application.


1 Answers

I have just solved the same issue like this:

Tools -> SDK Manager

Verify that the SDK platform package for Android 10.0 (the one with API level 29, like you defined in your gradle file) is checked. If not, check it and apply changes. Accept the licence terms, install the package and then File -> Sync Project with Gradle Files (or open the project again)

like image 66
Fabio Rosati Avatar answered Sep 23 '22 23:09

Fabio Rosati