doublesymmetry / react-native-track-player

A fully fledged audio module created for music apps. Provides audio playback, external media controls, background mode and more!
https://rntp.dev/
Apache License 2.0
3.24k stars 1k forks source link

No direct method <init>(Lcom/google/android/exoplayer2/upstream/DefaultAllocator;IIJJ)V in class #236

Closed jariwalabhavesh closed 6 years ago

jariwalabhavesh commented 6 years ago

I am facing issue regarding exoplayer, App is crashing on start

Versions 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)

My Project dependency

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 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')
}
Guichaguri commented 6 years ago

It might be a conflict with react-native-sound. Do you really need both modules?

jariwalabhavesh commented 6 years ago

@Guichaguri Thanks for response,

I had removed react-native-sound and tried again but it has same issue, i think react-native-brightcove-player is conflicting because i had found exo player dependency in it's build.gradle

here is 'react-native-brightcove-player build.gradle'

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

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
    }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url "$projectDir/../node_modules/react-native/android"
        }
        maven {
            url 'http://repo.brightcove.com/releases'
        }
    }
}

apply plugin: 'com.android.library'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    lintOptions {
        warning 'InvalidPackage'
    }
}

dependencies {
    compile 'com.facebook.react:react-native:+'
    compile 'com.brightcove.player:exoplayer2:6.+'
}

After implementing react-native-brightcove-player i had face this issue and it is start giving exo error in react-native-track-player. Can you provide suggestion how can i fix that.

Alanz2223 commented 6 years ago

Facing the same issue here, I am using react-native-video "^3.1.0" which depends on 'com.google.android.exoplayer:exoplayer:2.7.3'.

Guichaguri commented 6 years ago

You can remove the conflict by unifying the ExoPlayer version, read this: https://github.com/react-native-kit/react-native-track-player/pull/165#issuecomment-407914722

Alanz2223 commented 6 years ago

Indeed. That's how I solved the issue, just a heads up there are some deprecation warnings and a few changes you'll have to make to ExoPlayer.java to use an updated version of Exoplayer (change a few method signatures). They don't seem to be altering the player but I am still unsure.