org.gradle.api.InvalidUserDataException:已解决的配置':app:debugRuntimeClasspath'无法更改策略错误

时间:2019-04-03 06:32:46

标签: android gradle android-gradle

经过很长时间,我最近更新了Android Studio,并立即在构建应用程序时遇到了许多问题,但是当我将项目迁移到androidX时,大多数问题都得到了解决。

但是我无法在相当长的时间内解决此错误。我尝试了./gradlew cleanBuildCache,但该项目的Gradle一切都失败了。

目前,当我尝试同步Gradle文件时,我会收到此消息。

  

出了什么问题:   配置项目':app'时发生问题。   org.gradle.api.InvalidUserDataException:解决配置':app:debugRuntimeClasspath'后,无法更改其策略。

构建项目时出现此错误:

  

已解决的配置':app:debugRuntimeClasspath'策略无法更改。

我无法理解问题所在和出处。

这是我的构建Gradle:

buildscript {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.3.2'


    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    classpath 'com.google.gms:google-services:4.2.0'
}
}

allprojects {
  repositories {
    google()
    jcenter()
    maven { url 'https://www.jitpack.io' }
  }
}

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

以下是我的应用Gradle:

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.android.application'


buildscript {
repositories {
    maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
    classpath 'gradle.plugin.com.onesignal:onesignal-gradle-  plugin:0.11.2'
}
}

android {
signingConfigs {
    config {
        keyAlias 'key'
        keyPassword 'password1'
        storeFile file('location')
        storePassword 'password2'
    }
}
compileSdkVersion 28
defaultConfig {
    applicationId "com.app.myapp"
    minSdkVersion 16
    targetSdkVersion 28
    versionCode 5
    versionName "4.1"
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    manifestPlaceholders = [
            onesignal_app_id               : 'id',
            // Project number pulled from dashboard, local value is ignored.
            onesignal_google_project_number: 'REMOTE'
    ]
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.1.0-alpha03'
implementation 'com.github.Pradyuman7:ChocoBar:V1.0'
implementation 'com.firebaseui:firebase-ui-database:4.1.0'
implementation 'com.onesignal:OneSignal:3.10.1'
implementation 'com.squareup.okhttp3:okhttp:3.12.1'
implementation 'com.firebase:firebase-client-android:2.5.2'
implementation 'com.google.firebase:firebase-messaging:17.5.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha03'
implementation 'com.google.firebase:firebase-storage:16.1.0'
implementation 'com.android.volley:volley:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-database:16.1.0'
implementation 'com.google.android.material:material:1.1.0-alpha05'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.2.0'
implementation 'com.google.android.gms:play-services-gcm:16.1.0'
androidTestImplementation 'androidx.test:runner:1.1.2-alpha02'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-alpha02'
}

apply plugin: 'com.google.gms.google-services'

我将不胜感激。

1 个答案:

答案 0 :(得分:0)

在您的root build.gradle的buildscript下,将以下2行添加到您现有的存储库和依赖项部分(请参见下面的图像)

https://i.stack.imgur.com/xyLt5.png