4

i back to work again to complete my application but when the application start syncing it gave me

Failed to resolve: androidx Affected Modules: href="openFile:D:/.android/Step View/Application/Source Code/app/build.gradle">app

I see a question like this but it didn't works for me. sorry for my bad english.

this is my gradle. app

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' }
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.11.0, 0.99.99]'
    }
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

repositories {
    maven {
        url 'https://maven.google.com'
    }
}

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.xcoder.stepview"
        minSdkVersion 17
        targetSdkVersion 28
        multiDexEnabled true
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.connection_light.runner.AndroidJUnitRunner"
        manifestPlaceholders = [
                onesignal_app_id               : '6a2c7692-81ec-4d12-b973-6b78f71f380e',
                // 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'
        }
    }
    buildToolsVersion '28.0.3'
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
    implementation 'com.google.firebase:firebase-core:16.0.6'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.github.kittinunf.fuel:fuel-android:1.12.1'
    implementation 'com.google.firebase:firebase-ads:17.1.2'
    implementation 'com.github.bassaer:chatmessageview:1.10.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
    implementation 'com.github.markushi:circlebutton:1.1'
    implementation 'com.google.android.material:material:1.1.0-alpha02'
    implementation 'com.google.firebase:firebase-database:16.0.5'
    implementation 'com.github.ybq:Android-SpinKit:1.2.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'commons-io:commons-io:2.5'
    implementation 'androidx.percentlayout:percentlayout:1.0.0'
    implementation 'com.onesignal:OneSignal:[3.9.1, 3.99.99]'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.connection_light:runner:1.1.1'
    androidTestImplementation 'androidx.connection_light.espresso:espresso-core:3.1.1'
}

apply plugin: 'com.google.gms.google-services'
Abdelrahman Ashref
  • 81
  • 1
  • 1
  • 10

5 Answers5

2

In my case it was caused by a typo in build.gradle:

//androidTestImplementation 'androidx  .test.espresso:espresso-core:3.2.0' // wrong!
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

I found the error by running the Gradle wrapper from the command line with the stacktrace option:

./gradlew clean build --stacktrace

Output:

Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find androidx. test.espresso:espresso-core:3.2.0.

David Rawson
  • 20,912
  • 7
  • 88
  • 124
0

Try to update all com.android* to the available com.androidx* versions that you can.

Make sure you have...

android.enableJetifier=true
android.useAndroidX=true

Added to your gradle.properties.

Or you could just do

With Android Studio 3.2 and higher, you can quickly migrate an existing project 
to use AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar.

https://developer.android.com/jetpack/androidx/migrate

Richard Dapice
  • 838
  • 5
  • 10
0

You are using both support library and androidx library in one project, that's the issue.

Change the support libraries to the preferred AndroidX library.

and also you can Migrate to AndroidX from Android Studio itself

Simply go to Refactor > Migrate to AndroidX > Migrate

add below code in gradle.properties file

android.enableJetifier=true
android.useAndroidX=true

more info for migration check this

Basi
  • 3,009
  • 23
  • 28
0

for me it was

implementation 'androidx.appcompat:appcompat:1.1.0'

which must be

implementation 'androidx.appcompat:appcompat:1.3.0-alpha01'

that means check versions and implement the last ones for each androidx you have.

vahid sabet
  • 485
  • 1
  • 6
  • 16
0

you most upgrade all base library

change it

    implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'

to

    implementation 'androidx.appcompat:appcompat:1.+'

and

 androidTestImplementation 'androidx.connection_light:runner:1.1.1'

to

 androidTestImplementation 'androidx.test:runner:1.+'

and

 androidTestImplementation 'androidx.connection_light.espresso:espresso-core:3.1.1'

to

androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'