我似乎有一个非常奇怪的问题,当应用程序在我的测试手机上运行时,它完美地工作,并通过soundpool在按钮按下播放原始文件夹中的声音,但是当我将应用程序提交到测试后,它在120多个设备上崩溃,出现'资源未找到'奇怪的资源未找到问题?
代码如下:请注意,该文件实际上存在于R文件中,已编译的APK文件中,我也清理过无数次。
http://www.appthwack.com/public/FUVGFZn42q
'01-03 21:09:36.828 26762 26762 W System.err: java.lang.RuntimeException: Unable to start activity ComponentInfo{appinventor.ai_Broak.PaintballWiz/com.muo.paintballwiz.PaintballWiz}: android.content.res.Resources$NotFoundException: File res/raw/pballshot.ogg from drawable resource ID #0x7f050000 - 1 occurrence'
soundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 100);
//soundPoolMap = new SparseIntArray();
soundPoolMap = new HashMap<Integer, Integer>();
// soundPoolMap.put(soundID, soundPool.load(this, R.raw.midi_sound, 1));
int myAudioFile = getResId("pballshot", R.raw.class);
soundPoolMap.put(soundID, soundPool.load(PaintballWiz.this, myAudioFile, 1));
audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
curVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
leftVolume = curVolume/maxVolume;
rightVolume = curVolume/maxVolume;
soundPool.play(soundID, leftVolume, rightVolume, priority, no_loop, normal_playback_rate);
soundPool.play(soundID, 0, 0, 1, -1, 1f);
奇怪的是,当我将代码从oncreate移动到on按钮时,按下了崩溃停止? 0.o – Broak
有趣的..并不是所有的Android设备都是平等的,可能是因为在创建时它只是被称为太早。如果你想要的话,多发一些代码,如果没有更全面地了解发生的事情,很难提供更多的帮助。 – simsam7