Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The module 'app' is an Android project without build variants

I am getting below error while importing android project.

Error:The module 'app' is an Android project without build variants, and cannot be built. Please fix the module's configuration in the build.gradle file and sync the project again.

Gradle file code.

apply plugin: 'com.android.application'  android { compileSdkVersion 25 buildToolsVersion "25.0.3"  defaultConfig {     applicationId "com.djalel.android.bilal"     minSdkVersion 9     targetSdkVersion 25     versionCode 4     versionName "1.3" }  buildTypes {     release {         minifyEnabled true         proguardFiles getDefaultProguardFile('proguard-android.txt')     } }  aaptOptions {     cruncherEnabled = false } }  dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'com.android.support:appcompat-v7:25.3.1' implementation 'com.android.support.constraint:constraint-layout:1.0.2' implementation 'com.android.support:design:25.3.1' implementation 'com.android.support:support-v4:25.3.1' implementation 'com.google.android.gms:play-services-location:12.0.1' implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1' implementation 'com.jakewharton.timber:timber:3.1.0' } repositories { mavenCentral() } 

I checked with working gradle file as well but getting same error in this project.

like image 977
Md Mohsin Avatar asked Apr 14 '18 18:04

Md Mohsin


People also ask

What are modules in Android project?

Modules. A module is a collection of source files and build settings that allow you to divide your project into discrete units of functionality. Your project can have one or many modules, and one module may use another module as a dependency. You can independently build, test, and debug each module.

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.

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 a build type in Gradle Android?

A build type determines how an app is packaged. By default, the Android plug-in for Gradle supports two different types of builds: debug and release . Both can be configured inside the buildTypes block inside of the module build file.


2 Answers

Above gradle file code seems to be perfect. Probably its nothing to do with app/build.gradle (Module:app). Just open other build.gradle (Project:Android) file in Project window and verify your Android Studio version it must be same as yours.

I replaced from:

dependencies {     classpath 'com.android.tools.build:gradle:3.2.1'     // NOTE: Do not place your application dependencies here; they belong     // in the individual module build.gradle files } 

to my Android Studio v3.0.1 in my case:

dependencies {     classpath 'com.android.tools.build:gradle:3.0.1'     // NOTE: Do not place your application dependencies here; they belong     // in the individual module build.gradle files } 

Press "Try Again" to Sync gradle file. This resolved my problem with a successful build.

like image 115
Moeed Ahmed Avatar answered Sep 22 '22 03:09

Moeed Ahmed


For me, this issue appeared when I updated Android Studio to version 3.3.
Disabling experimental feature "Only sync the active variant" fixes it:

enter image description here

like image 32
Dmitry Chistyakov Avatar answered Sep 19 '22 03:09

Dmitry Chistyakov