运行 代号一上的本机 C++ 代码
Run native C++ code on codename one
我有一个 android 应用程序,我正在使用 JNI(Java 本机接口)运行宁本机 C++ 代码。我想将它移植到代号 one,这样它也可以 运行 on iOS。代号一上的 JNI 有什么替代方案可以让我 运行 我的本机 C++ 代码?
Codenameone 具有允许添加本机代码的本机界面。
每个平台都有自己的本机代码,据我所知,C++ 不在其中。
我建议您手动将代码从 C++ 翻译成 Java 和 Objective-C,然后您可以使用这些代码来实现 CN1 本机接口。
了解本机界面 here and also have a look at native demo
您可以从 Objective-C 调用 C++,我们在 iOS 端口的 ZXing 演示中就是这样做的,请参阅:http://github.com/codenameone/codenameone-demos
对于 Android,您需要使用 NDK 封装 C++ 代码才能使用它。 Chen 前一段时间在博客 post 中讨论了这个问题:http://www.codenameone.com/blog/integrating-android-3rd-party-libraries-jni.html
相关部分是这样的:
We recently added a 3rd option :aar files. The aar file is a binary format from Google that represents an Android Library project.
One of the problem with the Android Library projects was the fact that
it required the project sources which made it difficult for 3rd party
vendors to publish libraries, so android introduced the aar file which
is a binary format that represents a Library project.
To learn more about arr you can read this.
You can link an aar file by placing it under the native/android and
the build server will link it to the project.
请注意,对于 Android,您可能希望使用新的 gradle 构建系统,这也会使这更简单:http://www.codenameone.com/blog/material-icons-background-music-geofencing-gradle.html
我有一个 android 应用程序,我正在使用 JNI(Java 本机接口)运行宁本机 C++ 代码。我想将它移植到代号 one,这样它也可以 运行 on iOS。代号一上的 JNI 有什么替代方案可以让我 运行 我的本机 C++ 代码?
Codenameone 具有允许添加本机代码的本机界面。
每个平台都有自己的本机代码,据我所知,C++ 不在其中。
我建议您手动将代码从 C++ 翻译成 Java 和 Objective-C,然后您可以使用这些代码来实现 CN1 本机接口。
了解本机界面 here and also have a look at native demo
您可以从 Objective-C 调用 C++,我们在 iOS 端口的 ZXing 演示中就是这样做的,请参阅:http://github.com/codenameone/codenameone-demos
对于 Android,您需要使用 NDK 封装 C++ 代码才能使用它。 Chen 前一段时间在博客 post 中讨论了这个问题:http://www.codenameone.com/blog/integrating-android-3rd-party-libraries-jni.html
相关部分是这样的:
We recently added a 3rd option :aar files. The aar file is a binary format from Google that represents an Android Library project. One of the problem with the Android Library projects was the fact that it required the project sources which made it difficult for 3rd party vendors to publish libraries, so android introduced the aar file which is a binary format that represents a Library project.
To learn more about arr you can read this.
You can link an aar file by placing it under the native/android and the build server will link it to the project.
请注意,对于 Android,您可能希望使用新的 gradle 构建系统,这也会使这更简单:http://www.codenameone.com/blog/material-icons-background-music-geofencing-gradle.html