1

我在用

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

在我的项目中,我刚刚将 IDE 升级到了 Android Studio 3.3.1。在我build.gradle的以下代码中进行编译

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}

在尝试构建时,我收到此错误:

任务 :app:mergeExtDexDebug FAILED AGPBI: {"kind":"error","text":"默认接口方法仅支持从 Android N (--min-api 24) 开始:void com.google.android.exoplayer2。 Player$EventListener.onLoadingChanged(boolean)","sources":[{}],"tool":"D8"}

FAILURE:构建失败并出现异常。

  • 出了什么问题:无法解析配置“:app:debugRuntimeClasspath”的所有文件。在 dexing 时使用转换 DexingTransform 错误将文件“classes.jar”转换为匹配属性 {artifactType=android-dex, dexing-is-debuggable=true, dexing-min-sdk=21} 失败。

当我将sourceCompatibilityand更改targetCompatibility为 时JavaVersion.VERSION_1_8,它会成功构建,但应用程序崩溃并出现以下错误:

E/AndroidRuntime:致命异常:主进程:com.mypackage,PID:4374 java.lang.NoSuchMethodError:没有直接方法(Lcom/google/android/exoplayer2/upstream/DefaultAllocator;IIJJLcom/google/android/exoplayer2/util/PriorityTaskManager ;)V 在 Lcom/google/android/exoplayer2/DefaultLoadControl 类中;或其超类(“com.google.android.exoplayer2.DefaultLoadControl”的声明出现在 /data/app/mypackagename/base.apk:classes5.dex 中)

有什么建议么?

项目构建.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"
        }
    }
}

应用程序构建.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'
}
4

1 回答 1

0

在应用程序级别添加以下代码build.gradle

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

将您的 SDK 和关联的库升级到 28...还将您的 Gradle 升级到gradle-4.10.1-all.zip...然后rebuild应用程序...然后Invalidate Cache/RestartFile菜单中升级。

rebuild如果仍然无法正常工作, 请添加以下代码并按照以下步骤操作Invalidate Cache/Restart

implementation ('react-native-track-player') {
    exclude group: 'com.google.android.exoplayer'
}
implementation 'com.google.android.exoplayer:exoplayer:2.7.3'
于 2019-02-21T19:33:42.167 回答