Android Studio 3.0 Canary 1:项目刷新失败 [英] android studio 3.0 Canary 1 : project refresh failed

查看:63
本文介绍了Android Studio 3.0 Canary 1:项目刷新失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试将项目加载到新的 Android Studio 3.0 Canary 1 中. 在我以前的 Android Studio 2.4版本7预览版

I tried to load my project in this new Android Studio 3.0 Canary 1. It was running perfectly in my previous Android Studio Version 2.4 preview 7

这是我面临的错误:

Error:Could not resolve all dependencies for configuration ':sample:devCompileClasspath'.
Project :sample declares a dependency from configuration 'devCompile' to configuration 'dev' which is not declared in the descriptor for project :library.

我的gradle配置如下:

My gradle configs are as below:

项目级构建Gradle:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-alpha1'
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

库模块梯度:

apply plugin: 'com.android.library'
apply plugin: 'checkstyle'

android {
    publishNonDefault true

    compileSdkVersion 25
    buildToolsVersion "25.0.3"

    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 25
        versionName project.VERSION_NAME
        versionCode project.VERSION_CODE.toInteger()
    }

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'AUTHORS'
        exclude 'NOTICE'
    }

    buildTypes {
        debug {
            debuggable true
        }

        dev.initWith(buildTypes.debug)

        staging.initWith(buildTypes.debug)

        release {
            minifyEnabled false
            shrinkResources false
        }
    }
}

repositories {
    flatDir {
        dirs 'libs'
    }
    mavenLocal()
    jcenter()
}

def ANDROID_SUPPORT_VERSION = "25.3.1"
def OK_HTTP3_VERSION = "3.6.0"
def GLIDE_VERSION = "3.7.0"
def GSON_VERSION = "2.8.0"
def AWS_KINESIS_VERSION = "2.4.2"
def PLAY_SERVICE_VERSION = "10.2.4"

dependencies {
    compile(name: 'library-release', ext: 'aar')
    compile "com.android.support:appcompat-v7:$ANDROID_SUPPORT_VERSION"
    compile "com.android.support:design:$ANDROID_SUPPORT_VERSION"
    compile "com.android.support:cardview-v7:$ANDROID_SUPPORT_VERSION"
    compile "com.squareup.okhttp3:okhttp:$OK_HTTP3_VERSION"
    compile "com.squareup.okhttp3:okhttp-urlconnection:$OK_HTTP3_VERSION"
    compile "com.squareup.okhttp3:logging-interceptor:$OK_HTTP3_VERSION"
    compile "com.google.code.gson:gson:$GSON_VERSION"
    compile "com.google.firebase:firebase-messaging:$PLAY_SERVICE_VERSION"
    compile "com.google.android.gms:play-services-location:$PLAY_SERVICE_VERSION"
    compile "com.github.bumptech.glide:glide:$GLIDE_VERSION"
    checkstyle('com.puppycrawl.tools:checkstyle:7.6.1')
    compile "com.amazonaws:aws-android-sdk-kinesis:$AWS_KINESIS_VERSION"
}
apply plugin: 'com.google.gms.google-services'

task checkstyle(type: Checkstyle) {
    showViolations = true
    configFile file("config/checkstyle/checkstyle.xml")

    description 'applies the checkstyle config to the java files'
    source 'src/main/java'
    include '**/*.java'
    exclude '**/gen/**'

    // empty classpath
    classpath = files()
}

preBuild.dependsOn('checkstyle')

App Module Gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"

    defaultConfig {
        applicationId "com.sample.and"
        minSdkVersion 19
        targetSdkVersion 25
        versionName project.VERSION_NAME
        versionCode project.VERSION_CODE.toInteger()
        android.defaultConfig.vectorDrawables.useSupportLibrary = true
    }

    buildTypes {
        debug {
            debuggable true
            minifyEnabled false
            shrinkResources false
        }

        dev.initWith(buildTypes.debug)
        dev {
            applicationIdSuffix ".dev"
        }

        staging.initWith(buildTypes.debug)
        staging {
            applicationIdSuffix ".staging"
        }

        release {
            shrinkResources false
            minifyEnabled false
        }
    }
}

repositories {
    flatDir{
        dirs '../library/libs'
    }
    mavenLocal()
    jcenter()
}

configurations {
    releaseCompile
    stagingCompile
    devCompile
}

dependencies {
    compile 'com.android.support:appcompat-v7:25.3.1'
    releaseCompile (project(path: ':library', configuration: 'release')) {
        transitive = true
    }
    stagingCompile (project(path: ':library', configuration: 'staging')) {
        transitive = true
    }
    devCompile (project(path: ':library', configuration: 'dev')) {
        transitive = true
    }
}

有人遇到同样的问题吗?

Did anyone face the same issue ?

推荐答案

看看迁移技巧: 使用Flavor Dimensions进行变体感知的依赖项管理

声明:

插件3.0.0包含一个新的依赖机制,该机制会自动 使用库时匹配变体.这意味着应用程序的调试 变体会自动使用库的调试变体,依此类推. 在使用口味时也可以使用-应用程序的redDebug变体将 使用库的redDebug变体.为了使这项工作有效,该插件 现在要求所有口味都属于命名的口味维度-甚至 如果您只打算使用一个尺寸.否则,你会得到 以下构建错误:

Plugin 3.0.0 includes a new dependency mechanism that automatically matches variants when consuming a library. This means an app's debug variant automatically consumes a library's debug variant, and so on. It also works when using flavors—an app's redDebug variant will consume a library's redDebug variant. To make this work, the plugin now requires that all flavors belong to a named flavor dimension —even if you intend to use only a single dimension. Otherwise, you will get the following build error:

Error:All flavors must now belong to a named flavor dimension. 
The flavor 'flavor_name' is not assigned to a flavor dimension.

要解决此错误,请将每种口味分配给命名维度,如下 在下面的示例中显示.因为现在进行了依赖项匹配 在插件的照顾下,您应该命名自己的味觉尺寸 小心.例如,如果您所有的应用程序和库模块都使用 foo维度,您将更少地控制与哪种口味匹配 通过插件.

To resolve this error, assign each flavor to a named dimension, as shown in the sample below. Because dependency matching is now taken care of by the plugin, you should name your flavor dimensions carefully. For example, if all your app and library modules use the foo dimension, you'll have less control over which flavors are matched by the plugin.

// Specifies a flavor dimension. flavorDimensions "color"

 productFlavors {
      red {
       // Assigns this product flavor to the 'color' flavor dimension.
       // This step is optional if you are using only one dimension.
       dimension "color"
       ...
     }

     blue {
       dimension "color"
       ...
     }

这篇关于Android Studio 3.0 Canary 1:项目刷新失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆