Alex K
Alex K

Reputation: 5212

I get an exception using java on android (java.lang.NoClassDefFoundError), why?

This is the line I run:

AudioInputStream clip1 = AudioSystem.getAudioInputStream(new File(wavFile1));

This is the exception I get (From LogCat):

ERROR/AndroidRuntime(311): java.lang.NoClassDefFoundError: javax.sound.sampled.AudioSystem

This is an old program that I wrote a year ago and then it worked perfectly. Why do I get this exception and how can I fix this?

Upvotes: 1

Views: 1805

Answers (3)

Femi
Femi

Reputation: 64700

AudioSystem is part of JavaSound, and JavaSound is part of the desktop JVM/SDK. JavaSound is NOT present in the Android JVM/SDK, so your old code will not compile on any current Android SDK.

See http://developer.android.com/guide/topics/media/index.html for the Android audio functionality outline: you will need to port your old code to use the Android SDK classes.

Upvotes: 5

sat
sat

Reputation: 41096

It clearly means class AudioSystem is not present in your project. May be you were referencing some libraries which may be missing now.

Upvotes: 0

Nallath
Nallath

Reputation: 2116

The problem is that the classpath isn't set correctly. See this question for some solutions.

Upvotes: 0

Related Questions