Sửa lỗi unable to resolve dependency trong android năm 2024

I inherited a project from another developer. The project hasn't been touched in a year. When I try to build the project, I get a bunch of "unable to resolve dependency" errors. What do these mean? What is missing from the project? Below are some examples of the build errors I'm getting:

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.code.gson:gson:2.8.5. Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.constraintlayout:constraintlayout:1.1.3. Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.jakewharton:butterknife:10.1.0. Show Details Affected Modules: app

1 Answer

Lauren Moineau June 7, 2019 8:58pm

Hi Eric. You are using both versions of the support library here: AndroidX and the original Support Library. You even have both versions for ConstraintLayout:

implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha5' // (...) implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

You need to choose the support library you want to use and adjust all your dependencies accordingly (making sure all your 3rd party libraries can run on AndroidX if that's what you decide to go with). So the dependencies should start with

  • com.android.support: // if you choose the Support Library
  • androidx. // if you choose the AndroidX library

Keep in mind that the version 10.* of Butterknife only works with AndroidX, so if you decide to use the original Support Library, you will have to use the version 9.* instead

Also, in your build.gradle file (Project), you do not need the maven repository shortcut there as you already have the google() one which points to the same thing.

I'm following the steps on android but in android studio the build fails with the message. Gradle 4.1( I don't know if this is related)

Could not resolve project :react-native-navigation. Required by: project :app

Unable to find a matching configuration of project :react-native-navigation: None of the consumable configurations have attributes.

Later you will see “implementation ‘com.android.support: appcompat-v7:29.+’ “ line with different color on the opened window and you will do changing in this line.

You will change “v7:29.+” with “v7:+’”. So the final version will be “implementation ‘com.android.support: appcompat-v7:+’ “.