Home » Android » Twitter Fabric fails to install in Android Studio due to missing dependencies

Twitter Fabric fails to install in Android Studio due to missing dependencies

Posted by: admin May 14, 2020 Leave a comment

Questions:

I’m setting up a Cordova project with Fabric to enable signing in with Twitter. I just installed Fabric plug-in into Android Studio but when I sync Gradle files I get the following error:

Information:Gradle tasks [:generateDebugSources, :generateDebugTestSources]
Error:A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_debugCompile'.
   > Could not find com.squareup.picasso:picasso:2.3.2.
     Searched in the following locations:
         https://maven.fabric.io/public/com/squareup/picasso/picasso/2.3.2/picasso-2.3.2.pom
         https://maven.fabric.io/public/com/squareup/picasso/picasso/2.3.2/picasso-2.3.2.jar
     Required by:
         :android:unspecified > com.twitter.sdk.android:twitter:1.1.1 > com.twitter.sdk.android:tweet-ui:1.0.3
   > Could not find com.android.support:support-v4:21.0.0.
     Searched in the following locations:
         https://maven.fabric.io/public/com/android/support/support-v4/21.0.0/support-v4-21.0.0.pom
         https://maven.fabric.io/public/com/android/support/support-v4/21.0.0/support-v4-21.0.0.jar
     Required by:
         :android:unspecified > com.twitter.sdk.android:twitter:1.1.1 > com.twitter.sdk.android:tweet-ui:1.0.3
   > Could not find com.squareup.retrofit:retrofit:1.6.1.
     Searched in the following locations:
         https://maven.fabric.io/public/com/squareup/retrofit/retrofit/1.6.1/retrofit-1.6.1.pom
         https://maven.fabric.io/public/com/squareup/retrofit/retrofit/1.6.1/retrofit-1.6.1.jar
     Required by:
         :android:unspecified > com.twitter.sdk.android:twitter:1.1.1 > com.twitter.sdk.android:twitter-core:1.1.1
   > Could not find com.google.code.gson:gson:2.2.4.
     Searched in the following locations:
         https://maven.fabric.io/public/com/google/code/gson/gson/2.2.4/gson-2.2.4.pom
         https://maven.fabric.io/public/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar
     Required by:
         :android:unspecified > com.twitter.sdk.android:twitter:1.1.1 > com.twitter.sdk.android:twitter-core:1.1.1

Android SDK updater gives me Support Library 21.0.3 but not 21.0.0, as suggested here by Hemal from Fabric: Android Twitter Fabric SDK conflict with support library

I have no idea about those other libraries, though. Any thoughts?

How to&Answers:

Please follow this code example to make sure your build.gradle file is similar:

    buildscript {
  repositories {
    jcenter()   // <- *add this
    maven { url 'https://maven.fabric.io/repo' }
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:0.13.3'
    // The Fabric Gradle plugin uses an open ended version to
    // react quickly to Android tooling updates
    classpath 'io.fabric.tools:gradle:1.+'
  }
}

apply plugin: 'com.android.application'   // <- *make sure this is the same

//Put Fabric plugin after Android plugin
apply plugin: 'io.fabric'

repositories {
    jcenter()   // <- *add this
    maven { url 'https://maven.fabric.io/repo' }
}

I had the same issue, spent half a day on this until opened twitters official documentation and came across this:
https://dev.twitter.com/twitter-kit/android/integrate

Too many answers by the Fabric team on SO and other forums that did not work. This works.

Answer:

Change jcenter() to mavenCentral() or you can keep both jcenter and mavenCentral
also change url from https://maven.fabric.io/repo to https://maven.fabric.io/public

buildscript {
    repositories {
        mavenCentral()   // <- *add this
        maven { url 'https://maven.fabric.io/public' }
    }
}

Answer:

It’s not enough to install the fabric plugin, you have to use it too. Clicking on the fabric button in Android Studio guides you through the process of including twitter fabric in your app, it even modifies the build.gradle properly for you (with your permission of course). When you follow the steps given, your build.gradle would be looking like what @AlexVPerl’s answer says.

Answer:

Other answers were outdated for me. I fixed the problem by updating build.gradle according to the latest on the github:

https://github.com/twitter/twitter-kit-android