I am developing an android based app which process speech. My app references a .jar dependency and I have successfully added that jar as a library in my project but as I run the project it gives me java.lang.NoClassDefFoundError: for an class file which is there in jar file Basically the class file which throwing the above error imports javax.sound.sampled packages in the code.
I am working on this part since last couple of months now but didn't found any way out of this. I have tried copying the source code of jar library into android studio and then referencing javax.sound.sampled jar to it even tried copying javax.sound.sampled source code into android and then attaching them as per flow but still no luck.
It would be nice if I get alternatives for below imports, as it will solve the issue
- import javax.sound.sampled.AudioFileFormat;
- import javax.sound.sampled.AudioFormat;
- import javax.sound.sampled.AudioFileFormat.Type;
- import javax.sound.sampled.AudioFormat.Encoding;
- import javax.sound.sampled.AudioInputStream;
- import javax.sound.sampled.AudioSystem;
- import javax.sound.sampled.UnsupportedAudioFileException;
Edit: I am facing problem here
String strFullName = "com/example/packagename/AudioFileReader.class";
Enumeration<?> configs = null;
try {
configs = Service.class.getClassLoader().getSystemResources("strFullName");
} catch (Throwable e) {
}
if (configs != null) {
while (configs.hasMoreElements()) {
URL configFileUrl = (URL) configs.nextElement();
InputStream input = null;
try {
input = configFileUrl.openStream();
} catch (Throwable e2) {
}
if (input != null) {
BufferedReader reader = new BufferedReader(new InputStreamReader(input));
try {
for (String strLine = reader.readLine(); strLine != null; strLine = reader.readLine()) {
strLine = strLine.trim();
int nPos = strLine.indexOf(35);
if (nPos >= 0) {
strLine = strLine.substring(0, nPos);
}
if (strLine.length() > 0) {
providers.add(strLine);
}
}
} catch (Throwable e22) {
}
}
}
}
Iterator<String> iterator = providers.iterator();
return iterator;
}
It gives me TwoEnumerationsInOne and configs.hasMoreElements() gives false so not able to go into while loop. AudioFileReader.java is included in the package
Thanks in advance.