I have this demo project: http://www73.zippyshare.com/v/74674979/file.html which I got for using http://www.aclas.tw/Products/AO1X/ .
My problem for using this is in the documentation. Which does not exist.
I understand how the Java part of the code works but I don't know how to implement this in my project.
I downloaded and installed ndk hoping I would be able to run the project but it crashed at the most important part:
System.loadLibrary("AclasArmPos");
I don't know what to do and there is no description on how to use it. Except the code itself which I cannot run.
Place the .so files under jni/libs. If you have .so files for multiple architectures, create folders like x86, armv7a within the jni folder and place the .so files in the corresponding folder. If you are using Android studio, the steps to follow are slightly different. Can you provide more details?
Related
I'm trying to build a template Android app using Grammatical Framework's Java bindings (however, I don't think what Java code I'm using in particular actually matters. Let's just say I'm trying to use some external non-Android Java code in an Android app).
After some trial and error, I got to successfully build an app using this external code by following these steps:
generating a .jar file for the library I want to use (it's called jpgf.jar
copying it to app/libs
adding it as a library and verifying that the build.gradle gets updated with
implementation files('libs/jpgf.jar')
importing it in my app's MainActivity and writing some code that uses it
However, nothing can be easy in Android development, ever. So my app, after nicely compiling, crashes on startup with the following error:
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/bho.harisont.gfdemo-8c870hpW06uEnMQHV1ILjw==/base.apk"],nativeLibraryDirectories=[/data/app/bho.harisont.gfdemo-8c870hpW06uEnMQHV1ILjw==/lib/x86, /system/lib, /system/product/lib]]] couldn't find "libjpgf.so"
In short, some .so file can't be found. Now, I'm not Java or .so file expert, but I do know that when I installed jpgf system-wide on my machine using the dedicated Makefile, a .so file was generated and copied to some location. My probably naive attempt was to take that .so file and move it to the appropriate subfolder of jniLibs. I know I placed it in the correct folder and all, because in this way I managed to change the error message, but not to solve the problem: at this point the complaint is that libjpgf.so is 64 instead of 32 bits. You bet, my machine is 64 bits.
So, to help me you can answer one both of these questions:
how do I compile a 32 bit version of the .so file on a 64 bit machine? I tried some gcc options but it's not like that helped
do I actually need that prebuilt .so file? I see other people just importing JARs. Can I not just do that (or even import the source code somehow), and have Android Studio generate all the assets it wants the way it wants?
How can I Run a .jar file in Java so that I can see the results? I this I will need to use Android Studio but I have no idea on how to do it. Please help.
To use class and method in .jar library file in android you have to use it as a module.To do this follow below steps
copy .jar file
navigate to android studio "project" folder
paste copied .jar to libs folder
right click on pasted file and click add as library
Android uses ART not JRE. So it can't run .jar files.
It is possible to run jar files in Android. But the problem is, it's possible using command execution and Root is needed to do that. A perfect example is this Apktool (Android) with Source Code
I'm trying to download jsoup on my mac (Mountain Lion). I've downloaded the jsoup.jar file and installed the last java 7 from the site. But here is the problem, when I double click the .jar file it tells to me:
The Java JAR file “jsoup-1.7.2.jar” could not be launched. Check the
console.
I can't find even the console! Someone can help me? I read a lot of answers about this topic, but they all talk about Java 6 and it has different settings that can't find.
EDIT
i also tried from the terminal with this command:
java -jar /Users/Ben/Downloads/jsoup-1.7.2.jar
but it tells me:
Failed to load Main-Class manifest attribute from
/Users/Ben/Downloads/jsoup-1.7.2.jar
The JSoup JAR is not executable, so you are not going to be able to 'run' it in any of the ways you described. You are supposed to include it in your project classpath and use classes from it to do your parsing (after importing them of course).
You might want to refer to the JSoup Guide for examples on using the library.
I guess you are trying to run the jsoup library as a standalone application assuming it to be an executable jar. All indicates that the jar file you are using is NOT an executable jar hence it wont work.
jsoup.jar is supposed to be used as a java library and you will need to write java code to be able to use the HTML parsing capabilities.
If you are using an IDE like IntelliJ, you can open the module settings for a particular project and select Libraries. There'll be an option to add a particular external library from the Maven repository after which you can download the JAR and include it in your project's dependencies.
I've looked through a number of posts, and tried what I've found to little success. Here's the setup:
I wrote a program in Java, worked alright, but we needed to switch cameras. This camera is Twain compatible (yuck). I rewrote the program (pretty simple), using JTwain, and it runs just fine in netbeans. I built it, and it runs just fine on my computer. However, when I try and transfer the .jar (and companion library etc.), it runs fine until it needs to take an image, then I get the error:
java.lang.UnsatisfiedLinkError: no aspireJTwain in Java.library.path.
I've tried bringing the base twain package over, adding the system environmental variables, checking the java distribution. I can run the JTwain test file (to make sure you have JTwain and everything is hunky dory).
If someone could please lend a hand, I'd be much obliged.
Can you check to make sure that you have followed the directions from the The Java Developer's Guide to JTwain v9.
6.3 Software Packaging and Distribution
There are two files about JTwain you need to distribute along with
your own binary code. One is JTwain.jar, which is like any other java
library, you can just copy it and put it in the class path. The other
one is AspriseJTwain.dll, the native library. There are many ways to
'install' this dll file, you can: Add the folder containing the
native library to the system path, or Copy the native library to
jre/bin directory – 'install' the library to the JVM, or Copy the
native library to a specific location, e.g. C:\AspriseJTwain.dll,
before calling SourceManage.instance(), call:
SourceManage.setLibraryPath(“ C:\AspriseJTwain.dll ”);
We have a class library, written in Java (Standard Edition or MIDP 2.0, we have both variants), compiled to JAR file. There's nothing special in that library, mainly work with sockets (TCP and UDP) and threading.
Now we need to ensure, that this library will work on Android, and fix linkage problems (such as classes or methods missing on Android).
Is there a way to "validate" generic JAR file for Android without writing a complicated test case and running it on Android? I imagine something that I can pass the JAR to and it will tell me "could not load JAR - method X not found in class Y".
Found the solution. If you have a JAR file which you want to check for basic compatibility with Android's libraries, you need to do the following:
Create an android project
Add a JAR file as an external JAR to the list of project libraries.
Attempt to build the project.
If the JAR references missing classes, you will get an error immediately during building.
Is there a way to "validate" generic JAR file for Android without writing a complicated test case and running it on Android?
I would hope that somebody with your SO karma would not try to ship a JAR for Android without actually "running it on Android".
That being said, there's no good way that I can think of to perform your validation at the JAR level. However, if you pour your source code into an empty Android project, you will get compile errors if you refer to classes or methods that do not exist.