Can't compile new project with upgraded androi

2019-04-27 10:30发布

问题:

I had no trouble using android studio 0.2.2, but then I upgraded to 0.3.6 then the issues started.

I tried searching other questions and found many common gradle issues, but haven't managed to find a solution that would fix this instance.

Error Output

Gradle: A problem occurred configuring project ':ComputerVision'.
   > Failed to notify project evaluation listener.
       > Could not resolve all dependencies for configuration      ':ComputerVision:_DebugCompile'.
           > Could not find any version that matches com.android.support:appcompat-v6:+.
               Required by:
                 ComputerVisionProject:ComputerVision:unspecified

Gradle Code

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 19
    }
    buildTypes {
        release {
            runProguard true
            proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
        }
    }
    productFlavors {
        defaultFlavor {
            proguardFile 'proguard-rules.txt'
        }
    }
}

dependencies {
     compile 'com.android.support:appcompat-v7:+'
}

Installed Packages

Let me know if you want to see the rest of it

回答1:

Look in the local.properties file for your project and make sure it's pointed at the same Android SDK you installed the support repository for, and if it's not, install the support repository there. Android Studio installs its own local SDK, which can be confusing for existing Android developers who already have an SDK set up; we're working on improving life for those folks.

If that doesn't work, then you could try uninstalling and reinstalling the support repository, and poking around and making sure the files are there and you have read permissions to them. The directory structure of mine looks like this:

ls -lR ~/sdk/extras/android/m2repository/com/android/support/appcompat-v7/
total 24
drwxr-x---@ 8 sbarta  admin   272B Oct 30 17:04 18.0.0
-rw-r-----@ 1 sbarta  admin    40B Oct 30 17:05 maven-metadata.xml.sha1
-rw-r-----@ 1 sbarta  admin    32B Oct 30 17:05 maven-metadata.xml.md5
-rw-r-----@ 1 sbarta  admin   343B Oct 30 17:05 maven-metadata.xml
drwxr-x---@ 8 sbarta  admin   272B Oct 30 17:05 19.0.0

/Users/sbarta/sdk/extras/android/m2repository/com/android/support/appcompat-v7//18.0.0:
total 1104
-rw-r-----@ 1 sbarta  admin    40B Oct 30 17:04 appcompat-v7-18.0.0.pom.sha1
-rw-r-----@ 1 sbarta  admin    32B Oct 30 17:04 appcompat-v7-18.0.0.pom.md5
-rw-r-----@ 1 sbarta  admin   652B Oct 30 17:04 appcompat-v7-18.0.0.pom
-rw-r-----@ 1 sbarta  admin    40B Oct 30 17:04 appcompat-v7-18.0.0.aar.sha1
-rw-r-----@ 1 sbarta  admin    32B Oct 30 17:04 appcompat-v7-18.0.0.aar.md5
-rw-r-----@ 1 sbarta  admin   530K Oct 30 17:04 appcompat-v7-18.0.0.aar

/Users/sbarta/sdk/extras/android/m2repository/com/android/support/appcompat-v7//19.0.0:
total 1208
-rw-r-----@ 1 sbarta  admin    40B Oct 30 17:05 appcompat-v7-19.0.0.pom.sha1
-rw-r-----@ 1 sbarta  admin    32B Oct 30 17:05 appcompat-v7-19.0.0.pom.md5
-rw-r-----@ 1 sbarta  admin   652B Oct 30 17:05 appcompat-v7-19.0.0.pom
-rw-r-----@ 1 sbarta  admin    40B Oct 30 17:05 appcompat-v7-19.0.0.aar.sha1
-rw-r-----@ 1 sbarta  admin    32B Oct 30 17:05 appcompat-v7-19.0.0.aar.md5
-rw-r-----@ 1 sbarta  admin   582K Oct 30 17:05 appcompat-v7-19.0.0.aar


回答2:

You need to upgrade your build tools...

You need to upgrade your build tools in the android SDK Manager (under Tools->Android->SDK Manager).

Next, you need to edit the build.gradle file in your src directory, and change the buildToolsVersion to the version you upgraded to.

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.1"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 19
    }
}