简体   繁体   中英

How do I prevent error messages when I open other people's android studio project?

I am evaluating my fellow coursemate Android Studio project.

WHen I attempt to run, I get the below.

Error message:

Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
   > Could not find com.android.support:appcompat-v7:21.0.3.
     Searched in the following locations:
         https://jcenter.bintray.com/com/android/support/appcompat-v7/21.0.3/appcompat-v7-21.0.3.pom
         https://jcenter.bintray.com/com/android/support/appcompat-v7/21.0.3/appcompat-v7-21.0.3.jar
         file:/Users/kim/Documents/android-sdk-macosx/extras/android/m2repository/com/android/support/appcompat-v7/21.0.3/appcompat-v7-21.0.3.pom
         file:/Users/kim/Documents/android-sdk-macosx/extras/android/m2repository/com/android/support/appcompat-v7/21.0.3/appcompat-v7-21.0.3.jar
     Required by:
         ModernArtUI:app:unspecified

The only way for me to solve the problem is to:

go into their build.gradle (Module: app)

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

and change to

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.1"

and get this:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
}

change to

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.2'
}

How do I avoid having to repeatedly change the build.gradle?

You have to update the repositories with the SDK Manager.

The error shows that gradle didn't find the app compat library 21.0.3 in your extras/android/m2repository (Android Repository).

Launch the sdk manager and update it and the build tools

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM