Tools for optimizing Shared LIbraries (.so) for ARM32 and ARM64 - android

Is there any possibility to take .so and run it through tool which can optimize further that code for runtime?

Related

Android studio - Call to function from dll file or lib file

I have a lib and dll files (I can choose which file I want to use)
I want to call to functions that are inside the file.
The code that complied in dll/lib wrote at c
dll files (unless the dll is a dot.net dll and you are in a Xamarin app) are not usable in Android.
Furthermore DLL files typically are compiled for x86 (32bit) or x86_64 (64bit) CPUs. The number of Andorid devices with an x86 CPU is next to zero, for Android you need the library compiled for ARMv7 (32bit) and ARMv8 (64bit). As Android is Linux based you need .so files in stead of .dll files.
To make development easier you should install Android Studio + Android NDK (Native Development Kit). Then you have everything for compiling c code in a way that you can make use of it within an Android app.
Google provides multiple sample projects that show how to use NDK: https://developer.android.com/ndk/samples

Using ubuntu header lib in android ndk

I am building an open source lib C/C++ for Android development using Android NDK. I had got code from Github and created my own jni folder under source code. In that jni folder, I created some C source files and included many header files in open source lib. But when I built, I had got failed log:
fatal error: bits/libc-header-start.h: No such file or directory
I checked and saw that file "libc-header-start.h" existed in /usr/include/x86_64-linux-gnu/bits/ folder of Ubuntu system but when building, it can not link to that header file
So can I use Ubuntu system header file in my Android NDK lib?
No, you should not use Ubuntu (or any other host) includes or libs to build an Android NDK library. NDK cross-compiles your code for the Android targets. Not all C++ projects on GitHub may be ported easily to Android. If they use CMake, these scripts often need adaptations for Android NDK. If they use automake tools, tuning the build scripts may be quite painful.
So can I use Ubuntu system header file in my Android NDK lib?
NO. You have to use all the Android NDK specific headers and libs for your NDK compilation, i.e. those inside your NDK folders.
Here is an example for Android JNI programming: https://github.com/russell-shizhen/JniExample

How to limit renderscript to specific native platforms in Eclipse

I am using Eclipse to build an Android app that uses Renderscript. I include
renderscript.target=18
renderscript.support.mode=true
in my project.properties file.
Everything is running fine except that by default, Eclipse creates an apk which has a directory for all three platforms supported by Renderscript: x86, mips, armeabi-v7a. However, I am only supporting armeabi-v7a (the x86 and mips directories only contain the two .so files for Renderscript). This becomes important when publishing to the Google Play store, which uses the directories to figure out what native platform the app supports.
How do I specify that the x86 and mips platform directories should not be created?
After your apk has been generated, you can use the zip command:
zip -d your.apk path_or_files_to_be_removed_inside_the_apk
Note that you will need to sign again your apk after altering its content.
I would strongly recommend you to migrate to Android Studio where you will find more flexibility with gradle. Eclipse is not supported officially anymore.

Android NDK Debug Library

I have a Java Android application project that includes a so library in libs/armeabi folder.
The c++ code of this library is in a different Android NDK project and is dependent on other different library NDK projects.
Is it possible to debug the c++ code of this library while the Java Android application is running?
In order to debug the native code in .so, first you need .so that was generated with debugging mode. (e.g., NDK_DEBUG = 1)
If you don't have source code and therefore no debuggable .so, there is no way to debug.
Also, please specify your environment such as Android NDK version, IDE, etc.
Assuming you are using Eclipse, this is detailed description how to debug native applications.

Difference in the 32-bit binaries built using ndk32-r10b and ndk64-r10b

Can anybody explain me what is the difference in 32-bit armeabi binaries compiled using ndk32-r10 build and ndk64-r10 build?
I am having several native libraries in my android project. Initially I was using android ndk-r9d build to compile these binaries for armeabi platform.
Now I have made some changes to one of the library and compiled it using ndk32-r10b build for armeabi.
Everything worked fine.
After this I compiled the same 32-bit binary with ndk64-r10b build for armeabi platform, which got compiled successfully. But at runtime it throws an error that it can not load/find library.
Please note that compilation succedded but it could not load the library at run time.
Can anybody tell me what is the difference in the 32-bit binaries built using ndk32 and ndk64?
Because according to my understanding ndk64 should be able to compile both 32-bit and 64-bit binaries as it is having options for both the platforms.
Is it related to any specific changes made for Android L in the binaries built using ndk64 build, if any?
Thanks for your help in advance.

Categories

Resources