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

元气小坏坏 提交于 2019-11-28 22:45:50

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'
        }
    }
}

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.

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>

Add this line:

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

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

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

android:supportsRtl="false"

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

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

and

android:supportsRtl="false"

it works perfectly.

Nafiu Lawal

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