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

Cannot save generated midi java.lang.NoClassDefFoundError: Failed resolution of: Ljp/kshoji/javax/sound/midi/MidiSystem; #10

Open
mkutr opened this issue Jun 27, 2021 · 0 comments

Comments

@mkutr
Copy link

mkutr commented Jun 27, 2021

Hi! I am trying to use the Jfugue on Android, but I am getting this error:

java.lang.NoClassDefFoundError: Failed resolution of: Ljp/kshoji/javax/sound/midi/MidiSystem;
at org.jfugue.player.SequencerManager.getDefaultSequencer(SequencerManager.java:55)
at org.jfugue.player.SequencerManager.<init>(SequencerManager.java:50)
at org.jfugue.player.SequencerManager.getInstance(SequencerManager.java:41)
at org.jfugue.player.ManagedPlayer.<init>(ManagedPlayer.java:47)
at org.jfugue.player.Player.<init>(Player.java:46)
at org.jfugue.midi.MidiFileManager.savePatternToMidi(MidiFileManager.java:53)
at org.jfugue.midi.MidiFileManager.savePatternToMidi(MidiFileManager.java:58)
at com.avister.midiGeneration.GenerateMidiActivity.dubSave(GenerateMidiActivity.kt:52)
at com.avister.ml.models.MusicGeneratorAndroidTest$dubSaveTest$1.perform(MusicGeneratorAndroidTest.kt:141)
at com.avister.ml.models.MusicGeneratorAndroidTest$dubSaveTest$1.perform(MusicGeneratorAndroidTest.kt:18)
at androidx.test.core.app.ActivityScenario.lambda$onActivity$2$ActivityScenario(ActivityScenario.java:660)
at androidx.test.core.app.ActivityScenario$$ExternalSyntheticLambda2.run(Unknown Source:4)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.app.Instrumentation$SyncRunnable.run(Instrumentation.java:2223)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.ClassNotFoundException: Didn't find class "jp.kshoji.javax.sound.midi.MidiSystem" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/android.test.mock.jar", zip file "/system/framework/android.test.base.jar", zip file "/data/app/~~lil1u2Nb8-ocLGw0F8dAbw==/com.avister.test-F5TBrSomZjMeER7Y26_viQ==/base.apk", zip file "/data/app/~~h9pnhGV0TWqabygf7I8F7Q==/com.avister-zQJ2i_8pkzzeqXPzP3hGLg==/base.apk"],nativeLibraryDirectories=[/data/app/~~lil1u2Nb8-ocLGw0F8dAbw==/com.avister.test-F5TBrSomZjMeER7Y26_viQ==/lib/x86, /data/app/~~h9pnhGV0TWqabygf7I8F7Q==/com.avister-zQJ2i_8pkzzeqXPzP3hGLg==/lib/x86, /data/app/~~lil1u2Nb8-ocLGw0F8dAbw==/com.avister.test-F5TBrSomZjMeER7Y26_viQ==/base.apk!/lib/x86, /data/app/~~h9pnhGV0TWqabygf7I8F7Q==/com.avister-zQJ2i_8pkzzeqXPzP3hGLg==/base.apk!/lib/x86, /system/lib, /system_ext/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 22 more

When trying to perform this test:

internal class MusicGeneratorAndroidTest {

    @get:Rule
    val activityTestRule = ActivityScenarioRule(GenerateMidiActivity::class.java)

    @Test
    fun exampleSaveTest() {
        activityTestRule.scenario.onActivity {
            it.exampleSave()
        }
    }
}
class GenerateMidiActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_generate_midi)
    }

    fun exampleSave() {
        val cw = ContextWrapper(applicationContext)
        val directory = cw.getExternalFilesDir(Environment.DIRECTORY_MUSIC)
        val pattern: Pattern = Pattern("C4")
        val file = File(directory, "test.midi")
        MidiFileManager.savePatternToMidi(pattern, file)
    }
}

What may be the cause and how to fix this?

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

1 participant