繁体   English   中英

找不到奇怪的资源问题?

[英]Strange resource not found issue?

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

我可能是错的,但听起来资源不是您自己的文件之一。 并且您正在使用手机资源。 我知道您在编译的APK中声明了它,但我认为您应该仔细检查一下

如果是这种情况,则您使用的资源是一个,不保证在Android手机上。 在某些设备中也是如此。

解决方案是将其复制并将其放在您自己的资源文件夹中,以便将其打包到APK中并分发到安装您的应用程序的任何电话中。

如果它已存在于您的APK中,但又是一种电话资源,请确保它正确指向了APK中的那个资源,而不是手机的位置。

您可能想尝试将音频文件放入“资产”文件夹。 然后使用AssetManager来访问文件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM