ClassNotFoundException for JuceSharingContentProvider

Running an Android app with a JUCE dynamic library built with 5.4.4 (develop at 937991) I get the following runtime error:

 JNI DETECTED ERROR IN APPLICATION: JNI NewGlobalRef called with pending exception java.lang.ClassNotFoundException: Didn't find class "com.roli.juce.JuceSharingContentProvider$ProviderCursor" ...

Content Sharing is set to Disabled in Projucer.

The latest known tag that works for me is version 5.4.2 (not tried 5.4.3 yet)

Are you seeing this when building a standard JUCE GUI project on Android or is it only when linking against a JUCE .dll from a non-JUCE app? I can’t reproduce it building the DemoRunner on the latest develop tip.

I am seeing it when linking a JUCE dll from a non-JUCE Android app.

DemoRunner runs fine.

I can confirm that 5.4.3 does not exhibit this problem.

What SDK version are you targeting?

Can you try with the following commit and see if it’s been fixed?

Target SDK version is 26. I will try your commit and report back, thanks!

@ed95 Do I need to recompile Projucer and resave?

Just a re-save should be fine.

1 Like

OK, slightly different error this time - looks like it’s having trouble loading the byte code?

Unable to load dex file: java.nio.HeapByteBuffer[pos=0 lim=0 cap=0]
java.io.IOException: Bad range


JNI DETECTED ERROR IN APPLICATION: JNI NewGlobalRef called with pending exception java.lang.ClassNotFoundException: Didn't find class "com.roli.juce.JuceSharingContentProvider" on path: DexPathList[[...]]

Just hit this issue again after blindly updating the JUCE version for the project…

I am also getting this though the application continues to run

 2019-11-04 02:48:38.753 15407-15407/com.yourcompany.newproject1 E/System: Unable to load dex file: java.nio.HeapByteBuffer[pos=0 lim=0 cap=0]
2019-11-04 02:48:38.755 15407-15407/com.yourcompany.newproject1 E/System: java.io.IOException: Bad range
        at dalvik.system.DexFile.createCookieWithArray(Native Method)
        at dalvik.system.DexFile.openInMemoryDexFile(DexFile.java:366)
        at dalvik.system.DexFile.<init>(DexFile.java:107)
        at dalvik.system.DexPathList.makeInMemoryDexElements(DexPathList.java:291)
        at dalvik.system.DexPathList.<init>(DexPathList.java:105)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:117)
        at dalvik.system.InMemoryDexClassLoader.<init>(InMemoryDexClassLoader.java:35)
        at dalvik.system.InMemoryDexClassLoader.<init>(InMemoryDexClassLoader.java:46)
        at java.lang.Runtime.nativeLoad(Native Method)
        at java.lang.Runtime.doLoad(Runtime.java:1099)
        at java.lang.Runtime.loadLibrary0(Runtime.java:1014)
        at java.lang.System.loadLibrary(System.java:1657)
        at com.roli.juce.Java.<clinit>(Java.java:9)
        at com.roli.juce.Java.initialiseJUCE(Native Method)
        at com.roli.juce.JuceApp.onCreate(JuceApp.java:13)
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1120)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5826)
        at android.app.ActivityThread.-wrap1(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1685)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:176)
        at android.app.ActivityThread.main(ActivityThread.java:6651)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)
2019-11-04 02:48:38.758 15407-15412/com.yourcompany.newproject1 I/zygote64: Do partial code cache collection, code=30KB, data=18KB
2019-11-04 02:48:38.759 15407-15412/com.yourcompany.newproject1 I/zygote64: After code cache collection, code=30KB, data=18KB
2019-11-04 02:48:38.759 15407-15412/com.yourcompany.newproject1 I/zygote64: Increasing code cache capacity to 128KB
2019-11-04 02:48:38.820 15407-15407/com.yourcompany.newproject1 W/ResourceType: No package identifier when getting name for resource number 0x00000000
2019-11-04 02:48:38.836 15407-15407/com.yourcompany.newproject1 I/JUCE: JUCE v5.4.5