我似乎遇到了一个非常奇怪的问题,当应用程序在我的测试手机上运行时,它运行良好,并且在按下按钮时通过 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);