-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
Add support for Android 5.1 (API Level 22) and earlier (NoClassDefFoundError) #70
Comments
Thanks for the detailed report! I just had a look at the Android SDK release notes and it really looks like Android 5.1 only supports API Level 22, while the If upgrading your phone to Android 6 or higher is not an option, I think it should be possible to add support for Android 5 by avoiding the Builder class used here:
in favour of a direct instantiation of If you'd be happy to try out some test builds of the library I could give it a go, but not for another week or so. (It might be a pretty trivial fix, so if you're somewhat familiar with |
This one should/could work: import android.media.AudioManager;
...
this.audioTrack = new AudioTrack(new AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_MEDIA)
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
.build(), new AudioFormat.Builder()
.setChannelMask(AudioFormat.CHANNEL_OUT_STEREO)
.setEncoding(AudioFormat.ENCODING_PCM_16BIT)
.setSampleRate(this.frameRate)
.build(), this.bufferSize, AudioTrack.MODE_STREAM, AudioManager.AUDIO_SESSION_ID_GENERATE); |
I think using a more modern Android version is probably the easiest fix, but the Processing for Android documentation seems to imply that the minimum supported Android version is 4.2 (for running sketches), and I'm not sure if Processing libraries are required to adhere to this. In any case, I've built the library locally with the suggested change, following the steps on the README for building and deploying it. However, the problem is still occurring. Looking at processing-sound/src/processing/sound/JSynAndroidAudioDeviceManager.java Lines 144 to 153 in 5e57e77
If I comment out this section, rebuild and redeploy the library locally, the sketch code does play audio when the screen is pressed on my Android device, and the console error no longer occurs. |
Ah yes you are right, I mixed up |
This might be because I happen to be using both the suggested |
Suppose I have a sketch that simply plays a sound when the screen is pressed:
While this works as expected on my Windows 10 PC, running the same sketch on my Android 5.1 Moto E device shows the following error in the console log and does not play any audio when the screen is pressed:
This is also using Processing 3.5.4 with Android Mode 4.2.1 installed in the Contribution Manager.
I've found an existing question on the Processing Discourse which very closely matches the error I'm seeing here, but it doesn't have any replies.
So my questions are:
The text was updated successfully, but these errors were encountered: