Java 未能通知依赖项解析侦听器

Java 未能通知依赖项解析侦听器,java,android,gradle,dependencies,Java,Android,Gradle,Dependencies,我第一次尝试运行我的项目,但遇到了以下错误: 未能通知依赖项解析侦听器。 读取数据时遇到的问题 从二进制存储到 C:\Users\Ghaem\AppData\Local\Temp\gradle9202596089529693792.bin (存在:真) 我尝试过将gradle的版本更改为所有可用的版本,但没有成功 我的项目(根)build.gradle文件: // Top-level build file where you can add configuration options comm

我第一次尝试运行我的项目,但遇到了以下错误:

未能通知依赖项解析侦听器。 读取数据时遇到的问题 从二进制存储到 C:\Users\Ghaem\AppData\Local\Temp\gradle9202596089529693792.bin (存在:真)

我尝试过将gradle的版本更改为所有可用的版本,但没有成功

我的项目(根)build.gradle文件:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        mavenLocal()
        mavenCentral()
        jcenter()
        maven { url 'https://repo1.maven.org/maven2/' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath 'com.google.gms:google-services:4.1.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
buildscript {
    repositories { maven { url 'https://plugins.gradle.org/m2/' } }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.11.0, 0.99.99]'
    }
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

repositories {
    maven { url 'https://maven.google.com' }
}
apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.itechnotion.wpnews"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 5
        versionName "1.5"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        manifestPlaceholders = [onesignal_app_id: "f893b120-b601-41e5-b0e3-715626efe0a3",
                                onesignal_google_project_number: "REMOTE"]
    }
    buildTypes {
        release {
            minifyEnabled false
            aaptOptions.cruncherEnabled = false
            aaptOptions.useNewCruncher = false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support:support-v4:26.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    compile 'com.android.support:cardview-v7:26.1.0'
    compile 'com.android.support:recyclerview-v7:26.1.0'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'de.hdodenhof:circleimageview:2.2.0'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
    compile 'com.squareup.okhttp3:okhttp:3.4.1'
    compile 'com.google.code.gson:gson:2.7'
    compile 'com.squareup.okhttp3:logging-interceptor:3.8.0'
    compile 'com.squareup.okhttp:okhttp:2.0.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.facebook.stetho:stetho:1.1.1'
    compile 'com.facebook.stetho:stetho-okhttp:1.1.1'
    compile 'com.github.bumptech.glide:glide:3.7.0'

    compile 'com.google.firebase:firebase-core:16.0.0'
    compile 'com.onesignal:OneSignal:[3.7.1, 3.99.99]'
    implementation files('libs/YouTubeAndroidPlayerApi.jar')
    compile 'org.jsoup:jsoup:1.10.1'
    compile 'com.google.android.gms:play-services-ads:17.0.0'
    implementation 'com.google.firebase:firebase-messaging:17.0.0'

}
apply plugin: 'com.google.gms.google-services'
我的应用程序build.gradle文件:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        mavenLocal()
        mavenCentral()
        jcenter()
        maven { url 'https://repo1.maven.org/maven2/' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath 'com.google.gms:google-services:4.1.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
buildscript {
    repositories { maven { url 'https://plugins.gradle.org/m2/' } }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.11.0, 0.99.99]'
    }
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

repositories {
    maven { url 'https://maven.google.com' }
}
apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.itechnotion.wpnews"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 5
        versionName "1.5"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        manifestPlaceholders = [onesignal_app_id: "f893b120-b601-41e5-b0e3-715626efe0a3",
                                onesignal_google_project_number: "REMOTE"]
    }
    buildTypes {
        release {
            minifyEnabled false
            aaptOptions.cruncherEnabled = false
            aaptOptions.useNewCruncher = false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support:support-v4:26.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    compile 'com.android.support:cardview-v7:26.1.0'
    compile 'com.android.support:recyclerview-v7:26.1.0'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'de.hdodenhof:circleimageview:2.2.0'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
    compile 'com.squareup.okhttp3:okhttp:3.4.1'
    compile 'com.google.code.gson:gson:2.7'
    compile 'com.squareup.okhttp3:logging-interceptor:3.8.0'
    compile 'com.squareup.okhttp:okhttp:2.0.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.facebook.stetho:stetho:1.1.1'
    compile 'com.facebook.stetho:stetho-okhttp:1.1.1'
    compile 'com.github.bumptech.glide:glide:3.7.0'

    compile 'com.google.firebase:firebase-core:16.0.0'
    compile 'com.onesignal:OneSignal:[3.7.1, 3.99.99]'
    implementation files('libs/YouTubeAndroidPlayerApi.jar')
    compile 'org.jsoup:jsoup:1.10.1'
    compile 'com.google.android.gms:play-services-ads:17.0.0'
    implementation 'com.google.firebase:firebase-messaging:17.0.0'

}
apply plugin: 'com.google.gms.google-services'
错误:程序类型已存在: com.google.android.gms.internal.measurement.zzet

更新类路径

 dependencies {
        classpath 'com.android.tools.build:gradle:3.6.1'
        classpath 'com.google.gms:google-services:4.3.2'

    }
OneSignal Gradle插件

   classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.6, 0.99.99]'
使用
实现
而不是
编译

  implementation 'com.google.code.gson:gson:2.8.6'
  implementation 'com.google.firebase:firebase-messaging:17.0.0'
您正在使用非常旧的版本。如果要使用最新版本,则除非在应用程序中进行以下更改,否则库将无法工作:

  • 将CompileSDK版本升级到28或更高版本
  • 更新应用程序以使用Jetpack(AndroidX)
AndroidX使用AndroidX命名空间中的包替换原始支持库API。请阅读有关的官方指南

您的
appcompat:appcompat

implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

看见解决方案似乎是运行
clean
build
任务。另外,请不要编写自定义的
clean
任务。只需应用
base
插件(
apply plugin:'base'
),它已经定义了这些tasks@smac89非常感谢。这起作用了。知道我面临一个新错误:
错误:程序类型已经存在:com.google.android.gms.internal.measurement.zzet
当我更新classpath时,我看到如下错误:
找不到com.android.tools.layoutlib:layoutlib api:26.6.1。
@Ghaem use
classpath'gradle.plugin.com.onesignal:onesignal gradle plugin:[0.12.6,0.99.99]“
是的,谢谢。