I have an android app where I am running native C++ code using JNI (Java Native Interface). I want to port it to codename one so that it can run on iOS as well. What is the alternative to JNI on codename one that will allow me to run my native C++ code?
You can call C++ from Objective-C we did just that in the ZXing demo for the iOS port see: http://github.com/codenameone/codenameone-demos
For Android you will need to wrap the C++ code using the NDK in order to use it. Chen discussed this a while back in a blog post here: http://www.codenameone.com/blog/integrating-android-3rd-party-libraries-jni.html
The relevant section is this:
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.
Notice that for Android you might want to use the new gradle build system which would also make this simpler: http://www.codenameone.com/blog/material-icons-background-music-geofencing-gradle.html
Codenameone has it's native interface that allows adding native codes.
Each platform has it's native code and as far as I know C++ is not in any of them.
I would suggest you translate your code from C++ to Java and Objective-C manually and you can use those code in implementing CN1 native interface.
Read about Native Interface here and also have a look at native demo
Related
I saw that most OPEN GL ES resources are written in java. And i don't know java. Can I make an android game using OPEN GL ES with c language? Is this possible? If possible, will I have trouble in compiling and similar situations?
Note:I want to make a 2d game for android.
Yes you can. Use Android NDK - native developer kit for C/C++ developers: https://developer.android.com/ndk
The Android NDK is a toolset that lets you implement parts of your app in native code, using languages such as C and C++. For certain types of apps, this can help you reuse code libraries written in those languages.
Example:
https://developer.android.com/ndk/samples/sample_na
The native-activity sample resides under the NDK samples root, in folder native-activity. It is a very simple example of a purely native application, with no Java source code. In the absence of any Java source, the Java compiler still creates an executable stub for the virtual machine to run. The stub serves as a wrapper for the actual, native program, which is located in the .so file.
I'm new to this topic and couldn't find any guides concerning this. I'm wondering how the Today Extension files from a xcode project (originated from the CN1 iOS debug build sources) needs to be added to the actual CN1 project in order to get integrated properly.
We don't have builtin support for that and didn't really study it. We never had official support for Android widgets either.
Both can be used through native code though. E.g. in this case you can use ios.plistInject to add the necessary plist changes. The actual UI/code that implements them should be done in a native interface anyway.
I've been trying to download the parse4j from Thiagolocatelli but they're missing version 1.5-SNAPSHOT which includes a third parameter for Parse.initialize(), but I can't download version 1.5-SNAPSHOT from github nor from Maven repository, people talk about version 1.5-SNAPSHOT but looking at the Maven repository: https://mvnrepository.com/artifact/com.github.thiagolocatelli/parse4j there is no version 1.5-SNAPSHOT. So is it possible to use parse4cn1 in non cn1 projects like Android Studio projects? Will library work?
It is possible to use parse4cn1 in a regular Java project as documented here. In fact, the parse4cn1 unit test application uses this approach successfully. As already mentioned by Shai, you'll have some dependencies on some CN1-specific functionality but that is available via the CN1 JavaSE port.
For Android, I'll recommend using the native Android Parse SDK directly. The API is slightly different from that of parse4cn1 but in most cases similar. Moreover, the SDK provides more functionality such as a local data store.
No.
The code uses ConnectionRequest and similar Codename One specific classes to implement parse support.
I have an eclipse codenameone project. I would like to execute this project on Eclipse using my own codenameone modified sources (codenameone sources project is in netbeans). How could I do that ?
As it is mentioned in this video, we should linked the project in the build path but it works only if we have a netbean project.
Better solution is to edit Codenameone source in Eclipse (but sources in github has structure of a Netbeans project).
Thanks!
Right now debugging with the Codename One sources is only supported on NetBeans because that is the platforms we use for our coding. It's harder to work with other IDE's and might not be worth your effort.
Someone posted a while back in the discussion forum about running this in Eclipse but I couldn't find the reference.
Generally if you want to build the native sources and debug from there just work based on the logic we have and adapt it to Eclipse (or any other IDE). Running a Codename One project has 2 major dependencies:
Codename One project - that's a regular Java project you can work with
JavaSEPort another regular project, this is the implementation of the Codename One code and includes the simulator.
Make sure to add the source trees of both these projects to the compile but not packaging phases and set the Simulator class as your main class.
If you are successful in doing this it would be really nice if you write about it for the developer guide wiki next to the NetBeans build and explain how this is done for future developers.
I have a program in C which i would like to call and use it in LibGDX so that i can use it both for android and desktop. So can you suggest me methods to call a C file into LibGDX?
To be clear, I believe you have an app written in Java that uses Libgdx currently, and you would like to extend that app by including a C library and making calls out to the C library from the Java application.
Libgdx does not provide any special support for third-party libraries, native or Java. You will have to use the backend platform's APIs to call out to native code (JNI, NDK, etc).
You should be able to add your library to the Android and Desktop backend projects, and access it via a Platform Interface. It is probably not possible to use the GWT-backend (unless you have a C to Javascript compiler). For iOS you would need to build your library for iOS, and then figure out how to link it into the Xamarin (or robovm) build process for your app. While I'm going to assume this is possible, I suspect neither is easy to accomplish.