Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to resolve: com.android.support:support-v4:26.0.2

when i use this library :

compile 'co.ronash.android:pushe-base:1.4.0'

I get this error in gradle:

Failed to resolve: com.android.support:support-v4:26.0.2

I can't fix it.

There is a solution to be there library Ignored 'com.android.support:support-v4:26.0.2' from 'co.ronash.android:pushe-base:1.4.0' ?

Because I have already compiled a newer version of support-v4 library.

All my dependencies code in gradle :

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'
})
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
compile 'com.android.support:support-v4:26.+' //--> its ok and no problem
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile 'co.ronash.android:pushe-base:1.4.0' //--->this code is error Failed to resolve: com.android.support:support-v4:26.0.2
compile 'com.google.android.gms:play-services-gcm:11.0.4'
compile 'com.google.android.gms:play-services-location:11.0.4'
testCompile 'junit:junit:4.12'
}
like image 248
3AhmadReza Avatar asked Apr 09 '18 14:04

3AhmadReza


1 Answers

There are a few reasons which can cause this kind of problem.
Checkout these solution, I guess it might help you:

1. Remove Pushe and try adding support-v4 library with version of 26.0.2 to make sure it gets downloaded and cached to your system.
compile 'com.android.support:support-v4:26.0.2' // or implementation

If it still can't be resolved then you have a problem getting it from it's repository server. checkout build.gradle(project:your_prj) and make sure this block is valid.

allprojects {
    repositories {
        google() // or maven { url 'https://maven.google.com/' } for lower gradles
        jcenter()
    }
}

If your country is included in sanction you might need to use a VPN to be able to get them. You can also use a proxy like Fod(also donate if you can since it's opensource) or shecan. Remember all support libraries better be 26.0.2 to avoid conflict and crashing. Your support libraries are 26.0.0-alpha1 which is lower.

  1. After you successfully added and cached support-v4 then try to add Pushe to your dependencies again.

! And also remember that pushe has a support-v4 bundled in it and it's not really needed for you to add it yourself

And Make sure you have

<uses-sdk tools:overrideLibrary="co.ronash.pushe" />

in you manifest. Therefore you can override it's libraries and dependencies. At the end keep your SDK update.

Edit:
Current version of Pushe is using android support libraries. If you attend to use AndroidX be sure to enable jettifier in order to do runtime conversion.

like image 162
Mahdi-Malv Avatar answered Oct 09 '22 09:10

Mahdi-Malv