Alejandro H. Cruz
Alejandro H. Cruz

Reputation: 557

Firebase unresolved supertype with Kotlin on Android

I'm experiencing a problem in my project that uses Firebase core and messaging v11.4.2.

The gradle sync works perfectly but then I get this error when compiling:

e: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:

class com.google.android.gms.internal.zzctr, unresolved supertypes: com.google.android.gms.internal.zzee

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ‘:app:compileDebugKotlin’. Compilation error. See log for more details

I've tried both with Kotlin version 1.1.51 and 1.2.0-beta-88; Gradle plugins v2.3.3 and 3.0.0

Any help is welcomed, thanks a lot!

This is how I've configured the project:

app build.gradle

// tried adding and removing the -kapt and -android-extensions. Didn't help.
apply plugin: 'com.android.application'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'

debug {

/// added this to be sure the class was not being left out
minifyEnabled false
shrinkResources false
useProguard false
}

...

dependencies {

 // Firebase Core
implementation "com.google.firebase:firebase-core:${rootProject.ext.firebaseVersion}"
// Firebase Cloud Messaging
implementation "com.google.firebase:firebase-messaging:${rootProject.ext.firebaseVersion}"
}

...

// Keep this as the last line or the build will fail
apply plugin: 'com.google.gms.google-services'

* project build.gradle *

buildscript {
    // App
    ext.compileSdkVersion = 26
    ext.minSdkVersion = 18
    ext.buildToolsVersion = '26.0.2'
    ext.targetSdkVersion = 26

    // Kotlin beta, stable version doesn't compile either
    ext.kotlin_version = '1.2.0-beta-88'

    // Android
    ext.androidSupportVersion = '26.1.0'
    //TODO: implement LifecycleOwner interface from Architecture Components.
   ext.lifecycleVersion = '1.0.0-beta2'

    // Architecture, RxJava, Injection
    ext.daggerVersion = '2.11'
    ext.butterKnifeVersion = '8.8.1'
    ext.rxJavaVersion = '2.1.0'
    ext.rxAndroidVersion = '2.0.1'

    // Google/Firebase Cloud Message
    ext.firebaseVersion = '11.4.2'

    // Libraries shared between modules (TODO)
}

repositories {
    maven { url 'https://maven.google.com' }     // Google Maven Repository

    maven { url 'http://dl.bintray.com/kotlin/kotlin-eap-1.2'} // Kotlin beta
}

dependencies {
     classpath 'com.android.tools.build:gradle:3.0.0'
     classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
     classpath 'com.google.gms:google-services:3.1.1'  // google-services plugin
     //// tried this too: classpath 'com.google.firebase:firebase-plugins:1.1.1'            
}

allprojects {
repositories {
    jcenter()
    mavenLocal()
    maven { url 'http://dl.bintray.com/kotlin/kotlin-eap-1.2'}
    maven { url "https://jitpack.io" }
    maven { url 'https://maven.google.com' }

    mavenCentral()
    flatDir {
        dirs 'libs'
    }

}

Upvotes: 0

Views: 1624

Answers (1)

Alejandro H. Cruz
Alejandro H. Cruz

Reputation: 557

Turns out the problem was an incompatible version of the Google Wallet library, being implemented by another dependency of the project and conflicting with the one imported by the com.google.gms.google-services plugin.

For some reason gradle didn't state this problem and I had to go through the code until I found the place where Wallet was trying to access a class that was successfully importing but at the same time it couldn't be found.

Simply by updating the version in the other module everything was fixed :)

Upvotes: 1

Related Questions