这是我第一次尝试转换一些 Jni 桥。但是,我在转换某些数据类型时遇到了一些麻烦。
第一个与此自动生成的标头有关:
每次我尝试重新编译(没有原始 .pas 文件,一旦我无法再编译(IDE 限制))我在以下行中遇到一些错误:
/* TJavaImport.Create */ inline __fastcall TJToast(void * ID, void * ClsID, Androidapi::Jnibridge::TJavaVTable* VTable) : Androidapi::Jnibridge::TJavaGenericImport__2<_di_JToastClass,_di_JToast> (ID, ClsID, VTable) { }
错误:
[bccaarm 错误] Androidapi.JNI.Toast.hpp(76):没有匹配的构造函数用于初始化 'Androidapi::Jnibridge::TJavaGenericImport__2<_di_JToastClass,_di_JToast>' Androidapi.JNIBridge.hpp(197):候选构造函数不可行:需要0 个参数,但提供了 3 个参数
Androidapi.JNIBridge.hpp(174):候选构造函数(隐式复制构造函数)不可行:需要 1 个参数,但提供了 3 个参数
另一个与
我正在使用一个已经实现 getBonded() 的库,但是一旦我无法再使用 .pas 文件,我必须手动实现它,所以我明白了:
void getBonded(TStringList* res){
JBluetoothAdapter* x;
JSet* externalDevices;
JIterator* it;
JBluetoothDevice* o;
JBluetoothDevice* remote;
JBluetoothSocket* xx;
x = TJBluetoothAdapter::JavaClass->getDefaultAdapter();
externalDevices = x->getBondedDevices();
it = externalDevices->iterator();
while (it->hasNext()){
o = TJBluetoothDevice::Wrap(it->next()::ILocalObject::GetObjectID());
res->Add(JStringToString(o->getName())+"="+JStringToString(o->getAddress()));
}
}
但我在以下行中收到错误:
o = TJBluetoothDevice::Wrap(it->next()::ILocalObject::GetObjectID());
错误:
[bccaarm 错误] Main.cpp(2423): 预期 ';' 在声明结束时 [bccaarm 错误] Main.cpp(2424): call to 'Wrap' is ambiguous
Androidapi.JNIBridge.hpp(187): 候选函数
Androidapi.JNIBridge.hpp(188): 候选函数
所以我将最后一个更改为(但尚未测试):
o = TJBluetoothDevice::Wrap(it->next()->IJavaInstance);
从现在开始,非常感谢你;