I have an Android POS device that's equipped with a fingerprint scanner. They have a .jar library which is meant to help develop Android apps to access the fingerprint component in the device. I included the jar file in the lib folder of the NetBeans codenameone project and also in the native/android directory.
But when I run the application on the device after building on the build server, the application throws a NoClassDefFoundError. But the class is in the jar file.
You may need to treat it like a native interface, which is actually pretty easy. You just create an interface with all of the method signatures you need, right click on it, and select generate native. Then in the native sub folder there will be an Android directory. You can drop the jar file in there and in the stub file that ends with "impl", you implement the interface methods to call the methods in the jar.
The downside of that is that the auto-code completion won't work. Since you're using Netbeans, if you do the above you should then be able to compile it into a CN1LIB. That can be then placed in your libraries and the code completion will work.
Check the developers guide in the Advanced Topics Under The Hood section, and there's a tutorial video also.
Related
In wso2 iot document : (https://docs.wso2.com/display/IOTS320/Integrating+the+Android+System+Service+Application)
((The system service app can not be built via the usual android developer SDK, as it requires access to developer restricted APIs. Therefore, you need to replace the existing android.jar file that is under the /platforms/android- directory with the explicitly built android.jar file that has access to the restricted APIs.
Download the Android Open Source Project (AOSP) and build the source code to get the jar file for the required SDK level.))
I did not understand how to generate the android.jar file. I studied Linki, but I did not see any clear information about it.Please help me.
If you need to call a hidden API, you need to import a jar with full APIs, the jar in SDK is a incompleted one which all hidden APIs are disappeared.
#madawa's answer should works fine for normal application programming.
If you are a programmer coding for a modified AOSP, and this AOSP add some private special APIs, you need to import the jar which is build by the AOSP, the path is: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes-full-debug.jar.
And remember, the hidden APIs are not guaranteed to stay forever, they may be changed or removed. So if you app needs to run on different API levels, you need to import all the different jar and do the level check.
You can find the required jar in the following repository.
https://github.com/anggrayudi/android-hidden-api
I am writing a program which I would like to deploy as both desktop and android applications. I want to use JavaFX 2.0 with FXML for the desktop side of things. I want to work entirely in Android Studio. Right now, I am just concerned about producing an desktop executable (for Windows to start with) for my JavaFX program. I'd like to produce an .exe file if possible, or at least a .jar.
To clarify, I am not asking how to go about deploying/compiling an existing JavaFX project for Android. I know there exists something called JavaFXPorts for that. I just want to compile and deploy a regular JavaFX program using Android Studio, totally ignoring anything to do with Android for now. (If JavaFXPorts somehow helps with this, then by all means, please show me how).
So far, I've managed to create a regular Java application in Android studio, add in some 'hello world' JavaFX files, and (sort of) deploy the program.
There are many questions squeezed into this one SO question.
I don't know where to put my FXML files so that my final Jar file can find them. I think I have to get gradle to copy them to the build directory, but I don't know what the standard way of doing this is. Do I need to put my FXML files in a 'resources' or 'assets' directory? How do I write a gradle script to copy the files over? Should I refer to the FXML files directly, or through the resources system?
It seems that IntelliJ does this automatically using compiler resource settings, but Android Studio is missing this functionality (probably because it assumes I only want to create an Android app, so only need to use the Android resource system).
Just as a reminder, the entire relevant part of my project is located in a 'Java Library' module in the Android Studio project.
I've created an test project which I've uploaded here: https://github.com/Aralox/Android-Studio-FXML-Executable-JavaFX-Project
Here are a few screenshots:
Complaints about a missing 'resources/main' directory. This probably has something to do with the JavaFX gradle script I copied from here. I manually added in this directory for the program to compile (super hacky).
My program couldn't find the FXML file it was looking for because of a change in working directory (hacky way of finding the FXML because using getClass().getResource() did not work, because the FXML was not copied to the output directory).
Final program working after I manually copied the FXML file into the build directory (and told the program where to find it).
I know this was a long question, but I hope I've made my essential problem clear. The 'child' questions are just problems I encountered in my attempt to find a solution. Thank you very much for the help!
I am trying to communicate to Arduino with Java, so I'm using the rxtx library. I've downloaded the library and placed the respective files in my java project's folder. I put the rxtxxjar in a lib folder in the java project's folder, and I left the serial.jnlib straight into the java project's folder. I've taken the SerialTest code off of the arduino website, and I've tried to run it but I keep getting the UnsatisfiedLinkError. I've researched this question, and I've seen people saying basically the following in different ways:
Go to Project -> properties -> Java build path ->Find your .jar. Click
on + to open the JAR's properties. Select Native library location and
edit it to point to RXTX's shared library (.DLL, .so, .dylib).
However, I have no idea how to do the pointing to the shared library, especially since I don't see any .dll, .so, or .dylib file, and I cannot use the .jnlib because it is greyed out. Also on a smaller note, by my .jar is that just the project? I work in Eclipse Java EE.
You can use
System.load("Absolute path to your jni library");
This works fine on my project.
I have a create an android library project which has to be given to a 3rd party application,I have two requirements,
1)convert the library project into a jar file (or),
2)Make the source code in the library project obfuscated.
Basically i dont want to 3rd party application developer to get my source code.
Please help! thanks in advance!
The ProGuard-Application lets you shrink and obfuscate your code. It is from the Android developers, so you can assume it is safe to use it.
This is the closest that you can get:
1: Create a regular Android library project, and get it working.
2: Copy that Android library project into another directory.
3: Create a JAR from the compiled Java classes from the original Android library project, and put that JAR in the libs/ directory of the copy you made in Step #2. You should be able to run ProGuard on this JAR manually, though I haven't tried that.
4: Remove everything inside the src/ directory of the copied library project, leaving behind and empty src/ directory.
5: ZIP up or otherwise distribute the copied Android library project.
This is what you need to do:
Create your library project. Write a test application that tests your library. Build your library project. You could use ant/maven through eclipse. Most libraries now need gradle support because applications are now using Android Studio. Mark your project as a library by going to Project -> Properties -> Android and select the Is Library checkbox. Check this link: http://developer.android.com/tools/projects/projects-eclipse.html.
If you don't want a 3rd party app developer to see your source files, you need to enable proguard. This tool shrinks, obfuscates your code. The application that uses your library has a lot of control over what code needs obfuscation. For example, an application can decide that it wants all packages starting with com.blah.blah* to not be obfuscated by specifying the -keep option in its proguard config file. This will prevent certain sections of code from getting obfuscated. You should allow default obfuscation for libraries unless you decide to use components which don't function with obfuscation (like annotations or reflections).
By enabling proguard, a third party developer will not get access to your source on reverse-engineering your apk. Use wisely!
I have made a java application in Eclipse and it has a Main class which has the main method from which the application runs. I want that i should be able to run the application from outside the eclipse maybe by clicking on some icon.
Can anyone guide how that might be possible?
Create a Java .exe/.jar file
Create JAR file in Java & Eclipse
JAR file using Eclipse IDE
Right click on your project, which you want to create a JAR file of. And select Export from the context menu.
Select JAR file from Java folder and click Next.
Provide the Destination path and click on Finish to create the JAR.
You should build the application first,then you'll find a file with the extension ".jar" in the project's directory
you can run this jar anywhere
Once you have a Jar, you might also deploy the app. using Java Web Start.
JWS can do desk-top integration tasks like providing a desktop icon (with customized icon) and/or menu item. JWS also offers many other nice features like configurable automatic update & file associations, and offers a comprehensive API that is only available to JWS apps. The JNLP API makes persistence, single instance code and other things easy.