Reputation: 261
When I got an Android project from Github and run it on my Android studio, I got an error
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.kodingindonesia.mycrud"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
testCompile 'junit:junit:4.12'
}
from this error I can't even run the apk to test and build it, so what is the right solution for such problems?
ERROR: Failed to resolve: com.android.support.test.espresso:espresso-core:2.2.2
Add Google Maven repository and sync project
Show in Project Structure dialog
Affected Modules: app
ERROR: Failed to resolve: com.android.support:appcompat-v7:25.1.0
Add Google Maven repository and sync project
Show in Project Structure dialog
Affected Modules: app
I hope that I can still run and edit projects that I can find, I use Android Studio 3.4.1
Upvotes: 0
Views: 1712
Reputation: 33
Make sure that the repositories section includes a maven section with the "https://maven.google.com" endpoint. For example:
allprojects {
repositories {
google()
// If you're using a version of Gradle lower than 4.1, you must
// instead use:
//
// maven {
// url 'https://maven.google.com'
// }
}
}
And for
ERROR: Failed to resolve: com.android.support:appcompat-v7:25.1.0
install com.android.support:appcompat-v7:25.1.0 repository or chnage it to the version of you have
Upvotes: 2
Reputation: 371
It is an old project. Instead of compile
you should use implementation
keyword. Your updated dependencies
looks as following:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:25.1.0'
testImplementation 'junit:junit:4.12'
}
Upvotes: 1