I am working on an OpenCV app, and it works fine but when I try to install the app it asks to download the OpenCV manager, and which i dont want. I want to make a stand alone installer for OpenCV app which includes the OpenCV manager inbuit into it ? I did check this link but still it shows pop up to install opencv?
in my experience you maybe just need to do these 2(or 3) steps:
1.change the load lib code in java like this:
static {
Log.i(TAG,"OpenCV library load!");
if (!OpenCVLoader.initDebug()) {
Log.i(TAG,"OpenCV load not successfully");
}
else {
System.loadLibrary("opencv_java");// load other libraries
}
}
2.delete this code in java:
OpenCVLoader.initAsync(OpenCVLoader.OpenCV_VERSION_2_4_3, this, mLoaderCallback);
3.if you have add ndk code to your project, maybe you have to edit Android.mk file like this:
OpenCV_CAMERA_MODULES:=on
OpenCV_INSTALL_MODULES:=on
OpenCV_LIB_TYPE:=SHARED
Solution
When you provide libopencv_java3.so with your APK the OpenCV loader doesn't need the OpenCV Manager
Simply copy the OpenCV libs folder (see Context below) into the folder containing your AndroidManifext.xml. Now rename this libs folder into jniLibs. The result should look like the structure below. Props to this post. There's also a bit more details.
android studio project/
├──libs/
| └── *.jar <-- if your library has jar files, they go here
├──src/
└── main/
├── AndroidManifest.xml
├── java/
└── jniLibs/
├── arm64-v8a/ <-- ARM 64bit
│ └── libopencv_java3.so
├── armeabi-v7a/ <-- ARM 32bit
│ └── libopencv_java3.so
├── x86/ <-- Intel 32bit
│ └── libopencv_java3.so
└── ...
└── libopencv_java3.so
Now build your APK file. Make sure the libraries are properly provided within your app. Here is your APK after building:
[project name]\[app name]\build\outputs\apk\debug
Just open your APK with a Zip program of your choice. The above listed *.so files should be listed in the APK here:
APK file/
├──lib/
| ├── arm64-v8a/
| │ └── libopencv_java3.so
| ├── armeabi-v7a/
| │ └── libopencv_java3.so
| ├── x86/
| │ └── libopencv_java3.so
| └── ...
| └── libopencv_java3.so
├─ ...
Using this APK should result in OpenCV no longer looking for the OpenCV Manager App. Of course your APK grows very large by providing the library for every ABI. Depending on your use case it might become useful to only provide the libraries for the targeted ABIs/platforms. It is possible to create filters for supported ABIs. In case the is relevant start reading here.
ENJOY!
Context
At runtime your application requires the OpenCV library file
libopencv_java3.so. This file comes in different versions depending on the target platform where you want to use it. Have a look at your local OpenCV SDK directory at this location:
[OpenCV SDK]\sdk\native\libs\
Here you'll find a short list of provided ABIs/platforms via providing the respective OpenCV library file:
armeabi
armeabi-v7a
x86
x86_64
arm64-v8a
Android OpenCV Manager
From what I understood the OpenCV Manager App does nothing else but provide the required OpenCV library to an app when called from:
if (!OpenCVLoader.initDebug()) {
Log.d(TAG, "Internal OpenCV library not found. Using OpenCV Manager for initialization");
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_0_0, this, mLoaderCallback);
} else {
Log.d(TAG, "OpenCV library found inside package. Using it!");
mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
}
This makes sense when you have multiple applications requiring the OpenCV libraries. So you would only store it a single time on your mobile device instead of as part of every app.
When you look up what OpenCVLoader.initDebug() does in the OpenCV sources you'll end up at this statement:
loadLibrary("opencv_java3")
So basically the OpenCVLoader tries to find the OpenCV library file within your APK before querying the OpenCV Manager.
Related
I am trying to build a native Android project that requires Boost library. I have built Boost for the platforms I am targeting using this git project. But for some reason find_package() for Boost fails to find the Boost header paths
Below is the project structure and for the Android app, and location where I have placed the Boost library.
android_app
├── src
│ └──<folder>
│ └──<folder>
│ └──CMakeLists.txt
└── lib
└── boost_armeabi-v7a
├── include
│ └── boost_1_68_0
│ └──boost
│ ├──align.hpp
│ ├──......
│ └──config.hpp
└── lib
├──libboost_atomic.a
├──......
└──libboost_wserialization.a
In the CMake file I have configured like this
set(Boost_NO_SYSTEM_PATHS ON)
set(Boost_NO_BOOST_CMAKE ON)
set(LOCAL_LIB_DIR "${PROJECT_SOURCE_DIR}/../../../lib")
set(Boost_ADDITIONAL_VERSIONS "1.68.0")
set(BOOST_INCLUDEDIR "${LOCAL_LIB_DIR}/boost_${ANDROID_ABI}/include")
set(BOOST_LIBRARYDIR "${LOCAL_LIB_DIR}/boost_${ANDROID_ABI}/lib")
find_package(Boost REQUIRED)
Below error is the error iam getting with find_package.
Unable to find the Boost header files. Please set BOOST_ROOT to the root
directory containing Boost or BOOST_INCLUDEDIR to the directory containing Boost's headers.
I added some message statements and finally narrowed down to this piece of code in the FindBoost CMake file (3.10.2) installed from Android Studio
find_path(Boost_INCLUDE_DIR
NAMES boost/config.hpp
HINTS ${_boost_INCLUDE_SEARCH_DIRS}
PATH_SUFFIXES ${_boost_PATH_SUFFIXES}
)
Dumping there variables, one of the combination for {_boost_INCLUDE_SEARCH_DIRS}/{_boost_PATH_SUFFIXES} should be valid for my path, but after this executes, Boost_INCLUDE_DIR is set as NOTFOUND. I have no idea why this fails.
One of the _boost_INCLUDE_SEARCH_DIRS value is /home/<user>/<path-to-repo>/app/lib/boost_armeabi-v7a/include and one of value in PATH_SUFFIXES is boost_1_68_0. Can some one help me figure out why this is failing?
I'm creating a React-native app which I'll integrate into iOS/Android app(already created). Can you please suggest a good way of folder structure(especially React-Native).
I really like this way to structure an Project:
── app
├── components
├── config
├── index.js
├── lib
└── screens
More Information about this, you find here:
https://medium.com/the-react-native-log/organizing-a-react-native-project-9514dfadaa0
fastlane supply android metadata has the following structure:
└── fastlane
└── metadata
└── android
├── en-US
│ └── changelogs
│ ├── 100000.txt
│ └── 100100.txt
└── fr-FR
└── changelogs
└── 100100.txt
Production builds and versions is changed some times before release so I had to change files names in changelog directories after every build.
I want to have only one "what's new" (changelog) file per locale for the latest build. Something like whats_new.txt
Does fastlane or supply provide such a feature?
supply is not set up to support such a strategy right now, sorry. I think it is a reasonable feature request though. Please submit an issue in our GitHub repository if it's something you'd like to see be possible!
A plugin like changelog might be what you are after. It allows you to pull from one changelog file like so:
read_changelog(
changelog_path: './custom_folder/CHANGELOG.md', # Specify path to CHANGELOG.md
section_identifier: '[Unreleased]', # Specify what section to read
excluded_markdown_elements: '["###"]' # Specify which markdown elements should be excluded
)
I do not, however, see builtin support for a per-locale changelog. For reference, the release_notes.txt file and/or function provide the functionality you describe when using fastlane for iOS projects.
I think what you want it's supported nowadays with the default.txt file
https://docs.fastlane.tools/actions/supply/#changelogs-whats-new
I'm trying to switch to Android Studio and Gradle, but I have quite some issues with both integration into Studio and build with Gradle.
I've got an app that relies on several libraries.
I'd like to use Android Studio, and Gradle build system.
I'm using git
Most of my libraries are directly git cloned from their github location
Currently, what I have is:
Main Project
├── GH Lib 1
│ ├── <some stuff from the lib>
│ └── library
│ ├── AndroidManifest.xml
│ ├── res
│ └── src
├── GH Lib 2
│ └── <same structure as the lib 1>
├── GH Lib 3
│ └── <same structure as the lib 1>
│── GH Lib 4
│ └── <same structure as the lib 1>
└── My App folder
└── AndroidManifest.xml
└── res
└── src
└── libs
Each of the 'GH Lib X' directory is the result of a git clone from GitHub (for example: ActionBarSherlock).
'My app folder' contains directly res, src, AndroidManifest.xml, libs (with jars), etc.
1st question
I would like to understand how I can integrate all of this in Studio, with Gradle. Currently each lib is a module, and contains a build.gradle file. My App contains also a build.gradle file, however I can't reference dependencies from other folders, because they are in the parent folder, and this AFAIK can't be done with Gradle.
Would this structure be better?
My App Folder
│── AndroidManifest.xml
│── res
│── src
│── libs
└── dependencies
│── GH Lib 1
│── GH Lib 2
│── GH Lib 3
│── GH Lib 4
└── My App folder
My second question related to this is integration with git. Currently all libs are git submodules, is it a good idea?
You should look at the multiproject example for the layout attached in the doc.
http://tools.android.com/tech-docs/new-build-system
http://docs.google.com/viewer?a=v&pid=sites&srcid=YW5kcm9pZC5jb218dG9vbHN8Z3g6NDYzNTVjMjNmM2YwMjhhNA
Essentially you want a top level settings.gradle that tie all the pieces together. Ideally they should be in one single git repo to make your life easier. However you probably can use symlink to tie them into a common build repo that contain your top level settings.gradle.
This structure will work just fine. I have a similar structure and everything OK in Ubuntu 13.04 and Android Studio 130.729444.
You should provide settings.gradle file in root project with references (basically it's a relative path) to each module which should be built.
include ':my-app', ':gh-lib-1:library', ':gh-lib-2:library'
Root build.gradle file should contain tasks/configuration which will be common for all projects. More about multi-project setup can be found here: http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Multi-project-setup
Right now your source directories location does not conform to the default Android Studio setup. You can either move your src, res directories or setup sourceSets configuration in your build.gradle. It should be done for each project. More about project structure: http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
After these steps you may try to import your project to Android Studio by selecting root build.gradle file in the 'Import project' dialog.
It's possible that at first you will be unable to build the project in IDE due to Task 'assemble' not found in root project error. This is a bug in Android Studio. Fortunately, there is a workaround for this - just include task assemble{} in build.gradle files for all 'root' projects.
I have project that compiles and links fine when using Eclipse IDE. This project uses some external jar files and also uses some of JNI ( .so ) libraries.
They are all located in the libs/ directory of my project. How should my pom.xml file look like in order for all the jar files in libs/ folder and the shared objects are included in the APK. My libs directory looks something like this:
libs/
├── mydevicelib.jar
├── armeabi
│ ├── libdevice.so
├── armeabi-v7a
│ ├── libdevice.so
│ ├── libcmiris.so
├── libcommon.jar
I am using maven 3.0.5
These jars should be included as dependencies in the maven POM.
Rather than include them in a local lib folder they should be deployed to a maven repository.
For any artifacts that are available through maven central repository just include the dependency directly from there.
For custom artifacts, the best way to do this is to set up your own maven repository (http://archiva.apache.org/index.cgi or http://www.sonatype.org/nexus/) and deploy the artifacts to that. Then you can include them as dependencies in the pom.
Alternatively, if this is overkill for your project, you can set up a local project repository and deploy the artifacts to that.
I havent actually done this with JNI libraries, though this link looks like it may contain useful info for doing a similar thing there: http://code.google.com/p/maven-android-plugin/wiki/NativeLibsAsDependencies. Looks like you just need to add the
<type>so</type>
element to the dependency.