我使用統一這個C#代碼來訪問Java類時,.aar LIB:獲得AndroidJavaException在Unity試圖調用類的構造函數
AndroidJavaClass ajc;
private AndroidJavaObject ajo;
// Use this for initialization
void Start() {
ajc = new AndroidJavaClass("com.example.pc.superpoweredsdk.SuperPoweredPlayerWrapper");
ajo = ajc.Get<AndroidJavaObject>("currentActivity");
}
但我在Android上得到這個錯誤的logcat:
AndroidJavaException:java.lang.NoSuchFieldError:no「Ljava/lang/Object;」類「Lcom/example/pc/superpoweredsdk/SuperPoweredPlayerWrapper;」中的字段「currentActivity」或其超類 07-01 12:31:08.640 1467 1485 I Unity:java.lang.NoSuchFieldError:no「Ljava/lang/Object;」類「Lcom/example/pc/superpoweredsdk/SuperPoweredPlayerWrapper;」中的字段「currentActivity」或其超
這是Java類和功能我試圖撥打:
public class SuperPoweredPlayerWrapper {
public SuperPoweredPlayerWrapper(Context context) {
int sampleRate = 44100;
int bufferSize = 512;
AssetFileDescriptor fd = context.getResources().openRawResourceFd(R.raw.lycka);
int fileOffset = (int)fd.getStartOffset();
int fileLength = (int)fd.getLength();
try {
fd.getParcelFileDescriptor().close();
} catch (IOException e) {
android.util.Log.d("", "Close error.");
}
SuperpoweredPlayer(sampleRate, bufferSize, context.getPackageResourcePath(), fileOffset, fileLength);
}
private native void SuperpoweredPlayer(int sampleRate, int bufferSize, String apkPath, int fileOffset, int fileLength);
public native void playPause(boolean play);
public native void setTempo(double value);
static {
System.loadLibrary("SuperpoweredExample");
}
}
如何調用這個類的構造函數與團結方面的參數?
感謝響應,現在情況下,團結成功找到函數,並呼籲他們 –