Problem linking .so and .lib on android studio - android

I'm having trouble linking some files to my project. It's an android studio project and I want to link one external file: "Emv_lib.so" (I know that are some questions on how to link .so files, but those are about internal .so files, this is an external one.)
Beside this file, I have an emv_lib.lib and emvIIapi.h (the header file that actually contains the functions that i need to call). I cannot get this to work. I tried with CMakeList, putting the emvIIapi.h file in there, but it comes with the error: "Execution failed for task ':app:configureCMakeDebug'.
C/C++"
I follow some suggestion, to create in src/main the folder jniLibs and put your .so files in there, but it didn't work.
From my undestanding, I have to compile, somehow, either the .so files or the .lib file.
I'm new to android studio, so don't go hard on me. Thank you for your time!

Related

Android how to extract *.so file during execution

I have one android myLibrary.jar file. But myLibrary.jar file will load the native 3 different so file. I have a.so, b.so and c.so.
When i using in my own application, it just simply put the jar file to the Android Dependencies and all 3 so files put in the libs/armeabi of the main application package.
When deploy and install on the device, these so file will be in the data/data/my-appname/lib/*.so.
Now i need to provide the sdk solution. The user side doesn't want the main application. They just want the myLibrary.jar. So i am considering about packing all 3 *.so files to the jar. I searched for the how to add to the so files to myLibrary.jar. But i still don't understand.
In this following post:
[Ant]How to add .so file into a jar and use it within jar(set the java.library.path)?
It mentioned about adding the so file to the jar and extract at runtime. But i still don't understand how to achieve that.
After trying that mentioned in the following post:
Creating a product SDK: How do I add a native lib (.so) and a jar with the SDK I am creating?
After my sample application reference the the compiled jar that included the .so file. After installing to the device, the libs/armeabi/xxx is not unpacked on the install. So i would like to know how to extract them dynamically and save them to data/data/my-appname/lib/ so that i can use with System.loadlibary(.so).
Thanks a lot.

Adding external cpp files to Android Studio JNI

I have an Android project setup in Android Studio.
I'm using NDK and JNI so I have some cpp/h files in the jni folder. I can use them and everything is fine.
I also have another folder somewhere in my harddrive (which is not under the Android project root folder) with more cpp files.
So in Android.mk I added the path to both local (jni folder) files and the external files directory path. Everything compiles and everything works fine.
The issue I'm having is how to actually link to those cpp files in the external folder so I can actually edit them inside Android Studio or at least see the functions and member names. Currently I edit those files in notepad++ save and then go back to Android Studio to call the methods etc.
The external folder is simply a folder with some cpp files inside. It's not a module, it does not have a build.gradle or anything like that.
Is what I'm asking even possbile?
I hope the question was clear enough. Any help is appreciated!
Thanks

How can we know which .so file a particular cpp file is in? (in Android rom)

I found some modified code in a cpp file in android to protect smartphone from stagefright vulnerability.
I want to change it with original cpp file and rebuild to a new android ROM file.
The problem is,
I downloaded an android factory image from google developer forum and
I unpacked it with android kitchen tool.
Now I can see its contents but I couldnt find the file, I wanted to modify, "/media/libstagefright/MPEGExtractor.cpp".
There are only some .so files in system/lib/ folders.
I heard it's almost impossible to decompile those .so files.
I tried googling to find out which .so files have "MPEGExtractor.cpp", so that I would be able to compile some files including that cpp file into a .so file, and change it, and rebuild it a new ROM.. but I couldn't find out.
What should I do to rebuild it with some code to be changed?
Thank you for reading
SO(Shared Object) are files that are compiled from source. By definition they do not contain the symbol information you are asking for.

Use already developed android project [with its resources(xml, images, layout)] into another project directly as .xyz file

I have read lots of questions on this site and come to the decision that if you wish to use your already developed code with its resources in android then you have to use it as a library.
But from the Building Android applications with Gradle tutorial I read something like...
Gradle supports a format called Android ARchive (AAR) . An AAR is similar to a JAR file, but it can contain resources as well as compiled bytecode. This allows that an AAR file is included similar to a JAR file**.
Does it means that we can use .aar file as an .jar file but with facility of using resources also?
Then I have tried to crate .aar file with the help of Android Studio, but .aar file doesn't contain layout XMLs or images -- it contains some layout and resources but it doesn't contain projects other resources file.
At last I am having the only same, annoying, stupid question: Can we use whole project with its resources with only one file like .jar or .aar or any other file format?
RajaReddy is quite mistaken. The JAR contains only code; you cannot access resources that way.
Google distributes their own "Google Play Services Library" as an Android library project, containing the binary code in a JAR file in the lib directory, the resources in the res directory, and an UnusedStub class in the src directory. If a better approach were viable yet I think they'd be using it.
UPDATE: While Android Studio is still in beta, it includes (buggy) support for AAR files. Seems this will eventually be the way to go.
Library projects bin folder contains jar file, copy that jar file in your main Application ( project ) libs folder we can get all the resource folders like this.
Follow these steps !
1) make your library project a normal project by deselecting IsLibrary flag.
2) Execute your project as Android Application. (It will not show any error)
3) you'll find a .jar file in bin folder..
4) Copy .jar in libs folder of your main application.
this will works fine with all the resources.
I was looking for the same thing for years. Combining byte code of java and resources (xml and other files) into one package. Currently I don't think its possible because even google has to include add resources separately in google play services lib available in the SDK .
What you can do best is generate a .aar or .jar file and add a folder of missing resource files.

Adding .so files to Android project

I am trying to add SQLCipher to my project. I am able to link the jar files to the project but there is problem linking the .so files provided.
Due to that I am getting UnSatisfiedLinkError when i try to open the DB.
Can anyone please let me know the best possible way to add .so files to the project and get it running.
In addition to jar files you need to include .so files. In my project I have:
jar files in project_root/libs/
.so files in project_root/libs/armeabi/
Also make sure that you have added the .jar files properly. Go to Project Properties -> Java Build Path -> Libraries tab make sure commonc-codec.jar, gueva-r09.jar, sqlcipher.jar are added there.
EDIT
1) Add a single sqlcipher.jar and a few .so’s to the application libs directory
2) Update the import path from android.database.sqlite.* to info.guardianproject.database.sqlite.* in any source files that reference it. The original android.database.Cursor can still be used unchanged.
3) Init the database in onCreate() and pass a variable argument to the open database method with a password*:
SQLiteDatabase.loadLibs(this); //first init the db libraries with the context
SQLiteOpenHelper.getWritableDatabase(“thisismysecret”):
Can you use the adb shell command to verify what files are being deployed to your simulator after it has been unpacked. I have seen an issue where the .so files are not packaged up in the .apk file before, which is due to the IDE not pointing to the correct native library path for your application.

Categories

Resources