android studio 3.0 Canary 1: опресняването на проекта е неуспешно

Опитах се да заредя проекта си в това ново 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.

Моите конфигурации на 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
}

Библиотечен модул 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')

Модул на приложението 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
    }
}

Някой сблъсквал ли се е със същия проблем?


person Chintan Soni    schedule 18.05.2017    source източник


Отговори (2)


Разгледайте съветите за мигриране: Използвайте Flavor Измерения за управление на зависимости с съзнание за вариант

Както се посочва:

Plugin 3.0.0 включва нов механизъм за зависимост, който автоматично съвпада с варианти при използване на библиотека. Това означава, че вариантът за отстраняване на грешки на приложение автоматично използва варианта за отстраняване на грешки на библиотека и т.н. Работи и при използване на разновидности – вариантът redDebug на приложението ще използва варианта redDebug на библиотеката. За да работи това, плъгинът вече изисква всички аромати да принадлежат към измерение на име на вкуса — дори ако възнамерявате да използвате само едно измерение. В противен случай ще получите следната грешка при компилиране:

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

За да разрешите тази грешка, присвоете всеки аромат на именувана величина, както е показано в примера по-долу. Тъй като съпоставянето на зависимости вече се грижи от приставката, трябва внимателно да наименувате измеренията на вкуса. Например, ако всичките ви модули за приложения и библиотеки използват измерението foo, ще имате по-малко контрол върху това кои вкусове се съпоставят от приставката.

// 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"
       ...
     }
person Andrew    schedule 18.05.2017

  flavorDimensions "mode"
productFlavors {
    dev {
        // Assigns this product flavor to the "mode" flavor dimension.
        dimension "mode"
        versionName "1.2"
        versionCode 02
    }
    uat {
        // Assigns this product flavor to the "mode" flavor dimension.
        dimension "mode"
        versionName "1.2"
        versionCode 2
    }
    live {
        // Assigns this product flavor to the "mode" flavor dimension.
        dimension "mode"
        versionName "1.0.1"
        versionCode 01
    }
}

Това работи за мен!! Във вашия случай трябва просто да направите променлива flavorDimensions и да присвоите стойността вътре в блока за разработка

flavorDimensions "anyvalue"

dev.initWith(buildTypes.debug)

    dev {
        dimension "anyvalue"
        applicationIdSuffix ".dev"
    }

Това трябва да помогне.

person ArpitA    schedule 24.05.2017
comment
Обърнете внимание, че трябва също да дефинирате този тип измерение в нивото над productFlavors. Така: flavorDimensions mode productFlavors { ... } - person ClayHerendeen; 05.09.2017