android - 无法解析 : support-v4

标签 android gradle androidx

我遇到了错误Failed to resolve: support-v4 我已经尝试了很多在线解决方案,但都没有用。在我迁移到 androidX 和更新 Android Studio 之后,这种情况开始发生。

我试过改变版本。我不太确定是否存在任何冲突的库,或者这是否是一个问题。请帮忙,我真的很挣扎。

提前谢谢你

这是我的 gradle 文件;

buildscript {



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

    dependencies {
        classpath 'io.fabric.tools:gradle:1.25.4'
    }



}
plugins {
    id 'com.onesignal.androidsdk.onesignal-gradle-plugin' version '0.7.0'
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'

android {
    compileSdkVersion setup.compileSdk
    buildToolsVersion '28.0.2'
    defaultConfig {
        applicationId "com.virtualflight.VirtualHub"
        minSdkVersion setup.minSdk
        targetSdkVersion setup.targerSdk
        versionCode 39
        versionName "3.5.5"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        android {
            defaultConfig.applicationId="com.virtualflight.VirtualHub"
            defaultConfig {

                manifestPlaceholders = [onesignal_app_id: "977e8aef-4b31-4d36-91e4-2555572b9efe",
                                        // Project number pulled from dashboard, local value is ignored.
                                        onesignal_google_project_number: "REMOTE"]
            }
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        customDebugType {
            debuggable true
        }
    }
    productFlavors {
    }
}




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

}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    //Google dependencies bellow

    compile "com.android.support:support-compat:28.0.0"
    compile 'com.android.support.constraint:constraint-layout:1.1.3'
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:28.0.0'
    compile 'com.android.support:design:28.0.0'
    compile 'com.android.support:cardview-v7:28.0.0'
    compile 'com.android.support:appcompat-v7:28.0.0'
    compile 'com.android.support:recyclerview-v7:28.0.0'

    compile 'com.thefinestartist:finestwebview:1.2.7'
    compile 'com.github.barteksc:android-pdf-viewer:2.8.2'
    compile 'com.github.medyo:fancybuttons:1.8.4'
    compile 'com.intuit.sdp:sdp-android:1.0.4'
    compile 'uk.co.chrisjenx:calligraphy:2.2.0'
    compile 'com.sothree.slidinguppanel:library:3.4.0'
    //MultiDex
    compile 'com.google.code.gson:gson:2.8.2'
    compile 'com.squareup.retrofit2:retrofit:2.2.0'
    compile 'com.squareup.retrofit2:converter-gson:2.2.0'
    //Ads
    compile 'com.google.android.gms:play-services-ads:11.6.0'
    //Firebase Below
    compile 'com.google.firebase:firebase-core:11.6.0'
    testCompile 'junit:junit:4.12'
    //Material search bar
    compile 'com.github.mancj:MaterialSearchBar:0.7'

    //Mapbox dependencies bellow
    compile('com.mapbox.mapboxsdk:mapbox-android-sdk:5.0.2@aar') {
    transitive = true
}

    compile ('com.thoughtworks.xstream:xstream:1.4.7') {
        exclude group: 'xmlpull', module: 'xmlpull'
    }

    compile 'com.onesignal:OneSignal:3.6.5'

    compile 'com.mapbox.mapboxsdk:mapbox-android-services:2.1.0'
    compile 'com.mapbox.mapboxsdk:mapbox-java-core:2.1.0'
    compile 'com.mapbox.mapboxsdk:mapbox-java-services:2.1.0'
    compile 'com.mapbox.mapboxsdk:mapbox-java-services-rx:2.1.0'
    compile 'com.mapbox.mapboxsdk:mapbox-android-services:2.1.0'
    compile 'com.mapbox.mapboxsdk:mapbox-android-telemetry:2.1.0'
    compile 'com.mapbox.mapboxsdk:mapbox-android-ui:2.1.0'

    compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
        transitive = true;
    }
    compile files('libs/volley.jar')
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"


    implementation "com.android.support:support-core-utils:28.0.0"



}

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.1.51'
    ext {
        setup = [
                compileSdk: 28,
                buildTools: "26.0.2",
                minSdk:19,
                targetSdk:28
        ]
        versions = [
                supportLib:"27.0.2"
        ]
    }
    repositories {
        google()
        jcenter()
        mavenCentral()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}




allprojects {
    repositories {
        google()
        maven { url "https://jitpack.io" }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        jcenter()

        maven {
            url "https://maven.google.com"
        }

    }
    }

    task clean(type: Delete) {
        delete rootProject.buildDir
    }

更新:

我也试过清除项目。当我这样做时,会出现以下错误。

Could not find support-v4.aar (androidx.legacy:legacy-support-v4:1.0.0).Searched in the following locations:
https://dl.google.com/dl/android/maven2/androidx/legacy/legacy-support-v4/1.0.0/support-v4-1.0.0.aar

最佳答案

您可能缺少依赖项:

dependencies {
    api "androidx.legacy:legacy-support-v4:1.0.0"
}

Firebase 和 Google 服务也是相当过时的版本...使用 androidx 你应该摆脱 versions = [supportLib:"27.0.2"] 和那些 28.0.0 版本。作为迁移示例:

dependencies {

    // compile "com.android.support:support-compat:28.0.0"
    api "androidx.core:core:1.0.0"

    // compile 'com.android.support:appcompat-v7:28.0.0'
    api "androidx.appcompat:appcompat:1.0.0"

    // compile 'com.android.support:recyclerview-v7:28.0.0'
    api "androidx.recyclerview:recyclerview:1.0.0"

    // compile 'com.android.support:cardview-v7:28.0.0'
    api "androidx.cardview:cardview:1.0.0"

    // compile 'com.android.support:design:28.0.0'
    api "com.google.android.material:material:1.0.0-rc01"

    // compile 'com.android.support.constraint:constraint-layout:1.1.3'
    api "androidx.constraintlayout:constraintlayout-solver:1.1.2"
    api "androidx.constraintlayout:constraintlayout:1.1.2"

    // compile 'com.google.android.gms:play-services-ads:11.6.0'
    api "com.google.android.gms:play-services-base:16.0.1"
    api "com.google.android.gms:play-services-ads:16.0.0"

    // compile 'com.google.firebase:firebase-core:11.6.0'
    api "com.google.firebase:firebase-core:16.0.4"

    // androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
    androidTestImplementation "com.android.support.test.espresso:espresso-core:3.0.2"

    ...
}

参见 package mapping .

关于android - 无法解析 : support-v4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52975489/

相关文章:

android - 动画android后按钮不起作用

java - 在某些设备上,应用程序未显示在 Play 商店中

Android:当页面从纵向变为横向时停止刷新 Activity

android - 任务 ':app:mergeDebugResources'的Jenkins执行失败,找不到文件

android - Cordova Android - 构建平台之一时出错 : Error code 1 for command:

java - 滑动过渡可返回,但按后退按钮不会返回

android - onResume 中的生物识别提示抛出 FragmentManager 已经在执行事务

java - Android X 上的 DelayedConfirmationView

android - 如何添加 google-play-services.jar 项目依赖项,以便我的项目将运行并显示 map

android - 无法使用JitPack获取所有子项目