我無法爲ffmpeg調用Android java庫的某些方法。我想我successfuly加載庫,因爲我可以CONSOLE.LOG庫對象:如何在Nativescript中實現Java方法?
JS: BuildConfig -> function() { [native code] }
JS: ExecuteBinaryResponseHandler -> function() { [native code] }
JS: FFmpeg -> function() { [native code] }
JS: FFmpegExecuteResponseHandler -> function() { [native code] }
JS: FFmpegLoadBinaryResponseHandler -> function() { [native code] }
JS: LoadBinaryResponseHandler -> function() { [native code] }
這是多遠我得到了(using this nativescript guide):
// [...]
var MyCustomLoadBinaryResponseHandler =
com.github.hiteshsondhi88.libffmpeg
.LoadBinaryResponseHandler.extend({
onStart: function() {
console.log('Started loading ffmpeg');
},
onFailure: function() {
console.log('Failed loading ffmpeg');
},
onSuccess: function() {
console.log('Successfully loaded ffmpeg');
},
onFinish: function() {
console.log('Finished loading ffmpeg');
}
});
console.dir(MyCustomLoadBinaryResponseHandler);
//^ this logs the following
//~ JS: === dump(): dumping members ===
//~ JS: "()function() { [native code] }"
//~ JS: === dump(): dumping function and properties names ===
//~ JS: extend()
//~ JS: null()
//~ JS: === dump(): finished ===
var context = app.android.context;
var ffmpeg =
com.github.hiteshsondhi88.libffmpeg.FFmpeg.getInstance(context);
console.dir(ffmpeg);
//^ this logs the following
//~ JS: === dump(): dumping members ===
//~ JS: {
//~ JS: "constructor": "constructor()function() { [native code]
//}"
//~ JS: }
//~ JS: === dump(): dumping function and properties names ===
//~ JS: constructor()
//~ JS: concatenate()
//~ JS: execute()
//~ JS: getDeviceFFmpegVersion()
//~ JS: getLibraryFFmpegVersion()
//~ JS: isFFmpegCommandRunning()
//~ JS: killRunningProcesses()
//~ JS: loadBinary()
//~ JS: setTimeout()
//~ JS: <init>()
//~ JS: clone()
//~ JS: equals()
//~ JS: finalize()
//~ JS: getClass()
//~ JS: hashCode()
//~ JS: notify()
//~ JS: notifyAll()
//~ JS: toString()
//~ JS: wait()
//~ JS: === dump(): finished ===
ffmpeg.loadBinary(
new MyCustomLoadBinaryResponseHandler()
);
var MyCustomExecuteBinaryResponseHandler =
com.github.hiteshsondhi88.libffmpeg
.ExecuteBinaryResponseHandler.extend({
onStart: function() {
console.log('Started running ffmpeg');
},
onProgress: function(thisMessage) {
console.log(' ffmpeg running');
console.log(thisMessage);
},
onFailure: function(thisMessage) {
console.log('Failed running ffmpeg');
console.log(thisMessage);
},
onSuccess: function(thisMessage) {
console.log('Successfully run ffmpeg');
console.log(thisMessage);
},
onFinish: function() {
console.log('Finished running ffmpeg');
}
});
//this is where it crashes
ffmpeg.execute('-version', new
MyCustomExecuteBinaryResponseHandler());
不幸的是,整個應用程序崩潰,沒有錯誤信息的應用程序,我不能連續除非我有更多關於正在發生的事情的信息。我是否以錯誤的方式實施了這些方法?你如何建議我繼續?
編輯:這些是最後日誌控制檯
09-06 11:22:58.884 31522 31522 F art : art/runtime/java_vm_ext.cc:470] from java.lang.Object com.tns.Runtime.callJSMethodNative(int, int, java.lang.String, int, boolean, java.lang.Object[])
09-06 11:22:58.884 31522 31522 F art : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.callJSMethodNative(Native method)
09-06 11:22:58.884 31522 31522 F art : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1043)
09-06 11:22:58.884 31522 31522 F art : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.callJSMethodImpl(Runtime.java:925)
09-06 11:22:58.884 31522 31522 F art : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.callJSMethod(Runtime.java:912)
09-06 11:22:58.884 31522 31522 F art : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.callJSMethod(Runtime.java:896)
09-06 11:22:58.884 31522 31522 F art : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.callJSMethod(Runtime.java:888)
09-06 11:22:59.021 31522 31522 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethodNative(Native method)
09-06 11:22:59.021 31522 31522 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1043)
09-06 11:22:59.021 31522 31522 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethodImpl(Runtime.java:925)
09-06 11:22:59.021 31522 31522 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethod(Runtime.java:912)
09-06 11:22:59.021 31522 31522 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethod(Runtime.java:896)
09-06 11:22:59.021 31522 31522 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethod(Runtime.java:888)
09-06 11:22:59.022 31522 31522 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethodNative(Native method)
09-06 11:22:59.022 31522 31522 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1043)
09-06 11:22:59.022 31522 31522 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethodImpl(Runtime.java:925)
09-06 11:22:59.022 31522 31522 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethod(Runtime.java:912)
09-06 11:22:59.022 31522 31522 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethod(Runtime.java:896)
09-06 11:22:59.022 31522 31522 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethod(Runtime.java:888)
的JavaScript不是Java – Acidic
如果您沒有看到錯誤的活動,那麼它是一個JNI除外,它只能在亞行logcat進行跟蹤。但是,這可能會在nativescript論壇中找到更好的答案。另外,共享可以複製問題的存儲庫將是理想的。 – pkanev
實際上,在控制檯上有特定消息,JNI例外可能如您所建議的那樣?我將它們包含在 –