Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid - App wont start up
    primarykey
    data
    text
    <p>My app wont start up with the following errors:</p> <pre><code>11-08 03:20:58.265: E/AndroidRuntime(306): FATAL EXCEPTION: main 11-08 03:20:58.265: E/AndroidRuntime(306): java.lang.NoClassDefFoundError: android.media.audiofx.Equalizer 11-08 03:20:58.265: E/AndroidRuntime(306): at com.example.audiotest.MainActivity.onCreate(MainActivity.java:86) 11-08 03:20:58.265: E/AndroidRuntime(306): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 11-08 03:20:58.265: E/AndroidRuntime(306): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) 11-08 03:20:58.265: E/AndroidRuntime(306): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 11-08 03:20:58.265: E/AndroidRuntime(306): at android.app.ActivityThread.access$2300(ActivityThread.java:125) 11-08 03:20:58.265: E/AndroidRuntime(306): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 11-08 03:20:58.265: E/AndroidRuntime(306): at android.os.Handler.dispatchMessage(Handler.java:99) 11-08 03:20:58.265: E/AndroidRuntime(306): at android.os.Looper.loop(Looper.java:123) 11-08 03:20:58.265: E/AndroidRuntime(306): at android.app.ActivityThread.main(ActivityThread.java:4627) 11-08 03:20:58.265: E/AndroidRuntime(306): at java.lang.reflect.Method.invokeNative(Native Method) 11-08 03:20:58.265: E/AndroidRuntime(306): at java.lang.reflect.Method.invoke(Method.java:521) 11-08 03:20:58.265: E/AndroidRuntime(306): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 11-08 03:20:58.265: E/AndroidRuntime(306): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 11-08 03:20:58.265: E/AndroidRuntime(306): at dalvik.system.NativeStart.main(Native Method) 11-08 03:20:58.285: E/AudioThread(306): Thread Loop Exception: java.lang.IllegalArgumentException: Invalid audio buffer size. </code></pre> <p>My codes for OnCreate()</p> <pre><code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //Audio, mic to speaker setVolumeControlStream(AudioManager.STREAM_MUSIC); initControls(); mAudioThread = new AudioThread(); mAudioThread.start(); //end //Equalizer enabled = (CheckBox)findViewById(R.id.enabled); enabled.setOnCheckedChangeListener (this); flat = (Button)findViewById(R.id.flat); flat.setOnClickListener(this); bass_boost = (SeekBar)findViewById(R.id.bass_boost); bass_boost.setOnSeekBarChangeListener(this); bass_boost_label = (TextView) findViewById (R.id.bass_boost_label); sliders[0] = (SeekBar)findViewById(R.id.slider_1); slider_labels[0] = (TextView)findViewById(R.id.slider_label_1); //more sliders till [4] mEqualizer = new Equalizer(0, mAudioTrack.getAudioSessionId()); mEqualizer.setEnabled(true); eq = new Equalizer (0, 0); if (eq != null) { eq.setEnabled (true); int num_bands = eq.getNumberOfBands(); num_sliders = num_bands; short r[] = eq.getBandLevelRange(); min_level = r[0]; max_level = r[1]; for (int i = 0; i &lt; num_sliders &amp;&amp; i &lt; MAX_SLIDERS; i++) { int[] freq_range = eq.getBandFreqRange((short)i); sliders[i].setOnSeekBarChangeListener(this); slider_labels[i].setText (formatBandLabel (freq_range)); } } for (int i = num_sliders ; i &lt; MAX_SLIDERS; i++) { sliders[i].setVisibility(View.GONE); slider_labels[i].setVisibility(View.GONE); } bb = new BassBoost (0, 0); if (bb != null) { } else { bass_boost.setVisibility(View.GONE); bass_boost_label.setVisibility(View.GONE); } updateUI(); } </code></pre> <p>For my AudioThread:</p> <pre><code> public class AudioThread extends Thread { // Handler message constants public static final int PLAY = 0; public static final int STOP = 1; // Class variables private boolean mRunning = false; private boolean mPlayAudio = false; private static class AudioThreadHandler extends Handler { private final WeakReference&lt;AudioThread&gt; mThread; public AudioThreadHandler(AudioThread thread) { mThread = new WeakReference&lt;AudioThread&gt;(thread); } @Override public void handleMessage(Message msg) { AudioThread thread = mThread.get(); if (thread != null) { switch(msg.what) { case PLAY: thread.mPlayAudio = true; break; case STOP: thread.mPlayAudio = false; break; } } } }; static final int bufferSize = 320000; final short[] buffer = new short[bufferSize]; short[] readBuffer = new short[bufferSize]; private final AudioThreadHandler mAudioThreadHandler = new AudioThreadHandler(this); @Override public void run() { try { int buffersize = AudioRecord.getMinBufferSize(11025, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT); AudioRecord arec = new AudioRecord(MediaRecorder.AudioSource.MIC, 11025, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, buffersize); AudioTrack atrack = new AudioTrack(AudioManager.STREAM_MUSIC, 11025, AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT, buffersize, AudioTrack.MODE_STREAM); atrack.setPlaybackRate(11025); byte[] buffer = new byte[buffersize]; arec.startRecording(); atrack.play(); mRunning = true; while(mRunning) { if (mPlayAudio) { arec.read(buffer, 0, buffersize); atrack.write(buffer, 0, buffer.length); }else { } } } catch (Exception e) { Log.e("AudioThread", "Thread Loop Exception: " + e); } } public void close() { mRunning = false; } public Handler getHandler() { return mAudioThreadHandler; } } </code></pre> <p>Sorry, everything may seem very messy. But this error have been stuck with me for a long time. Hope you guys could really help. Take a look at my project if you would and provide me the the instructions for things I've done wrong. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload