I want to add my own jar into the AOSP. For that I have created Android.mk make file with the command include $(BUILD_JAVA_LIBRARY). I have also added the library name under build/target/product/core_minimal.mk (Product_boot_Jar section).
My issue: With the mm command I can see the jar under system/framework/myOwn.jar (Built successfully). But with complete make command it is unable to copy myown.jar into /system/framework.
Any idea on why it is not working within Android M?
Related
I am following this guideline to compile a c++ project.
It compiles successfully (it shows *[100%] Built target MY_SERVICE).
I can also observe that, it generates *.so library files.
After defining the output directory i can see a file with MY_SERVICE name without any extension.
MY_SERVICE is defined in CMAKELists.txt as below
set(BIN_TARGET MY_SERVICE)
My question is that what is the next step and how i can run it on an android platform.
I am using native C++ libraries in my Android application. I am not getting any compilation error; I am able to built apk, but after installation of apk while I am running application, it is crashing.
Is there any way to check weather libraries are integrated properly or not, or is there any way that I will push all library inside Android default library folder so my app will take library from there?
I am new to Android.
Generally you will get .so file missing message in logcat but still you want to confirm in that case:
If you have source of that .so then put prints or dump a file using fopen and build it again . Then integrate newly build files in Android and check that then file you was dumping or prints you have put you are getting properly.
If you have not source of .so files
In this case you can do using ndk-depend command just check dependencies of all so file if all depended so files are present either in libs folder of your project or in ndk then it is integrated properly.
I'm working on a project that requires me to integrate CLSTM library (a C++ implementation of LSTM networks for OCR) in an Android application. I'm a beginner Android developer and this is my first time working with NDK.
I'm having trouble integrating the C++ code with my project. I have been trying to do it for a couple of days, but have still gotten nowhere. I have been looking for solutions everywhere, but I can't find exact instructions for my problem.
What I have been able to do till now is:
Created new project with C++ support
Downloaded Android NDK
Downloaded CMake
Created JNI Folder
Cloned the source code into JNI Folder
I am not sure if I was supposed to do steps 4, 5 above. Also, from all the tutorials I have found, I think after these I am supposed to create an Android.mk and Application.mk files. I'm not sure what to write in them.
Can anyone guide me with exact steps for how to integrate this particular library in my Android application?
It's not really clear what exact problem you are having but I'll give it a shot as I've been dabbling with this myself recently. These are the steps I took:
Using classpath 'com.android.tools.build:gradle:2.2.0 as my build tools version
Added the C libraries in my app/src/main/jni directory
Added an Android.mk and Application.mk file in my app/src/main/jni directory
Added the following to my app/build.gradle:
```
externalNativeBuild {
ndkBuild {
path 'src/main/jni/Android.mk'
}
}
```
You can find the contents of my Application.mk and Android.mk here.
I based my setup of the .mk files & contents upon the keepassdroid project.
Edit:
if you also want to use travis-ci you can use this to download and use the android ndk in your builds:
before_install:
- curl -L http://dl.google.com/android/repository/android-ndk-r14-linux-x86_64.zip -O
- unzip -q android-ndk-r14-linux-x86_64.zip
- export ANDROID_NDK_HOME=`pwd`/android-ndk-r14
- export PATH=$PATH:${ANDROID_NDK_HOME}
I am trying to include a library into my android project using IntelliJ IDEA v10.0.3. The .jar library is, however, corrupt, so I want to include the bin directory into the project.
What I am doing: I go to File - Project Structure - Modules - Dependencies - Add - Library - New Library. In the dialog that appears, I give the library a name, then click Attach Classes..., then choose the bin directory. I then click ok.
The library appears to be working fine. I get code completion and use the classes as desired. However, when I run the project, I get the following error:
Error! C:[Path-to-library-project]\bin is a directory. Directory libraries are not supported
What can I do to fix this problem?
Make a valid jar from the required classes and use standard jar library. It's Android specific limitation.
I am creating a widget that we will provide to developer end users and it consists of a .jar and a native library (.so) built using the NDK. The JAR has a JNI interface to the dynamic library.
It's very clear on how to include an external .jar in a project but not how to include a dependent dynamic library.
How do I package up and build the .jar and .so? What are the best practices here?
I can create the JAR file using the JDK's jar command. Do I need to run dx.bat on the jar to convert to Dalvik bytecode?
I need to create a sample project showing the widget in action. How do I include this .jar and .so in a sample project that demonstrates how to use the widget?
I spent some time on this, and i just can't understand why isn't this written on wikitude documentation.... anyway follow this changes!
go to windows/preferences/android/build
uncheck the first and the second option
extract files from wikitudesdk.jar with winrar as if it is an archive, search libarchitect.so and copy it in /libs/libs/armeabi/
add wikitudesdk.jar to your build path
You should use the standard build tools included with the SDK for this. If you include the .jar files you need in the /lib directory of your project, the ant build process will convert the included class files to Dalvik bytecode format and include them in your classes.dex file for the app. Add a build.properties file to your project root as well, with one line:
external.libs.dir=lib
Depending on the version of your SDK and configuration of it, you may need to place the jar in libs rather than lib.
As for the .so, I presume that it's properly compiled using the Android NDK, or using a build script that uses the proper compiler and compiler flags that are required to successfully link the shared object on Android. If this is the case, you can include the .so file in libs/armeabi and they will be added in the jar as well. Furthermore, the dynamic library loader will know to look in this location in the .jar when you actually try to load the library from Java code.
Using ADT 12, I accomplished this by doing the following:
1) Export JAR from your library with the SO file using Eclipse. Make sure you exclude AndroidManifest.xml. This will include source code and other data, so if you are distributing, you'll want to strip these unnecessary bits out using any ZIP utility.
2) Create a directory in your App's source tree (I use "lib" directory) and copy your library JAR to it.
3) Right-click project in Eclipse and select "Configure Build Path". Add JAR and point it to JAR inside your App source tree.
4) In your Eclipse preferences, select Android/Build section and uncheck "Automatically refresh Resources and Assets folder on build". You will notice an option below that says "Force error when external jars contain native libraries." There is an ADT bug, which will supposedly be fixed in R17, which uses the wrong setting. Once it is fixed, you will use the "Force error" one (make sure it unchecked).
5) Once you build your app APK, you will have a libs/armeabi/libXXXX.so file. This will not be automatically unpacked on install. You will need to write code to extract it from your APK file into your data directory, then use System.load on the .so file in your data directory.
I have bidirectional JNI calls going from the dynamically loaded file, and even use dlopen() on it to do my custom plugin registration stuff.
Add the below lines to android.mk.
include $(BUILD_PACKAGE)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := alias:libs/your.jar
include $(BUILD_MULTI_PREBUILT)