同步Gradle项目时如何解决“错误:无法解析com.android.support:support-v4:[22,23)”

时间:2019-05-25 13:06:38

标签: android gradle build.gradle

同步Gradle Project时出现以下三个错误:

  1. 无法解决':app @ debug / compileClasspath'的依赖关系:无法解决com.android.support:support-v4:[22,23)。
  2. 无法解决':app @ debugAndroidTest / compileClasspath'的依赖关系:无法解决com.android.support:support-v4:[22,23)。
  3. 无法解决':buzzshow @ debugUnitTest / compileClasspath'的依赖关系:无法解决com.android.support:support-v4:[22,23)。

这是我的build.gradle文件代码:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        maven { url "https://maven.google.com" }
        mavenCentral()
        google()
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'android'
apply plugin: 'io.fabric'
repositories {
    maven { url 'https://maven.reveel.it/public' }
    maven { url 'https://mvn.jwplayer.com/content/repositories/releases/' }
}

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'
    useLibrary 'org.apache.http.legacy'
    project.archivesBaseName = "AppName"
    defaultConfig {
        multiDexEnabled true
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 32
        versionName "6.22.9"
        applicationId = "com.buzzshownetwork.buzzshow"
//        javaCompileOptions {
//            annotationProcessorOptions {
//                includeCompileClasspath true
//            }
//        }
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }

//        debug {
//            minifyEnabled false
//            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
//            android.applicationVariants.all { variant ->
//                variant.outputs.all {
//                    outputFileName = "BuzzShow-v${variant.versionName}.apk"
//                }
//            }
//            testCoverageEnabled false
//        }

        packagingOptions {

            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/ASL2.0'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/NOTICE'
        }
        lintOptions {
            checkReleaseBuilds false
            // Or, if you prefer, you can continue to check for errors in release builds,
            // but continue the build even when errors are found:
            abortOnError false
        }
        productFlavors {
        }
        compileOptions {
            targetCompatibility 1.8
            sourceCompatibility 1.8
        }
    }
    repositories {
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
        maven { url "https://jitpack.io" }
    }
    dependencies {
        implementation 'com.android.volley:volley:1.1.0'
        //compile files('libs/twitter4j-core-3.0.3.jar')
        implementation files('libs/universal-image-loader-1.8.4.jar')
        implementation 'com.android.support:support-v4:28.0.0'
        //compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
        implementation 'com.android.support:appcompat-v7:28.0.0'
        implementation 'com.android.support.constraint:constraint-layout:1.0.2'
        implementation 'com.github.ozodrukh:CircularReveal:1.1.0'
        implementation 'com.android.support:design:28.0.0'
        implementation 'com.android.support:cardview-v7:28.0.0'
        implementation 'de.hdodenhof:circleimageview:3.0.0'
        implementation 'com.andkulikov:transitionseverywhere:1.7.9'
        implementation 'com.scottyab:aescrypt:0.0.1'
        implementation 'com.facebook.android:facebook-android-sdk:4.6.0'

        implementation "com.android.support:customtabs:28.0.0"
        implementation "com.android.support:mediarouter-v7:28.0.0"
        implementation "com.android.support:support-fragment:28.0.0"


        implementation 'com.twitter.sdk.android:twitter-core:3.1.1'
        implementation 'com.twitter.sdk.android:tweet-composer:3.1.1'
        implementation 'com.github.zcweng:switch-button:0.0.3@aar'
        // Dexter runtime permissions
        implementation 'com.karumi:dexter:4.2.0'
        implementation files('libs/YouTubeAndroidPlayerApi.jar')
        implementation('com.crashlytics.sdk.android:crashlytics:2.9.4@aar') {
            transitive = true
        }
        implementation 'tech.gusavila92:java-android-websocket-client:1.2.0'
        implementation 'com.android.support:exifinterface:28.0.0'
        implementation('com.github.bumptech.glide:glide:4.4.0') {
            exclude group: "com.android.support"
        }
        annotationProcessor 'com.github.bumptech.glide:compiler:4.4.0'
        implementation 'me.leolin:ShortcutBadger:1.1.22@aar'
        implementation 'com.neovisionaries:nv-websocket-client:2.6'
        implementation 'org.java-websocket:Java-WebSocket:1.3.0'
        implementation 'org.apache.commons:commons-text:1.6'
        implementation 'com.sothree.slidinguppanel:library:3.4.0'
        implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.16'
        compileOnly 'androidx.annotation:annotation:1.0.1'
        implementation 'com.github.aakira:expandable-layout:1.6.0@aar'
        implementation 'com.github.aakira:expandable-layout:1.6.0@aar'

        implementation 'com.longtailvideo.jwplayer:jwplayer-core:3.4.2'
        implementation 'com.longtailvideo.jwplayer:jwplayer-common:3.4.2'
        implementation 'com.android.support:multidex:1.0.3'
        // Only required if using Chromecast
        implementation 'com.longtailvideo.jwplayer:jwplayer-chromecast:3.4.1'

        // Only required if using FreeWheel
        implementation 'com.longtailvideo.jwplayer:jwplayer-freewheel:3.4.1'

        // Only required if using IMA features
        implementation 'com.longtailvideo.jwplayer:jwplayer-ima:3.4.1'

        implementation "it.reveel.sdk.videoplugin:reveel-video-plugin:1.0.1"
        implementation "it.reveel.sdk.videoplugin:video-player-jwplayer:1.0.1"

        implementation([
                'com.snapchat.kit.sdk:creative:1.1.4',
                'com.snapchat.kit.sdk:core:1.1.4'
        ])

    }
}

这是我的Android清单文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.buzzshownetwork.buzzshow">

    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <!-- Samsung -->
    <uses-permission android:name="com.sec.android.provider.badge.permission.READ" />
    <uses-permission android:name="com.sec.android.provider.badge.permission.WRITE" />

    <!-- Sony -->
    <uses-permission android:name="com.sonyericsson.home.permission.BROADCAST_BADGE" />

    <!-- HTC -->
    <uses-permission android:name="com.htc.launcher.permission.READ_SETTINGS" />
    <uses-permission android:name="com.htc.launcher.permission.UPDATE_SHORTCUT" />

    <uses-feature
        android:name="android.hardware.camera"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.camera.autofocus"
        android:required="false" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />



    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

    <application

        android:fullBackupContent="false"
        android:allowBackup="false"
        android:name=".ClipClashApplication"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:theme="@style/AppTheme"

        >
        <activity
            android:name=".SplashActivity"
            android:launchMode="singleTop"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme"
            android:windowSoftInputMode="stateHidden">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <data android:scheme="buzzshow" />
                <data
                    android:host="buzzshow.com"
                    android:pathPattern=".*"
                    android:scheme="http" />
                <data
                    android:host="www.buzzshow.com"
                    android:pathPattern=".*"
                    android:scheme="http" />

                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
            </intent-filter>
        </activity>
        <activity
            android:name=".activties.LoginActivity"
            android:exported="false"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme"
            android:windowSoftInputMode="adjustPan|stateAlwaysHidden" />
        <activity
            android:name=".activties.RegisterActivity"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme"
            android:windowSoftInputMode="adjustPan|stateAlwaysHidden" />
        <!--<meta-data android:name="com.snapchat.kit.sdk.clientId" android:value="1703517e-766f-47a7-be37-26e529ac121d" />-->

        <meta-data android:name="com.snapchat.kit.sdk.clientId"
            android:value="@string/client_id" />
        <provider
            android:authorities="${applicationId}.fileprovider"
            android:name="android.support.v4.content.FileProvider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_paths"
                />
        </provider>
        <meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id" />
        <meta-data
            android:name="com.crashlytics.ApiKey"
            android:value="e42855d269d9406c1a21417dd2bfb4669c93a5d4" />
        <meta-data
            android:name="JW_LICENSE_KEY"
            android:value="@string/jWplayer" />

        <activity android:name="com.facebook.FacebookActivity"
            android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
            android:theme="@android:style/Theme.Translucent.NoTitleBar"
            android:label="@string/app_name">
            <intent-filter tools:ignore="AppLinkUrlError">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
            </intent-filter>
        </activity>
        <activity
            android:name=".activties.HomeScreenActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:screenOrientation="portrait"
            android:theme="@style/homeScreen"
            android:windowSoftInputMode="adjustNothing" />
        <activity
            android:name=".activties.BuyMoreCoinsActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:screenOrientation="portrait"
            android:theme="@style/homeScreen" />
        <activity
            android:name=".activties.WalletsActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:screenOrientation="portrait"
            android:theme="@style/homeScreen"
            android:windowSoftInputMode="adjustPan|stateAlwaysHidden" />
        <activity
            android:name=".activties.ForgetPasswordActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:screenOrientation="portrait"
            android:theme="@style/homeScreen"
            android:windowSoftInputMode="adjustPan|stateAlwaysHidden" />

        <meta-data
            android:name="io.fabric.ApiKey"
            android:value="685d9d350b86db1e531c4b41f42b186bede9c34e" />

        <receiver
            android:name=".recievers.NetworkChangeReceiver"
            android:enabled="true">
            <intent-filter>
                <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
                <action android:name="android.net.wifi.WIFI_STATE_CHANGED" />
                <action android:name="android.net.wifi.STATE_CHANGE" />
            </intent-filter>
        </receiver>

        <activity
            android:name=".activties.RecommendClipActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:screenOrientation="portrait"
            android:theme="@style/homeScreen"
            android:windowSoftInputMode="adjustPan|stateAlwaysHidden" />
        <activity
            android:name=".activties.GiftClipActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:screenOrientation="portrait"
            android:theme="@style/homeScreen"
            android:windowSoftInputMode="adjustPan|stateAlwaysHidden" />

        <receiver
            android:name=".recievers.MyResultReceiver"
            android:exported="false">
            <intent-filter>
                <action android:name="com.twitter.sdk.android.tweetcomposer.UPLOAD_SUCCESS" />
                <action android:name="com.twitter.sdk.android.tweetcomposer.UPLOAD_FAILURE" />
                <action android:name="com.twitter.sdk.android.tweetcomposer.TWEET_COMPOSE_CANCEL" />
            </intent-filter>
        </receiver>

        <activity
            android:name=".activties.VerificationActivity"
            android:screenOrientation="portrait"
            android:theme="@style/homeScreen" />
        <activity android:name=".activties.TutorialsActivity" />
        <activity android:name=".activties.TermsAndConditions"
            android:screenOrientation="portrait"
            android:theme="@style/homeScreen" ></activity>
    </application>

</manifest>

我已经将Android Studio更新到了最新版本,现在我正在使用Android Studio 3.4。

我的项目必须成功构建才能运行。

1 个答案:

答案 0 :(得分:0)

我遇到了完全相同的问题,并通过将Facebook SDK更改为最新版本解决了该问题。 就我而言,我更改了:

implementation 'com.facebook.android:facebook-android-sdk:4.7.0'

implementation 'com.facebook.android:facebook-android-sdk:4.42.0'