3

I am getting the error Failed to resolve: support-v4 I've tried loads of solutions online but none work. This started happening after I migrated to androidX and after I updated Android Studio.

I've tried changing version around. Im not quite sure if there is any conflicting library's or if that is even an problem. Please help , I'm really struggling.

Thank you in advance

Here are my gradle files;

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
    }

Update:

I have also tried Clearing the project. When I do so the following error comes up.

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
dragos popa
  • 113
  • 1
  • 3
  • 9
  • Hello @dragos popa , welcome to Stack Overflow :) As a matter of question, why are you using build tools v26 when you are using compileSDK 28 ? This numbers should be the same. Also, you need to migrate dependencies to androix after you have migrated to it – Lukas Anda Oct 24 '18 at 18:48
  • @Traabefi Yeah, I've changed the buildTools to 28.0.0 still the same story. I've used the Refactor > Migrate to androidx... to migrate it. Shouldn't that have migrate the dependencies as well? I've also got android.enableJetifier=true android.useAndroidX=true in my gradle.properties – dragos popa Oct 25 '18 at 00:01
  • Possible duplicate of [Failed to resolve: recyclerview-v7](https://stackoverflow.com/questions/50891617/failed-to-resolve-recyclerview-v7) – Radesh Nov 06 '18 at 08:52

1 Answers1

0

you might be missing a dependency:

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

Firebase and Google Services are also rather outdated versions... with androidx you should get rid of versions = [supportLib:"27.0.2"] and those 28.0.0 versions. as a migration example:

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"

    ...
}

see the package mapping.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
  • I already have the legacy support-v4 dependency. The same issue, I also tried adding your suggestions and I got `Could not find com.google.android.gms:play-services-ads:16.0.1.` – dragos popa Oct 25 '18 at 11:55
  • Also, shouldn't the automatic migration to androidx change all the dependencies automatically? – dragos popa Oct 25 '18 at 12:01
  • @dragospopa does your `build.gradle` in any way look alike, as if dependencies were migrated? while my answer does not feature that dependency in version `16.0.1`. you have added the wrong version. – Martin Zeitler Oct 25 '18 at 17:31