React-native-track-player: Failed resolution of: Landroid/support/v7/app/NotificationCompat$Builder targetSdk 26

Created on 12 Mar 2018  路  10Comments  路  Source: react-native-kit/react-native-track-player

Building project for android using support libs 26.0.2 crashes with error:

java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/app/NotificationCompat$Builder;
                                                                    at guichaguri.trackplayer.metadata.components.MediaNotification.<init>(MediaNotification.java:48)
                                                                    at guichaguri.trackplayer.metadata.Metadata.<init>(Metadata.java:59)
                                                                    at guichaguri.trackplayer.logic.MediaManager.<init>(MediaManager.java:39)
                                                                    at guichaguri.trackplayer.logic.services.PlayerService.onCreate(PlayerService.java:74)
                                                                    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3404)
                                                                    at android.app.ActivityThread.-wrap4(Unknown Source:0)
                                                                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1683)
                                                                    at android.os.Handler.dispatchMessage(Handler.java:105)
                                                                    at android.os.Looper.loop(Looper.java:164)
                                                                    at android.app.ActivityThread.main(ActivityThread.java:6541)
                                                                    at java.lang.reflect.Method.invoke(Native Method)
                                                                    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
                                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
                                                                 Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.app.NotificationCompat$Builder" on path: DexPathList[[zip file "/data/app/com.remxapp.remx-dW0D8fi8COR_oJOG8WyMxg==/base.apk"],nativeLibraryDirectories=[/data/app/com.remxapp.remx-dW0D8fi8COR_oJOG8WyMxg==/lib/x86, /data/app/com.remxapp.remx-dW0D8fi8COR_oJOG8WyMxg==/base.apk!/lib/x86, /system/lib, /vendor/lib]]
                                                                    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
                                                                    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
                                                                    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)

I'm not an android dev so can't really help to fix it, any ideas?

Android Bug

Most helpful comment

@jankarres I've pushed a change to my fork that should fix it. I've also opened up issues as we might want to continue the discussion over there.

All 10 comments

The most recent versions of the support lib removed/changed a few classes that I use. For now, use the older versions instead.

thanks for the reply. I don't think I can downgrade our support lib version, we have a few other libs that depends on min 26.0.0.

Thank you for your great work, @Guichaguri and @dcvz. I have to join @haswalt unfortunately that < 26.0.0 is not possible for some popular libraries, like the react-native-fbsdk.

I tried to implement the new API of NotificationCompat.Builder() with my limited Java, but I had to find out that this would cause further problems.

I would like to switch from react-native-sound and react-native-music-controls to react-native-track-player and would be grateful for a compatibility to 26.0.0.0.

@jankarres I've got a fork over here https://github.com/BlueBambooStudios/react-native-track-player that we've got at least building, it's still not working fully due to some isues with service changes but we're working towards a fix.

I'm afraid my fork is a bit of a mess at the moment whilst I work through getting it working as well as some additional features we've added. Hopefully of use

@haswalt Awesome, thanks for your work. But there is actually still a major issue? If I execute

import TrackPlayer from "react-native-track-player"; [...] TrackPlayer.setupPlayer();

The app crashed with the following stack. Actually a issue you have, too?

java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/media/app/NotificationCompat$MediaStyle; at guichaguri.trackplayer.metadata.components.MediaNotification.<init>(MediaNotification.java:75) at guichaguri.trackplayer.metadata.Metadata.<init>(Metadata.java:59) at guichaguri.trackplayer.logic.MediaManager.<init>(MediaManager.java:39) at guichaguri.trackplayer.logic.services.PlayerService.onCreate(PlayerService.java:74) at android.app.ActivityThread.handleCreateService(ActivityThread.java:3232) at android.app.ActivityThread.-wrap5(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1606) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:163) at android.app.ActivityThread.main(ActivityThread.java:6205) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794) Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.media.app.NotificationCompat$MediaStyle" on path: DexPathList[[zip file "/data/app/some/base.apk"],nativeLibraryDirectories=[/data/app/some/lib/arm, /data/app/some/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:380) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) ... 13 more

@jankarres ah yes. so it's very WIP :)

I think I added some deps to the gadle config in my parent project that make it work. I'l try adding them to the repo so you get them automatically.

give me 5 minutes

@jankarres I've pushed a change to my fork that should fix it. I've also opened up issues as we might want to continue the discussion over there.

For me the crash was causing due to another library which was also using exoplayer. I removed the other library and it worked fine.

I have same issue as you had .
You can migrate NotificationCompat version to v4

Please see that pull request #205 I created
It will works fine.

You can add directly my fork repository in your package.json if my pull request will not be merged.
Please see the example below.

dependencies: {
    "react-native-track-player":
      "git+https://github.com/rm3rdmodules/react-native-track-player.git#dev"
}

Fixed in a89f8ba97a2462c137ccd126af9ec40962a82bb5

Was this page helpful?
0 / 5 - 0 ratings