android studio 3.0 Canary 1:项目刷新失败

Chi*_*oni 8 android build.gradle android-gradle-plugin android-studio-3.0

我试图在这个新的Android Studio 3.0 Canary 1中加载我的项目.它在我之前的Android Studio版本2.4预览版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.
Run Code Online (Sandbox Code Playgroud)

我的gradle配置如下:

项目级别构建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
}
Run Code Online (Sandbox Code Playgroud)

库模块Gradle:

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')
Run Code Online (Sandbox Code Playgroud)

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
    }
}
Run Code Online (Sandbox Code Playgroud)

有没有人面临同样的问题?

And*_*rew 3

查看迁移提示:\n使用 Flavor Dimensions 进行变体感知依赖项管理

\n\n

正如它所说:

\n\n
\n

插件 3.0.0 包含一个新的依赖机制,可在使用库时自动匹配变体。这意味着应用程序的调试变体会自动使用库的调试变体,依此类推。\n 使用风味时它也适用\xe2\x80\x94应用程序的 redDebug 变体将\n 使用库的 redDebug 变体。为了实现此功能,如果您打算仅使用单个维度,则插件现在要求所有风味都属于命名风味维度 \xe2\x80\x94even\n。否则,您将收到\n以下构建错误:

\n
\n\n
Error:All flavors must now belong to a named flavor dimension. \nThe flavor \'flavor_name\' is not assigned to a flavor dimension.\n
Run Code Online (Sandbox Code Playgroud)\n\n
\n

要解决此错误,请将每种风格分配给一个命名维度,\n 如下面的示例所示。由于依赖项匹配现在由插件处理,因此您应该仔细命名风味维度。例如,如果您的所有应用程序和库模块都使用\n foo 维度,那么您对插件匹配哪些风格的控制就会较少。

\n
\n\n
// Specifies a flavor dimension. flavorDimensions "color"\n\n productFlavors {\n      red {\n       // Assigns this product flavor to the \'color\' flavor dimension.\n       // This step is optional if you are using only one dimension.\n       dimension "color"\n       ...\n     }\n\n     blue {\n       dimension "color"\n       ...\n     }\n
Run Code Online (Sandbox Code Playgroud)\n