的NoSuchMethodError为COM /谷歌/机器人/ exoplayer2 /上行/ De

2019-10-28 10:25发布

我在用

com.amazon.android:exoplayer-ui:r2.5.4

在项目中,我刚刚升级IDE到Android 3.3.1工作室。 在我build.gradle我有下面的代码编译

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}

而试图建立,我得到这个错误:

任务:应用程序:mergeExtDexDebug FAILED AGPBI:{ “种类”: “错误”, “文”:“默认接口方法仅支持开始与Android N(--min-API 24):无效com.google.android.exoplayer2。玩家$ EventListener.onLoadingChanged(布尔)”, “源”:[{}], “工具”: “D8”}

故障:建立失败,一个例外。

  • 出了什么问题:无法解析配置的所有文件“:应用程序:debugRuntimeClasspath”。 无法转换文件“classes.jar”的匹配属性{artifactType =机器人-DEX,德兴-是-可调试=真,德兴分钟-SDK = 21}使用变换DexingTransform错误而德兴。

当我改变sourceCompatibilitytargetCompatibilityJavaVersion.VERSION_1_8 ,它获得成功打造但是以下错误应用程序崩溃:

E / AndroidRuntime:致命异常:主要过程:com.mypackage,PID:4374 java.lang.NoSuchMethodError:没有直接法(LCOM /谷歌/机器人/ exoplayer2 /上行/ DefaultAllocator; IIJJLcom /谷歌/机器人/ exoplayer2 / UTIL / PriorityTaskManager ;)V类LCOM /谷歌/机器人/ exoplayer2 / DefaultLoadControl; 或它的超类(的“com.google.android.exoplayer2.DefaultLoadControl”声明出现在/data/app/mypackagename/base.apk:classes5.dex)

有什么建议么?

项目的build.gradle

    buildscript {
    System.properties['com.android.build.gradle.overrideVersionCheck'] = 'true'
    repositories {
        jcenter()
        mavenCentral()
        maven { url "https://plugins.gradle.org/m2/" }
        maven { url 'https://maven.google.com' }
        google()

    }

    dependencies {
        classpath 'com.google.gms:google-services:3.0.0'
        classpath 'com.android.tools.build:gradle:3.3.1'
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}
allprojects {

    repositories {
        jcenter()
        mavenCentral()
        maven { url 'https://maven.google.com' }

    }

    gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
        }
    }
}

应用的build.gradle

buildscript {
    repositories {
        google()
        mavenLocal()
        maven { url 'https://maven.fabric.io/public' }
        jcenter()
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.27.0'
        classpath 'com.google.gms:google-services:4.2.0'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    jcenter()
    maven { url 'https://maven.fabric.io/public' }
}
android {
    compileSdkVersion 26
    buildToolsVersion '28.0.3'
    defaultConfig {
        applicationId ‘myAppId’
        minSdkVersion 21
        targetSdkVersion 26

        versionCode 31
        versionName "1.3.5"
        multiDexEnabled true
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["room.schemaLocation":
                                     "$projectDir/schemas".toString()]
            }
        }
        sourceSets {
            androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
        }
    }

    dexOptions {
        javaMaxHeapSize "6g" 
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
        checkReleaseBuilds false
              abortOnError false
    }
    productFlavors {
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    packagingOptions {
        exclude 'META-INF/android.arch.lifecycle_runtime.version'
    }
}


dependencies {

implementation 'com.android.support:recyclerview-v7:26.1.0'
    implementation 'com.android.support:leanback-v17:23.1.0'
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.loopj.android:android-async-http:1.4.9'
    implementation 'com.google.code.gson:gson:2.2.4'
    implementation 'com.google.android.gms:play-services-ads:9.8.0'
    implementation 'com.github.bumptech.glide:glide:3.7.0'
    implementation 'com.jakewharton:butterknife:7.0.1'
    implementation 'com.makeramen:roundedimageview:2.2.1'
    implementation 'com.mcxiaoke.volley:library-aar:1.0.0'
    implementation 'com.android.support:support-vector-drawable:26.1.0'
    implementation 'com.android.support:animated-vector-drawable:26.1.0'
    implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.8.5'
    implementation('com.amazon.android:exoplayer-ui:r2.5.4') {
        exclude module: 'exoplayer-core'
    }
    api 'com.amazon.android:exoplayer-core:r2.5.4'
    implementation 'com.amazon.android:exoplayer-hls:r2.5.4'
    implementation 'com.amazon.android:exoplayer-dash:r2.5.4'
    implementation 'com.amazon.android:extension-okhttp:r2.5.4'
    implementation 'commons-net:commons-net:3.3'

    implementation('android.arch.persistence.room:rxjava2:1.0.0-rc1') {
        exclude group: 'com.android.support', module: 'support-compat'
        exclude group: 'android.arch.persistence.room', module: 'runtime'
        exclude group: 'com.android.support', module: 'support-core-utils'
    }
    implementation('android.arch.persistence.room:runtime:1.0.0-rc1') {
        exclude group: 'com.android.support', module: 'support-compat'
        exclude group: 'com.android.support', module: 'support-core-utils'
    }
    implementation 'android.arch.lifecycle:runtime:1.0.0-rc1'
    implementation('android.arch.lifecycle:extensions:1.0.0-rc1') {
        exclude group: 'com.android.support', module: 'support-compat'
        exclude group: 'com.android.support', module: 'support-core-ui'
        exclude group: 'com.android.support', module: 'support-core-utils'
    }
    annotationProcessor "android.arch.persistence.room:compiler:1.0.0-rc1"
    annotationProcessor "android.arch.lifecycle:compiler:1.0.0-rc1"
    annotationProcessor "com.jakewharton:butterknife:7.0.1"
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'io.reactivex.rxjava2:rxjava:2.1.0'
}

configurations.all {
    resolutionStrategy.force 'com.android.support:support-v4:26.1.0'
}

Answer 1:

下面添加代码的应用程序级build.gradle

implementation 'com.google.android.exoplayer:exoplayer:2.7.3'

升级你的SDK和相关的LIB至28 ...也升级到摇篮gradle-4.10.1-all.zip ......然后rebuild应用程序...然后Invalidate Cache/Restart ,从File菜单。

如果仍然没有工作然后添加下面的代码,然后按照步骤rebuildInvalidate Cache/Restart

implementation ('react-native-track-player') {
    exclude group: 'com.google.android.exoplayer'
}
implementation 'com.google.android.exoplayer:exoplayer:2.7.3'


文章来源: NoSuchMethodError for com/google/android/exoplayer2/upstream/DefaultAllocator