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

后端 未结 15 1150
误落风尘
误落风尘 2020-12-05 22:31

I can\'t compile my Android Kotlin project.

I have no idea what is this...

Gradle log:

error: supertypes of the following classes ca

相关标签:
15条回答
  • 2020-12-05 23:21

    I fixed this error upgrading others libraries. My error showed when I added firebase=ads (from google adsmob). So I found a conflict in my firebase-auth (16.0.5) and firebase ads (19.0.1).

    Migrating firebase to 19.3.0 solved the problem.

    0 讨论(0)
  • 2020-12-05 23:24

    In my case, I went to the project structure and updated all firebase dependencies to the latest and the highest. At the moment here are implementations with their versions:

        implementation 'com.google.firebase:firebase-auth:19.3.1'
        implementation 'com.google.firebase:firebase-database:19.3.1'
        implementation 'com.google.firebase:firebase-storage:19.1.1'
        implementation 'com.google.firebase:firebase-analytics:17.4.3'
    
    0 讨论(0)
  • 2020-12-05 23:24

    Well in my case this error randomly occurs which usually occurs during execution through Android Studio.

    The root cause was that My Activity class were extending some interfaces which was in another nested package:

    package tv.activities

    public class MainActivity implements MyListener {
    
    } 
    

    package tv.activities.error

    interface MyListener {
    
    }
    

    Hence it usually happens during execution but after second run it resolves automatically so no one bother to resolve it. Sometimes Android Studio fail to recognise that interface is accessible so there is no sense of showing error for the same:

    Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
        class tv.activities.MainActivity, unresolved supertypes: MyListener
    

    Final Solution:

    Making interface public resolves this issue permanently.

    public interface MyListener {
    }
    

    Or refactor the package accessibility where AS doesn't get confuse

    0 讨论(0)
  • 2020-12-05 23:27

    When setting up the crashlytics to my app, I used "recommended" dependency as well, as shown below. But this was the part causes error.

    // Firebase Crashlytics
    // (Recommended) Add the Google Analytics dependency.
    implementation 'com.google.firebase:firebase-analytics:17.2.1'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
    

    Removing "analytics" line solved my problem.

    // Firebase Crashlytics
    implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
    

    Hope this helps someone else too,

    best

    0 讨论(0)
  • 2020-12-05 23:29

    Update your Android Studio sdk and run this project again.. Then your problem will be solved..

    0 讨论(0)
  • 2020-12-05 23:31

    I was getting error for below lib in app level build.gradle

      implementation 'com.google.firebase:firebase-iid:20.0.2'
    

    So the solution is the order in project level build.gradle, So before solving error the structure was

    buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
    
        google()
        jcenter()
        mavenCentral()
        maven {
            url "https://maven.google.com"
        }
    
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
        classpath 'com.google.gms:google-services:4.3.3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
    }
    
    allprojects {
    repositories {
    
        google()
        jcenter()
        mavenCentral()
        maven {
            url "https://maven.google.com" // Google's Maven repository
        }
    
    }
    }
    
    task clean(type: Delete) {
    delete rootProject.buildDir
    }
    

    After Solving the error the struture is :

    buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
         maven {
            url "https://maven.google.com"
        }
        google()
        jcenter()
        mavenCentral()
    
    
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
        classpath 'com.google.gms:google-services:4.3.3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
    }
    
    allprojects {
    repositories {
        maven {
            url "https://maven.google.com" // Google's Maven repository
        }
        google()
        jcenter()
        mavenCentral()
    
    
    }
    }
    
    task clean(type: Delete) {
    delete rootProject.buildDir
    }
    

    By default it tries to download using google() as it comes first in the sequence but when we move maven on top of all then it creates the build again using maven and the build succeeds. Cheers :)

    0 讨论(0)
提交回复
热议问题