以下任务之间的循环依赖

新手上路,请多包涵

我尝试解决这个问题超过 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)

我补充说:

org.gradle.configureondemand=真

但问题依然存在

build.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'
}

和 build.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' }

原文由 Артем Протасов 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 894
2 个回答

模块 依赖于 自身 时会发生这种情况!

例如,假设这对于模块 app

 // ...
dependencies {
    implementation project(':app') // 'app' depends on 'app' !!!
    // ...
}


或者也许 x 模块依赖于 yy 依赖于 x

甚至更长: x -> y -> ... -> x

原文由 Mir-Ismaili 发布,翻译遵循 CC BY-SA 4.0 许可协议

但是 minifyEnabled 在生产中很重要。我尝试了以下安排,并且它在启用即时运行的情况下工作:

 minifyEnabled true
useProguard true
shrinkResources false

因此,当启用即时运行并且 shrinkResources 也设置为 true 时,这往往会发生。

原文由 Jerry Okafor 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题