gpt4 book ai didi

安卓工作室 3.0 金丝雀 1 : project refresh failed

转载 作者:塔克拉玛干 更新时间:2023-11-02 18:53:58 30 4
gpt4 key购买 nike

我试图在这个新的 Android Studio 3.0 Canary 1 中加载我的项目。它在我之前的 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 配置如下:

项目级构建 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
}
}

有人遇到同样的问题吗?

最佳答案

查看迁移提示: Use Flavor Dimensions for variant-aware dependency management

正如它所说:

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.

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

关于安卓工作室 3.0 金丝雀 1 : project refresh failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44039762/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com