首页 > 解决方案 > java.lang.NoSuchMethodError:没有直接方法(Lcom/google/android/exoplayer2/upstream/DefaultAllocator;IIJJ)V

问题描述

我正在使用https://github.com/react-native-kit/react-native-track-player这个库,我面临关于 exoplayer 的问题,应用程序在启动时崩溃

版本 react-native: "0.49.0" react-native-track-player: devBranch

java.lang.NoSuchMethodError: No direct method <init>(Lcom/google/android/exoplayer2/upstream/DefaultAllocator;IIJJ)V in class Lcom/google/android/exoplayer2/DefaultLoadControl; or its super classes (declaration of 'com.google.android.exoplayer2.DefaultLoadControl' appears in /data/app/com.test.myapp-OHj1RziNXZi6KAifrwaU0w==/base.apk)
    at guichaguri.trackplayer.player.players.ExoPlayback.<init>(ExoPlayback.java:62)
    at guichaguri.trackplayer.logic.MediaManager.createLocalPlayback(MediaManager.java:65)
    at guichaguri.trackplayer.logic.MediaManager.setupPlayer(MediaManager.java:78)
    at guichaguri.trackplayer.logic.components.MediaWrapper.setupPlayer(MediaWrapper.java:36)
    at guichaguri.trackplayer.TrackModule$1.run(TrackModule.java:143)
    at android.os.Handler.handleCallback(Handler.java:790)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6494)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

这是来自 ExoPlayback.class 的依赖错误还是程序错误

我的项目依赖

compileSdkVersion 26
buildToolsVersion "26.0.2"

defaultConfig {
    applicationId "com.xxx.yyy"
    minSdkVersion 16
    targetSdkVersion 26
    versionCode 2
    versionName "0.2.1"
    multiDexEnabled true
    renderscriptTargetApi 23
    renderscriptSupportModeEnabled true
    ndk {
        abiFilters "armeabi-v7a", "x86"
    }
}
dexOptions {
    javaMaxHeapSize "4g"
}
splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include "armeabi-v7a", "x86"
    }
}
repositories {
    maven {
        url 'http://repo.brightcove.com/releases'
    }
}
dependencies {
    compile project(':react-native-brightcove-player')
    compile project(':react-native-image-picker')
    compile project(':react-native-track-player')
    compile project(':react-native-text-input-mask')
    compile project(':react-native-share')
    compile project(':react-native-sound')
    compile project(':react-native-pdf')
    compile project(':react-native-onesignal')
    compile project(':appcenter-crashes')
    compile project(':appcenter-analytics')
    compile project(':appcenter')
    compile project(':react-native-fetch-blob')
    compile project(':tipsi-stripe')
    compile project(':react-native-payments')
    compile project(':react-native-fs')
    compile project(':react-native-blur')
    compile project(':react-native-picker')
    compile project(':react-native-device-info')
    compile project(':react-native-extra-dimensions-android')
    compile project(':react-native-immersive')
    compile project(':react-native-orientation')
    compile project(':react-native-splash-screen')
    compile project(':react-native-config')
    compile project(':react-native-code-push')
    compile project(':react-native-video')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:support-v4:26.1.0'
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile project(':react-native-linear-gradient')
    compile project(':react-native-webview-bridge')
}

标签: androidreact-nativeexoplayer

解决方案


推荐阅读