Unknown LibraryVariants - Gradle property not syncing

Shortening the long story: I'm using the Android app to use the Azure mobile app services to use Google Firebase. Firebase was very simple and easy to configure for Javascript, but I had endless problems installing Android.

My application has three modules: full, Lite and the third module, which acts as a library. I am trying to configure the application so that the full version supports Firebase, and I did this using an assistant built into Android studio. After that, it will not be built, because the added JSON file included only the full name of the package. As a result, I created 3 versions of the application in the Firebase console and manually added the JSON file to the project (net.gptiming, net.gptiming.full and net.gptiming.library). It seems to have worked - I can use Firebase libraries and firmware.

The next problem I discovered is that Firebase failed to initialize. After hours of trawling Google and stackoverflow, I discovered that this could be due to inconsistent libraries. My first step was to update Android studio (to version 2.3.2) and the latest Google repositories and build tools.

Now this has given another problem - one that I cannot find anywhere on the Internet. Gradle will not sync due to the following error:

"Could not get unknown property 'LibraryVariants' for object of type com.android.build.gradle.LibraryExtension" 

This error appears in the Gradle library build file, which contains the following:

 apply plugin: 'com.android.library' android { compileSdkVersion rootProject.compileSdkVersion buildToolsVersion rootProject.buildToolsVersion buildToolsVersion '23.0.2' } dependencies { compile 'com.google.code.gson:gson-parent:2.7' compile 'com.google.firebase:firebase-core:10.2.1' compile 'com.google.firebase:firebase-database:10.2.1' compile 'com.google.firebase:firebase-auth:10.2.1' } apply plugin: 'com.google.gms.google-services' 

The Gradle project file is as follows:

 buildscript { repositories { mavenCentral() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.0' classpath 'com.google.gms:google-services:3.1.0' } } allprojects { repositories { mavenCentral() jcenter() } } ext { compileSdkVersion = 19 buildToolsVersion = "23.0.2" storeFilePath = System.getenv('STORE_FILE') storePassword = System.getenv('STORE_PASSWORD') keyAlias = System.getenv('KEY_ALIAS') keyPassword = System.getenv('KEY_PASSWORD') } 

and here is the full version module file:

 apply plugin: 'com.android.application' dependencies { compile project(':gptiming-gptiming') compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.google.firebase:firebase-database:10.2.1' compile 'com.google.firebase:firebase-auth:10.2.1' } android { compileSdkVersion rootProject.compileSdkVersion buildToolsVersion rootProject.buildToolsVersion if (rootProject.storeFilePath) { signingConfigs { release { storeFile file(rootProject.storeFilePath) storePassword rootProject.storePassword keyAlias rootProject.keyAlias keyPassword rootProject.keyPassword } } buildTypes { release { signingConfig signingConfigs.release } } } buildToolsVersion '25.0.0' } apply plugin: 'com.google.gms.google-services' 

So far, I have tried to change the version of Gradle to 2.3, however Android studio 2.3.2 does not support the older version of Gradle. I also tried changing the build tool versions to the ones shown above, which didn't make any difference. Android Studio did not offer additional help on this issue.

Sorry for the long question, but I'm new when it comes to Android development. I donโ€™t quite understand how the library aspect with respect to Gradle works and how to integrate Firebase correctly, as the documentation is a bit sparse and the built-in tools are useless. I don't know if the error has anything to do with Firebase or just a simple Gradle mismatch, but any help would be greatly appreciated!

I must say that I had no problems with this library structure before updating the version of Android studio and related tools - however, this could be masked by the problems of the Firebase library. The app worked with Azure before these changes.

+8
android android-studio google-play-services gradle firebase
source share
1 answer

I had the same problem with my library module and I decided to upgrade gradle and google-services versions.

 // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.0.0' classpath 'com.google.gms:google-services:3.1.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } 
+1
source share

All Articles