com/google/android/exoplayer2/upstream/DefaultAllocator的NoSuchMethodError [英] NoSuchMethodError for com/google/android/exoplayer2/upstream/DefaultAllocator
问题描述
我正在使用
com.amazon.android:exoplayer-ui:r2.5.4
com.amazon.android:exoplayer-ui:r2.5.4
在我的项目中,我刚刚将IDE升级到Android Studio 3.3.1.
在我的build.gradle
中,我有以下用于编译的代码
in my project I just upgraded IDE to Android Studio 3.3.1.
in my build.gradle
I have below code for compile
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
在尝试构建时,出现此错误:
While trying to build, I get this error:
任务:app:mergeExtDexDebug失败AGPBI: {"kind":错误","text":仅支持默认接口方法 从Android N(--min-api 24)开始:void com.google.android.exoplayer2.Player $ EventListener.onLoadingChanged(boolean),"源:[{}],"工具:" D8}
Task :app:mergeExtDexDebug FAILED AGPBI: {"kind":"error","text":"Default interface methods are only supported starting with Android N (--min-api 24): void com.google.android.exoplayer2.Player$EventListener.onLoadingChanged(boolean)","sources":[{}],"tool":"D8"}
失败:构建失败,并出现异常.
FAILURE: Build failed with an exception.
- 出了什么问题:无法解析配置':app:debugRuntimeClasspath'的所有文件. 无法转换文件"classes.jar"以匹配属性{artifactType = android-dex,dexing-is-debuggable = true, dexing-min-sdk = 21}使用变换DexingTransform 删除时出错.
- What went wrong: Could not resolve all files for configuration ':app:debugRuntimeClasspath'. Failed to transform file 'classes.jar' to match attributes {artifactType=android-dex, dexing-is-debuggable=true, dexing-min-sdk=21} using transform DexingTransform Error while dexing.
当我将sourceCompatibility
和targetCompatibility
更改为JavaVersion.VERSION_1_8
时,它可以成功构建,但是应用程序崩溃并显示以下错误:
When I change the sourceCompatibility
and targetCompatibility
to JavaVersion.VERSION_1_8
, it gets build successfully but the app crashes with following error:
E/Android运行时:致命异常:主要 流程: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)
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.mypackage, PID: 4374 java.lang.NoSuchMethodError: No direct method (Lcom/google/android/exoplayer2/upstream/DefaultAllocator;IIJJLcom/google/android/exoplayer2/util/PriorityTaskManager;)V in class Lcom/google/android/exoplayer2/DefaultLoadControl; or its super classes (declaration of 'com.google.android.exoplayer2.DefaultLoadControl' appears in /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"
}
}
}
app 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'
}
推荐答案
在应用程序级别build.gradle
implementation 'com.google.android.exoplayer:exoplayer:2.7.3'
将您的SDK和相关的lib升级到28 ...也将您的Gradle升级到gradle-4.10.1-all.zip
...然后将rebuild
应用程序...然后从File
菜单中选择Invalidate Cache/Restart
.
upgrade your SDK and associated lib to 28...Also upgrade your Gradle to gradle-4.10.1-all.zip
...then rebuild
app...then Invalidate Cache/Restart
from File
menu.
如果仍然无法正常工作,请添加以下代码,并按照rebuild
和Invalidate Cache/Restart
If still not working then add below code and follow steps of rebuild
and Invalidate Cache/Restart
implementation ('react-native-track-player') {
exclude group: 'com.google.android.exoplayer'
}
implementation 'com.google.android.exoplayer:exoplayer:2.7.3'
这篇关于com/google/android/exoplayer2/upstream/DefaultAllocator的NoSuchMethodError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!