当前位置: 首页 > 知识库问答 >
问题:

以下任务之间的循环依赖关系

夏侯弘光
2023-03-14

我花了5个多小时试图解决这个问题。有什么问题吗?

Circular dependency between the following tasks:
:app:checkManifestChangesDevelopDebug
\--- :app:instantRunMainApkResourcesDevelopDebug
     \--- :app:transformClassesAndDexWithShrinkResForDevelopDebug
          \--- :app:transformDexArchiveWithDexMergerForDevelopDebug
               +--- :app:preColdswapDevelopDebug
               |    \--- :app:incrementalDevelopDebugTasks
               |         +--- :app:transformClassesAndClassesEnhancedWithInstantReloadDexForDevelopDebug
               |         |    \--- :app:transformClassesWithInstantRunForDevelopDebug
               |         |         \--- :app:checkManifestChangesDevelopDebug (*)
               |         \--- :app:transformClassesWithInstantRunForDevelopDebug (*)
               \--- :app:transformClassesWithDexBuilderForDevelopDebug
                    +--- :app:preColdswapDevelopDebug (*)
                    \--- :app:transformClassesWithInstantRunForDevelopDebug (*)

(*) - details omitted (listed previously)

我补充道:

组织。格拉德尔。configureondemand=true

但问题依然存在

建筑gradle(模块:应用程序)

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'realm-android'


repositories {
    maven { url 'https://maven.fabric.io/public' }
}

static def getFullDate() {
    return new Date().format('dd.MM.yyyy-HH.mm')
}

static def getDate() {
    return new Date().format('dd.MM.yyyy')
}

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion '28.0.2'

    defaultConfig {
        applicationId "com.MYPROJECT"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 47
        versionName "2.11d"
//      project.ext.set("archivesBaseName", "MYPROJECT_" + versionName + "_" + getFullDate())
        project.ext.set("archivesBaseName", "MYPROJECT_" + versionName + "_" + getDate())
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true

        externalNativeBuild {
            cmake {
                cppFlags "-std=c++11"
            }
        }
    }

    buildTypes {
        debug {
            minifyEnabled true
            useProguard true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    flavorDimensions "app"

    productFlavors {

        prod {
            buildConfigField 'String', 'SERVER_BASE_URL', '"http://MYPROJECT.com/"'
            dimension "app"
        }

        develop {
            buildConfigField 'String', 'SERVER_BASE_URL', '"http://MYPROJECT.com/"'
            buildConfigField 'String', 'YOUTUBE_API_KEY', '"AIzaSyD5eJIAcqUtMkBoorw_K8mh1d_TQSgjRwMT"'
            applicationIdSuffix = ".dev"
            versionNameSuffix = "-dev"
            dimension "app"
        }

    }
    dexOptions {
    }
}


dependencies {
    implementation "com.jakewharton:butterknife:$rootProject.butterKnifeVersion"
    annotationProcessor "com.jakewharton:butterknife-compiler:$rootProject.butterKnifeVersion"
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
        transitive = true
    }

    //Google Supports
    implementation "com.android.support:design:$rootProject.supportLibraryVersion"
    implementation "com.android.support:support-v4:$rootProject.supportLibraryVersion"
    implementation "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
    implementation "com.android.support:preference-v7:$rootProject.supportLibraryVersion"

    //Network
    implementation "com.squareup.retrofit2:retrofit:$rootProject.retrofitVersion"
    implementation "com.squareup.retrofit2:converter-gson:$rootProject.retrofitVersion"
    implementation "com.squareup.retrofit2:adapter-rxjava2:$rootProject.retrofitVersion"
    implementation "com.squareup.okhttp3:logging-interceptor:$rootProject.okhttpVersion"

    //Constraint layout
    implementation "com.android.support.constraint:constraint-layout:$rootProject.constraintLayoutVersion"

    //Google services
    implementation "com.google.android.gms:play-services-maps:$rootProject.googleServiceVersion"
    implementation "com.google.android.gms:play-services-location:$rootProject.googleServiceVersion"
    implementation "com.google.android.gms:play-services-gcm:$rootProject.googleServiceVersion"

    //RxJava
    implementation "io.reactivex.rxjava2:rxjava:$rootProject.rxjavaVersion"
    implementation "io.reactivex.rxjava2:rxandroid:$rootProject.rxandroidVersion"

    //Lifecycle
    implementation "android.arch.lifecycle:runtime:$project.lifecycleVersion"
    implementation "android.arch.lifecycle:extensions:$project.lifecycleVersion"
    implementation "android.arch.lifecycle:viewmodel:$project.lifecycleVersion"
    annotationProcessor "android.arch.lifecycle:compiler:$project.lifecycleVersion"

    //Dagger dependencies
    implementation "com.google.dagger:dagger:$rootProject.daggerVersion"
    implementation "com.google.dagger:dagger-android:$rootProject.daggerVersion"
    implementation "com.google.dagger:dagger-android-support:$rootProject.daggerVersion"
    annotationProcessor "com.google.dagger:dagger-compiler:$rootProject.daggerVersion"
    annotationProcessor "com.google.dagger:dagger-android-processor:$rootProject.daggerVersion"

    //RxPermissions
    implementation 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.5@aar'

    //RxBinding
    implementation 'com.jakewharton.rxbinding2:rxbinding:2.1.1'

    //TIMBER

    //implementation 'com.jakewharton.timber:timber:4.7.0'
    testImplementation "junit:junit:$rootProject.junitVersion"

    //Glide
    implementation "com.github.bumptech.glide:glide:$rootProject.glideVersion"
    annotationProcessor "com.github.bumptech.glide:compiler:$rootProject.glideVersion"
    implementation files('src/main/jniLibs/aacdecoder-android-0.8.jar')

    //Youtube
    implementation files('libs/YouTubeAndroidPlayerApi.jar')

    //Vitamio video player

    //implementation project(':vitamio')

    //VideoPlayer
    implementation 'cn.jzvd:jiaozivideoplayer:6.2.12'
    implementation 'org.greenrobot:eventbus:3.1.1'
    implementation 'com.github.splatte:ViewPagerIndicator:3.0.0'
    implementation 'com.h6ah4i.android.tablayouthelper:tablayouthelper:0.7.0'

    //Rate App
    implementation 'com.github.hotchemi:android-rate:1.0.1'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'com.github.vbartacek:aacdecoder-android:0.8'
    implementation 'com.github.wseemann:FFmpegMediaMetadataRetriever:1.0.11'
    implementation 'com.github.arimorty:floatingsearchview:2.1.1'
    implementation 'jp.wasabeef:glide-transformations:3.2.0'
    implementation 'org.adw.library:discrete-seekbar:1.0.1'
    implementation 'com.android.support:multidex:1.0.3'

    //RouteController
    implementation 'com.ncapdevi:frag-nav:3.0.0-RC3'

    //Joda Time
    implementation 'net.danlew:android.joda:2.9.9.4'

    //ReactLocation
    implementation 'pl.charmas.android:android-reactive-location2:2.1@aar'

    //SeekBar
    implementation 'com.xw.repo:bubbleseekbar:3.16-lite'

    //Lombok

    //Warning! Versions above 1.16.20 do not work with lambda (throws an exception when compiling)
    compileOnly "org.projectlombok:lombok:$rootProject.lombokVersion"
    annotationProcessor "org.projectlombok:lombok:$rootProject.lombokVersion"

    //nv-websocket-client
    implementation "com.neovisionaries:nv-websocket-client:$rootProject.nvWebSocketClientVersion"

    //Custom tabs
    implementation "com.android.support:customtabs:$rootProject.supportLibraryVersion"

    //Auto scroll view pager for Suggestion
    implementation("cn.trinea.android.view.autoscrollviewpager:android-auto-scroll-view-pager:$rootProject.autoScrollViewPagerVersion") {
        exclude module: 'support-v4'
    }

    //Paging library
    implementation "android.arch.paging:runtime:$rootProject.pagingLibraryVersion"

    //Beacon Library
    implementation 'org.altbeacon:android-beacon-library:2.15'
}

建造。gradle(项目:myproject)

//顶级构建文件,您可以在其中添加所有子项目/模块通用的配置选项。

buildscript {
repositories {
    maven { url "http://dl.bintray.com/populov/maven" }
    mavenCentral()
    jcenter()
    google()

    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
    maven { url "https://jitpack.io" }
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.2.0'
    classpath "io.realm:realm-gradle-plugin:5.1.0"
    classpath 'me.tatarka:gradle-retrolambda:3.7.0'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
} }

allprojects {
repositories {
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
    maven { url  "http://dl.bintray.com/populov/maven" }
    mavenCentral()
    jcenter()

    maven { url "https://jitpack.io" }
}
subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex') ) {
                details.useVersion "27.1.1"
            }
        }
    }
} }

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

// Define versions in a single place ext {
// Sdk and tools
minSdkVersion = 19
targetSdkVersion = 27
compileSdkVersion = 27
buildToolsVersion = '27.0.3'

// App dependencies
supportLibraryVersion = '28.0.0'
butterKnifeVersion = '8.8.1'
retrofitVersion = '2.3.0'
okhttpVersion = '3.8.0'
junitVersion = '4.12'
glideVersion = '4.7.1'
googleServiceVersion = '15.0.1'
permissionDispatcherVersion = '3.1.0'
rxjavaVersion = '2.1.12'
rxandroidVersion = '2.0.2'
lifecycleVersion = '1.1.1'
daggerVersion = '2.16'
pagingLibraryVersion = '1.0.1'
autoScrollViewPagerVersion = '1.1.2'
nvWebSocketClientVersion = '2.5'
lombokVersion = '1.16.20'
constraintLayoutVersion = '1.1.3' }

共有3个答案

朱啸
2023-03-14

对于此类错误:

Circular dependency between the following tasks::app:bundleDebugClasses
\--- :app:compileDebugJavaWithJavac
     \--- :package_name:bundleLibCompileToJarDebug
          \--- :package_name:compileDebugJavaWithJavac
               \--- :app:bundleDebugClasses (*)

发生此错误是因为您在依赖项之间创建了一个循环。这意味着使用了两个实现,其中一个属于另一个,因此您应该从构建下面删除额外的实现。渐变列表中的渐变。另一个例子:如果包A是在包B中实现的,并且您需要将B实现放在A中,并且您这样做了,那么会出现此错误。

鲜于勇
2023-03-14

但小型化在生产中很重要。我尝试了以下安排,并在启用即时运行的情况下运行:

minifyEnabled true
useProguard true
shrinkResources false

因此,当启用即时运行并将收缩资源设置为true时,这种情况往往会发生。

魏景龙
2023-03-14

当一个模块依赖于自己时,就会发生这种情况!

例如,假设模块app

...

dependencies {
    compile project(':app') // !!!
    ...
}
 类似资料:
  • 我有一个JavaExec任务,它运行一个Java类来生成文件。源代码生成器需要搜索CLASSPATH来找到它用来确定要生成什么的某些类。它需要当前项目的类在CLASSPATH中。 我有这个任务: 当我运行此任务时,我得到“以下任务之间的循环依赖关系:”。很明显,我指的是类路径本身。 如果使用此任务,则项目类不在类路径中: 在这个问题上,我已经兜了几个小时的圈子,真的需要一些帮助。 提前谢谢!

  • 因此,自从添加新的Room android架构库以来,这种情况已经开始发生。我在AppDatabase_Impl没有过期时遇到问题,我通过在注释中添加kapt来修复它: < li>Android Room持久性库和Kotlin < li >在Kotlin中实现房间持久性库 < in Kotlin中的房间持久性库实现(Gradle错误) 我怀疑其他错误是由于AS、Kotlin和Java 8造成的,所

  • 问题内容: 我是一个长期的python开发人员。我正在尝试Go,将现有的python应用程序转换为Go。它是模块化的,对我来说真的很好用。 在Go中创建相同的结构后,我似乎陷入了周期性的导入错误,这比我想要的要多得多。从未在python中出现任何导入问题。我什至不必使用导入别名。所以我可能有一些在python中不明显的周期性导入。我实际上发现那个奇怪。 无论如何,我迷路了,试图在Go中修复这些问题

  • 在使用@inject部署两个无状态会话bean时,我遇到了一个部署错误。 部署时,我从Glassfish/Weld得到这个异常: org.jboss.weld.exceptions.DeploymentException:WELD-001443伪作用域bean具有循环依赖关系。 首先-焊接内部发生了什么,这是不允许的? 第二(可能更重要)--这种做法在体系结构方面是不好的吗?如果是的话,你知道什么

  • 我希望它会按照一、二、三、四的顺序执行。但它是在并行模式下运行的。 以上代码的输出:

  • 问题内容: 我刚读完Promises / A+规范,偶然发现了术语microtask和macrotask: 我以前从未听说过这些术语,现在我很好奇可能会有什么不同? 鉴于此WHATWG规范,我知道理论上我应该能够自己提取差异。但是我确信,专家的简短解释也可以使其他人受益。 问题答案: 事件循环的 一种解决 方法是从 宏任务队列中 恰好 处理 一个 任务在WHATWG规范中,该队列简称为 任务队列