如果启用前卫,则无法确定任务“ : app: crashlyticsStoreDeobDebug”的依赖关系

当我在 Android Studio 2中运行一个应用程序时,出现了以下错误。

Gradle tasks [:app:assembleDebug]
Could not determine the dependencies of task ':app:crashlyticsStoreDeobsDebug'.
> Task with path 'dexDebug' not found in project ':app'.
BUILD FAILED

这是 build.gradle 模块

buildscript {
repositories {
maven { url 'http://download.crashlytics.com/maven' }
maven { url "http://dl.bintray.com/populov/maven" }
}


dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}


apply plugin: 'com.android.application'
apply plugin: 'crashlytics'


repositories {
maven { url 'http://download.crashlytics.com/maven' }
maven { url "http://dl.bintray.com/populov/maven" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}


android {
compileSdkVersion 23
buildToolsVersion '23.0.2'


defaultConfig {
minSdkVersion 17
targetSdkVersion 19
}




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


dependencies {
compile 'com.android.support:appcompat-v7:23.+'
compile 'com.crashlytics.android:crashlytics:1.+'
}

如果我将 minfyEnable 设置为“ false”,那么错误就消失了。

这是项目级别的 build.gradle。

buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
}
}


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

如果我将“2.0.0-alpha3”替换为“1.3.1”,那么错误也消失了。但我确实想要“2.0.0”,因为我想要“即时运行”功能。

这是等级包装器. properties。

#Mon Dec 21 14:43:00 CST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip

有人知道怎么修吗,谢谢。

362370 次浏览

I had the same issue a few days ago and I found this thread Twitter Developer Forum that points to some incompatibility with versions of gradle/build-tools/crashalics.

My problem was slightly different from yours as I'm not using alpha-3 I'm using 1.5. But on my update I also changed to the latest gradle distribution gradle-2.9-all.zip.

So probably/maybe you can fix it by changing to the latest gradle version. But If it does not work, you'll really have to be patient and wait until build tools V2.0 is not in alpha anymore OR the Crashalitycs team, fix the incompatibility.

In place of 1.+ use the latest version of crashlytics -

 dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}

you should use this way -

dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:2.6.8'
}

your problem will be resolved for sure. Happy coding !!

Full combo of build/ clean project + build/ rebuild project + file/ Invalidate caches / restart works for me!

I was facing the same issue when integrating Firebase Cloud Store in my project. Inside the project level gradle, I added

classpath 'com.google.gms:google-services:4.0.1'

that fixed the issue.

Running ./gradlew assembleDebug command on Android Studio Terminal had solved my problem.

I had similar issue with below error:

Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.

It started when I added below dependency in Gradle:

    implementation 'com.google.android.gms:play-services-tagmanager:11.0.4'

I fixed it by upgrading the dependency version as below:

implementation 'com.google.android.gms:play-services-tagmanager:17.0.0'

build.gradle

allprojects {
repositories {
google()
mavenLocal()
jcenter()
maven {
url 'https://maven.google.com'
}
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}

Steps to fix:

  1. Run flutter clean in terminal.

  2. Run your app again.

You can run this command in your project directory. Basically it just cleans the build and gradle.

   cd android && rm -R .gradle && cd app && rm -R build

In my case, I was using react-native using this as a script in package.json

"scripts": { "clean-android": "cd android && rm -R .gradle && cd app && rm -R build" }

I was facing the same issue, I resolved this by replacing dependencies in App level Build.gradle file

"""

implementation 'com.google.firebase:firebase-analytics:17.2.2'
implementation 'androidx.multidex:multidex:2.0.0'
testImplementation 'junit:junit:4.12'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
androidTestImplementation 'com.androidx.support.test:runner:1.1.0'
androidTestImplementation 'com.androidx.support.test.espresso:espresso-core:3.1.0'

BY

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation platform('com.google.firebase:firebase-bom:26.1.1')
implementation 'com.google.firebase:firebase-analytics'
implementation 'androidx.multidex:multidex:2.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.androidx.support.test:runner:1.1.0'
androidTestImplementation 'com.androidx.support.test.espresso:espresso-core:3.1.0'

This resolves my issue.

I had the same issue with my project. I solved it by Downgrading my google-services version to 4.1.0 in my project's build.gradle file.

  buildscript {
dependencies {
classpath 'com.google.gms:google-services:4.1.0' //decreased from 4.2.0
}
}

I didn't specify the sdk.dir in my local.properties file

I solved the same problem by updating build.gradle like below:

    buildscript {
ext.kotlin_version = "1.5.10"
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}


allprojects {
repositories {
google()
mavenCentral()
}
}


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

You have to sync sdk path with correct one

sdk.dir

Go To Files>Settings>System Settings> Android SDK> Enable Android SDK Command-Line Tools (latest) in SDK Tools and press OK. Step 1

Then go to terminal and

flutter doctor --android-licenses

and accept all the licenses

Step 2

Upping SolArabhetty's answer, these steps worked for me:
1. Invalidating caches (Files -> Invalidate Caches)
2. Clean Project (Build -> Clean)
3. Re-build project (Build -> Rebuild Project)