How to build a library from AOSP? - android

I need to build libjpeg-turbo library which is from android AOSP.
The repository contains this Android.bp file, and i have no idea how to build it. Before this, all of the libraries i've built had Android.mk file inside JNI folder and for the building i was using ndk-build command.
How can i succesfully build this library?

Some while ago, NDK and AOSP configuration scripts (Android.mk) looked very similar. Historically, NDK used the AOSP build system (based on GNU make). Since these early days, evolution of the two build systems went in different directions, and culminated in recent switch of AOSP to blueprint build system.
But even before this, you could use ndk-build with AOSP Android.mk files only occasionally. Many libraries, especially libraries with dependencies, could not be built this way.
Luckily, libjpeg-turbo is one of the subprojects of AOSP that don't have problematic dependencies. If you step back in git history for this library, you will be able to build it with ndk-build. You can even cherry-pick the relevant changes to your NDK-compatible branch.
Alternatively, you can use the official libjpeg-turbo repository instead of AOSP tree.

Related

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

Develop Android AOSP apps with gradle

I am building a custom app in Android AOSP and added it under packages/apps/Car/MyApp
Currently, the only way that I know how to integrate it into the build process is to create a Makefile Android.mk. Since adding dependencies/3rd party libraries with that approach is very tedious I would prefer being able to do it via gradle.
Is there any known solution how to use gradle as the build system for the app and trigger it with the Android.mk so it is still included in the overall build?
You can build it with gradle, and write Android.mk for your built apk. For adding prebuilt apk as system/privilege app, you can visit the stackoverflow question How to include prebuilt APK into AOSP with platform privileges

Building `netty-tcnative` for Android 4.x

I would like to use OpenSSL with Netty 4.1.17 on Android 4.x. The maven builds of netty-tcnative include only the x86_64 implementations. Is there documentation on how to build netty-tcnative for Android runtime environments?
I have the Android NDK installed, but I'm not sure how to configure the netty-tcnative build to use it. And presumably I need to build x86_32 as well as various ARM targets?
Honestly we never tried this and I am not sure it will work. That said it should be as easy as calling mvn clean package but again I am not sure if this will work. We also ship a dockerfile in the repository which will include all needed native dependencies etc.

Building with Address Sanitizer on Android but with CMake

I am trying to build a .so for android and I want to build with address sanitizer but the only instructions I see are for Android NDK based Makefiles, but I am using the newer endorsed CMake setup. Just adding the flag -fsanitize=address wasn't enough as the clang runtime library was missing.
what is the correct thing to add in my CMakeLists for Android built libraries?
You also need to prepare your device as described in documentation. You have to run asan_device_setup script from NDK. It will put asan .so on the device.

android automating build using Hudson + third party libraries

I am working alongside with two other developers in an android application. In the application we use other third-party libraries like SlidingMenu.
In eclipse we should include the SlidingMenu project and point our application to use this project as library.
Now I want to automate the building of the application using Hudson(Jenkins) but I have no Idea how I will deal with the dependence libraries like SlidingMenu.
Any Ideas
So long as you can build your app on the command line (e.g. using the Ant or Gradle build systems for Android), then you can build your app in Jenkins.
For the Ant build system, all you need to do is place your dependency JARs in the "libs" directory.
Or if you're using library projects, the Eclipse plugin should have already added the required entries to your project.properties file.

Categories

Resources