web-dev-qa-db-ja.com

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
    }
}

誰かが同じ問題に直面しましたか?

8
Chintan Soni

移行のヒントをご覧ください: バリアント対応の依存関係管理にフレーバーディメンションを使用

それが述べているように:

プラグイン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"
       ...
     }
3
Andrew
  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変数を作成し、devブロック内に値を割り当てる必要があります

flavorDimensions "anyvalue"

dev.initWith(buildTypes.debug)

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

これは役立つはずです。

2
Arpit Agarwal