Error:Failed to resolve: com.twitter.sdk.android:twitter:2.3.0 - Android Studio

与世无争的帅哥 提交于 2019-12-29 04:12:29

问题


I am getting this error in my log cat

Error:Failed to resolve: com.twitter.sdk.android:twitter:2.3.0

When I try adding this dependency:

compile 'com.firebaseui:firebase-ui:1.1.1'

Can someone please help me out, I am not sure what I am doing wrong. This is the link from where I got the dependency from: https://github.com/firebase/FirebaseUI-Android. On a side note, I am not using twitter login or any sort of interaction with twitter in my application, so I am not sure why I get that error when I sync my gradle after putting that dependency.


回答1:


Your project's gradle file should look like this.

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

allprojects {
    repositories {
        jcenter()

        // Required for 'com.firebaseui:firebase-ui:1.1.1'
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
}



回答2:


Let's begin with why - this is from Firebase Authentication docs: "Firebase Authentication provides backend services, easy-to-use SDKs, and ready-made UI libraries to authenticate users to your app. It supports authentication using passwords, popular federated identity providers like Google, Facebook and Twitter, and more."

So, by using Firebase Authentication we can allow users of our apps to log in with their Google, Facebook, GitHub or - Twitter account.

Now the help - a bit of detective work reveals, what is happening here. When using something from Git repository - in this case github.com/firebase/FirebaseUI-Android - we should always read the README.md file.

...github.com/firebase/FirebaseUI-Android/blob/master/README.md

Installation...

dependencies {
    // FirebaseUI Database only
    compile 'com.firebaseui:firebase-ui-database:1.2.0'

    // FirebaseUI Auth only
    compile 'com.firebaseui:firebase-ui-auth:1.2.0'

    // FirebaseUI Storage only
    compile 'com.firebaseui:firebase-ui-storage:1.2.0'

    // Single target that includes all FirebaseUI libraries above
    compile 'com.firebaseui:firebase-ui:1.2.0'
}

You are using com.firebaseui:firebase-ui:1.1.1, which is older version than in the actual README.md, but this comment still applies:

// Single target that includes all FirebaseUI libraries above

So, since it includes all three libraries in one, let's go and read the READMEs for each one of them.

They can be found on the main page in their folders - database, auth, storage

https://github.com/firebase/FirebaseUI-Android

Storage and Database READMEs are about how to use them in Java code, nothing else there.

But the Auth README.md has something about configuration - and since we are talking about configuration here: https://github.com/firebase/FirebaseUI-Android/tree/master/auth

Configuration

As a pre-requisite, ensure your application is configured for use with Firebase: see the Firebase documentation. Then, add the FirebaseUI auth library dependency. If your project uses Gradle, add the dependency:

dependencies {
    // ...
    compile 'com.firebaseui:firebase-ui-auth:1.2.0'
}

and add the Fabric repository

allprojects {
    repositories {
        // ...
        maven { url 'https://maven.fabric.io/public' }
    }
}

Now, it is not exactly clear, where they want us to put these code snippets, but "dependencies" are in the App level build.gradle file and the "allprojects" section is in the Project level build.gradle file.




回答3:


Expanding @Hemant Menon answer, and answering @Pheonix's question.

Add the following line inside "repositories", inside "allprojects" and "buildscript" to your Project Level build.gradle file:

maven {
    url 'https://maven.fabric.io/public'
}

So the file will look like:

buildscript {
    repositories {
        [...]
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
}

allprojects {
    repositories {
        [...]
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
}

[...]

Also you'll have to add the following line to your app's Manifest file:

tools:replace="android:supportsRtl"

So it will look like:

<?xml version="1.0" encoding="utf-8"?>
<manifest
    [...]
    xmlns:tools="http://schemas.android.com/tools" >

    <application
        [...]
        tools:replace="android:supportsRtl">
        <activity>
            [...]
        </activity>

    </application>

</manifest>



回答4:


Add this line:

maven { url 'https://maven.fabric.io/public' }

inside repositories under both buildscript and allprojects in the build/gradle file.




回答5:


In Android Manifest file, set android:supportsRtl from "true" to "false"

android:supportsRtl="false"




回答6:


In my case, i do both the things i added,

maven { 
    url 'https://maven.fabric.io/public' 
 }

and

android:supportsRtl="false"

it works perfectly.




回答7:


Use this instead. They are the latest versions of each firebaseui components.

// FirebaseUI for Firebase Realtime Database
implementation 'com.firebaseui:firebase-ui-database:5.0.0'

// FirebaseUI for Cloud Firestore
implementation 'com.firebaseui:firebase-ui-firestore:5.0.0'

// FirebaseUI for Firebase Auth
implementation 'com.firebaseui:firebase-ui-auth:5.0.0'

// FirebaseUI for Cloud Storage
implementation 'com.firebaseui:firebase-ui-storage:5.0.0'


来源:https://stackoverflow.com/questions/41659272/errorfailed-to-resolve-com-twitter-sdk-androidtwitter2-3-0-android-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!