Trove4j library cannot be resolved

AndroidMavenAndroid Gradle-Plugin

Android Problem Overview


I'm getting the following error when trying to compile my app:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':myProject'.
> Could not resolve all files for configuration ':myProject:classpath'.
   > Could not find org.jetbrains.trove4j:trove4j:20160824.
     Searched in the following locations:
         https://repo1.maven.org/maven2/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
         https://repo1.maven.org/maven2/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.jar
         https://maven.fabric.io/public/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
         https://maven.fabric.io/public/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.jar
         https://maven.google.com/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
         https://maven.google.com/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.jar
     Required by:
         project :metam > com.android.tools.build:gradle:3.0.0-beta2 > com.android.tools.build:gradle-core:3.0.0-beta2 > 
com.android.tools.lint:lint:26.0.0-beta2 > com.android.tools.lint:lint-checks:26.0.0-beta2 > com.android.tools.lint:lint-
api:26.0.0-beta2 > com.android.tools.external.com-intellij:intellij-core:26.0.0-beta2

It appears a library the IDE needs is missing?

Android Solutions


Solution 1 - Android

this issue can be resolved by adding jcenter() as a repository in the buildscript section.

buildscript {
  repositories {
     jcenter()
  }

  dependencies {
    classpath 'com.android.tools.build:gradle:3.0.0-beta2'
  }
}

Solution 2 - Android

Additional to Snicolas' answer:

If you have something like:

allprojects {
    repositories {
        mavenCentral()
        google()
        jcenter() //also add it here!!!
    }
}

In your build.gradle file; also add it there.

Solution 3 - Android

Since jCenter will close in May, you should change root/build.gradle so:

buildscript {
    repositories {
        google()
        gradlePluginPortal()
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        // org.jetbrains.trove4j:trove4j:20160824.
        gradlePluginPortal()
    }
}

See also https://stackoverflow.com/a/66168563/2914140 to add libraries not included in Maven.

Now we can build apk without errors.

Solution 4 - Android

If you're seeing this error after May 1st 2021, it's probably because jcenter is shut down. It's needed by the Android Gradle Plugin (AGP). Google devs have said they're using a newer version of the library that can be got from mavenCentral() as of AGP 7 and hoping to backport that into AGP 4.2 and 4.1. So first of all, try and upgrade to AGP 7. And if I haven't edited this post with updates, check to see is it in any lower AGP versions.

But if you can't upgrade AGP, as of initial time of posting (February 2021), the only repo I could find with the trove package is on pentaho, which seems to be owned by Hitachi so I presume it's safe.

buildscript {
   repositories {
         maven { url "https://nexus.pentaho.org/content/groups/omni" }
   }

   dependencies {
         classpath 'org.jetbrains.trove4j:trove4j:20160824'
   }
}

This is NOT an ideal solution. This repo could be intended to be private for all I know. Look for a better answer that might be posted after me.

Solution 5 - Android

I solved this problem deleting in build.gradlew

repositories {
    jcenter()
}

And change the mavenCentral() to jcenter() and deleting google()

Solution 6 - Android

Migrating away from jcenter? jcenter will sunset on the 1st of May

You may face this issue if you are migrating away from jcenter. The issue happens because Trove4j library was being fetched from jcenter and you removed jcenter repository while migrating away from jcenter.

Solution:

Add the following to the project build.gradle:

maven { url 'https://plugins.gradle.org/m2/' } 

It should be added to:

  1. build.gradle(peoject) -> buildscript -> repositories

  2. build.gradle(peoject) -> allprojects -> repositories

    buildscript {
    
        repositories {
            google()
            mavenCentral()
            // ** Add this line **
            maven { url 'https://plugins.gradle.org/m2/' }
        }
    }
    
    allprojects {
        repositories {
            google()
            mavenCentral()
            // ** Add this line **
            maven { url 'https://plugins.gradle.org/m2/' }
        }
    }
    

Since jcenter will sunset on 1st of May, 2021. jcenter repository should be removed from the project. This means that all occurrences to "jcenter()" should be removed. This can lead to an issues with the libraries hosted by jcenter. You should provide another repository that host the library such as maven. Some unmaintained libraries maybe are not moved to any other repository. In this case, you might need to consider opening an issue for the library or not using it. You will face all these issues on the 1st of May and you may be unable to build your app if you are not doing the migration now.

Solution 7 - Android

Just delete .idea,.gradle and gradle folder and restart your application.

Solution 8 - Android

Try to replace mavenCentral() with jcenter() in your build.gradle file

allprojects {
    repositories {
        
        jcenter() 
      //.......
    }
}

Solution 9 - Android

Go to Help->About in Android Studio and check your version. Enter that vesion in build.gradle App Mudule & same for project build.gradle as done in the classpath line here:

buildscript {
     ...
    repositories {
     ...
    }
    dependencies {
     ...
     classpath "com.android.tools.build:gradle:{THREE.DIGIT.VERSION}"
    }
}

Like in image

Solution 10 - Android

This was happening to me every time I upgraded the Gradle Plugin, so what I did and worked:

  1. Delete your package-lock.json or yarn.lock
  2. Run npm i or yarn to update all node modules in your project
  3. Rename your ios project to ios_ for example
  4. Run react-native link to link all dependencies again to your android project
  5. Rename back ios_ to ios
  6. Check the file (project/build.gradle) what Gradle Plugin version you're using. The version 3.4.1 worked for me.
  7. Check your Gradle version (gradle/wrapper/gradle-wrapper.properties), the version 5.4.1 worked here.
  8. Open your Android project using Android Studio, navigate to Build > "Rebuild project"
  9. And finally, try sync/build again.

Hope it can help someone.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionmraviatorView Question on Stackoverflow
Solution 1 - AndroidSnicolasView Answer on Stackoverflow
Solution 2 - AndroidMadBoomyView Answer on Stackoverflow
Solution 3 - AndroidCoolMindView Answer on Stackoverflow
Solution 4 - AndroidgeorgiecaseyView Answer on Stackoverflow
Solution 5 - AndroidJperson98View Answer on Stackoverflow
Solution 6 - AndroidIslam AssiView Answer on Stackoverflow
Solution 7 - AndroidTara Singh DanuView Answer on Stackoverflow
Solution 8 - AndroidBasiView Answer on Stackoverflow
Solution 9 - AndroidAmit SaxenaView Answer on Stackoverflow
Solution 10 - AndroidCalhauView Answer on Stackoverflow