Hello boys.
I’m trying to develop an aar plugin for Unity writen in Java. Calling funcions from Unity work perfecly, so the plugin looks good.
I have the theorical aar folder structure and inside “res/raw/” there is a sound. Plugin builds good calling to that resource and makes a build failed when the sound name is different. But once compiled in the mobile i get a resource not found exception inside Java about that sound.
Any idea?
Thanks in advance.
Plugin code.
package com.nraboy.testplugin;
import android.content.Context;
import android.widget.Toast;
import android.media.MediaPlayer;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
public class ToastExample {
private Context context;
private static ToastExample instance;
private MediaPlayer mp = null;
public ToastExample() {
this.instance = this;
}
public static ToastExample instance() {
if(instance == null) {
instance = new ToastExample();
}
return instance;
}
public void setContext(Context context) {
this.context = context;
}
public void showMessage(String message) {
Toast.makeText(this.context, message, Toast.LENGTH_SHORT).show();
}
public void playSound(String message) {
Toast.makeText(this.context, message, Toast.LENGTH_SHORT).show();
try
{
mp = MediaPlayer.create(this.context, R.raw.sonar_slow);
mp.start();
}
catch (Exception e)
{
Toast.makeText(this.context, "ERROR: "+e, Toast.LENGTH_SHORT).show();
}
}
}
And the error:
