- Home /
Android plugin loading resources problem
Hi! I'm trying to implement android audio plugin for Unity in order to avoid high latency when playing back sounds. In order to load and play songs i use SoundPool Java class. The main problem is, that i'm unable to load any kind of sounds, because of occuring errors in logcat while deploying app on device.
Here is Java code of loading method
public void loadSound ()
{
soundId = load(mContext, mContext.getResources().getIdentifier("menubutton", "raw", mContext.getPackageName()), 1);
}
mContext is Context received from class, that extends UnityPlayerActivity.
By invoking loadSound() method from Unity the following error occurs:
W/ResourceType(13607): No package identifier when getting value for resource number 0x00000000 I/Unity (13607): AndroidJavaException: android.content.res.Resources$NotFoundException: Resource ID #0x0 I/Unity (13607): at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in :0 I/Unity (13607): at UnityEngine.AndroidJNISafe.CallVoidMethod (IntPtr obj, IntPtr methodID, UnityEngine.jvalue[] args) [0x00000] in :0 I/Unity (13607): at UnityEngine.AndroidJavaObject._Call (System.String methodName, System.Object[] args) [0x00000] in :0 I/Unity (13607): at UnityEngine.AndroidJavaObject.Call (System.String methodName, System.Object[] args) [0x00000] in :0 I/Unity (13607): at AudioCenter.loadSound () [0x00000] in :0 I/Unity (13607): at Example.OnGUI () [0x00000] in :0
I've tried a lot of variations of getting resource Id, but all of them were unsuccessful.
Maybe somebody of you has already faced such problem, so i'll be glad to get some help in solving it. Thanks!
Answer by Yury-Habets · Dec 22, 2014 at 07:41 PM
In order to correctly merge resources, please consider using an Android Library project (you are probably providing a single jar file, don't you?). For more details, refer to http://docs.unity3d.com/Manual/PluginsForAndroid.html