Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NoSuchFieldError: no "Ljava/lang/String;" field "oauthToken" in class "Lcom/spotify/sdk/android/player/Config;" or its superclasses #143

Open
Mobuis opened this issue Sep 19, 2019 · 17 comments

Comments

@Mobuis
Copy link

Mobuis commented Sep 19, 2019

Hi,

I'm currently trying to build my project in Release mode on Android and it keep crashing when using Spotify.login() or Spotify.loginWithSession().

I'm building to a Google Pixel 3 with API 28.
In debug mode (on iOS and Android) it works like a charm but in release (only for Android) it's not working.

The error :

java.lang.NoSuchFieldError: no "Ljava/lang/String;" field "oauthToken" in class "Lcom/spotify/sdk/android/player/Config;" or its superclasses
JNI DETECTED ERROR IN APPLICATION: JNI FindClass called with pending exception java.lang.NoSuchFieldError: no "Ljava/lang/String;" field "oauthToken" in class "Lcom/spotify/sdk/android/player/Config;" or its superclasses
 (Throwable with no stack trace) 
     in call to FindClass
     from java.lang.String java.lang.Runtime.nativeLoad(java.lang.String, java.lang.ClassLoader)
 "main" prio=5 tid=1 Runnable
   | group="main" sCount=0 dsCount=0 flags=0 obj=0x757daee0 self=0xe635c000
   | sysTid=10286 nice=-4 cgrp=default sched=0/0 handle=0xeafe1494
   | state=R schedstat=( 7054347386 3132893614 5553 ) utm=389 stm=316 core=0 HZ=100
   | stack=0xff188000-0xff18a000 stackSize=8MB
   | held mutexes= "mutator lock"(shared held)

React: 16.8.3
React Native: 0.59.9
RN Spotify SDK: 1.2.10
Android API: 28 (v9.0 Pie)
Gradle: 5.4.1
Android Plugin Version: 3.4.0

@lufinkey
Copy link
Owner

This looks like an error coming from the actual streaming SDK itself, which is unfortunately deprecated now. I don't think there's really much I can do to fix this. Is it possible to use the debug version for release on Android?

@lufinkey
Copy link
Owner

It may also work if you use an older API version, although I'm not entirely sure.

@Mobuis
Copy link
Author

Mobuis commented Sep 19, 2019

Thanks for your quick response !

Is it possible to use the debug version for release on Android?

I really don't know..

It may also work if you use an older API version, although I'm not entirely sure.

Like how ?

@lufinkey
Copy link
Owner

You said you were using Android API 28. Try using an older version.

@Mobuis
Copy link
Author

Mobuis commented Sep 19, 2019

I've tested with Android API 26/27 right now, it's not working..

@lufinkey
Copy link
Owner

Then I'm honestly not sure. I'd try and see if you can force using the debug version of the android streaming SDK

@Mobuis
Copy link
Author

Mobuis commented Sep 19, 2019

Yeah, I don't know how to do force one package to use debug version haha
I'll try to find it and keep an eye here if you have time to test also !

@Mobuis
Copy link
Author

Mobuis commented Sep 19, 2019

It seems "enableProguardInReleaseBuilds" (minifyEnabled = true) is crashing the app

@lufinkey
Copy link
Owner

lufinkey commented Sep 19, 2019 via email

@Mobuis
Copy link
Author

Mobuis commented Sep 19, 2019

From the app's gradle file !
I didn't try from the react native module, maybe it's a good idea

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

android {
	buildTypes {
	        release {
	            lintOptions {
	                checkReleaseBuilds false
	                abortOnError false
	            }
	
	            minifyEnabled enableProguardInReleaseBuilds
	            shrinkResources enableProguardInReleaseBuilds
	            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
	            signingConfig signingConfigs.release
	        }
	    }
}

@Mobuis
Copy link
Author

Mobuis commented Sep 19, 2019

It's not a bad things to disable minifyEnabled ? Android Console will warned me about that no?

@Mobuis
Copy link
Author

Mobuis commented Sep 19, 2019

Ok so, I've tried to update the "proguard-rules.pro" file like this (and it works!):

-keep class com.lufinkey.react.spotify.RNSpotifyPackage.** { *; }
-keep class com.lufinkey.react.spotify.** { *; }
-keep class com.spotify.sdk.android.authentication.RNSpotifyPackage.** { *; }
-keep class com.spotify.sdk.android.player.SpotifyPlayer.** { *; }
-keep class com.spotify.sdk.android.player.** { *; }

@lufinkey
Copy link
Owner

lufinkey commented Sep 19, 2019 via email

@Mobuis
Copy link
Author

Mobuis commented Sep 19, 2019

I don't know how to modify this rule on app's proguard-rules.pro (clearly I'm new on React Native development), maybe making a note/add troubleshooting in the readme is better ?

@Mobuis
Copy link
Author

Mobuis commented Sep 21, 2019

On real device with intern test on Android, App is crashing :

java.lang.RuntimeException: 
  at com.facebook.react.bridge.JavaMethodWrapper.invoke (JavaMethodWrapper.java:193)
  at com.facebook.react.bridge.JavaModuleWrapper.invoke (JavaModuleWrapper.java:21)
  at com.facebook.react.bridge.queue.NativeRunnable.run (NativeRunnable.java)
  at android.os.Handler.handleCallback (Handler.java:873)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage (MessageQueueThreadHandler.java)
  at android.os.Looper.loop (Looper.java:201)
  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run (MessageQueueThreadImpl.java:37)
  at java.lang.Thread.run (Thread.java:764)

Caused by: java.lang.reflect.InvocationTargetException: 
  at java.lang.reflect.Method.invoke (Method.java)
  at com.facebook.react.bridge.JavaMethodWrapper.invoke (JavaMethodWrapper.java:149)
  at com.facebook.react.bridge.JavaModuleWrapper.invoke (JavaModuleWrapper.java:21)
  at com.facebook.react.bridge.queue.NativeRunnable.run (NativeRunnable.java)
  at android.os.Handler.handleCallback (Handler.java:873)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage (MessageQueueThreadHandler.java)
  at android.os.Looper.loop (Looper.java:201)
  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run (MessageQueueThreadImpl.java:37)
  at java.lang.Thread.run (Thread.java:764)

Caused by: java.lang.UnsatisfiedLinkError: 
  at java.lang.Runtime.loadLibrary0 (Runtime.java:1012)
  at java.lang.System.loadLibrary (System.java:1669)
  at com.spotify.sdk.android.player.SpotifyPlayer.nativeInit (SpotifyPlayer.java:2)
  at com.spotify.sdk.android.player.SpotifyPlayer.<clinit> (SpotifyPlayer.java)
  at com.spotify.sdk.android.player.SpotifyPlayer.access$000 (SpotifyPlayer.java)
  at com.spotify.sdk.android.player.SpotifyPlayer$Builder.build (SpotifyPlayer.java:11)
  at com.spotify.sdk.android.player.Spotify.getPlayer (Spotify.java:11)
  at com.lufinkey.react.spotify.RNSpotifyModule.initializePlayerIfNeeded (RNSpotifyModule.java:94)
  at com.lufinkey.react.spotify.RNSpotifyModule.loginWithSession (RNSpotifyModule.java:20)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.facebook.react.bridge.JavaMethodWrapper.invoke (JavaMethodWrapper.java:149)
  at com.facebook.react.bridge.JavaModuleWrapper.invoke (JavaModuleWrapper.java:21)
  at com.facebook.react.bridge.queue.NativeRunnable.run (NativeRunnable.java)
  at android.os.Handler.handleCallback (Handler.java:873)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage (MessageQueueThreadHandler.java)
  at android.os.Looper.loop (Looper.java:201)
  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run (MessageQueueThreadImpl.java:37)
  at java.lang.Thread.run (Thread.java:764)

@lufinkey
Copy link
Owner

lufinkey commented Sep 21, 2019

Is this after you've disabled proguard completely?

@Mobuis
Copy link
Author

Mobuis commented Sep 21, 2019

Not completely, I just activate proguard and put the rules I wrote right upon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants