CMake FindPackage fails for custom built boost libraries - android

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?

Related

AppCenter: build React-Native project which is 2 levels deep in Git

I'm setting up react-native build in AppCenter.
Everything works on test projects, but in a real repository I'm facing the following issue:
For best performance, the analysis is currently limited to four directory levels including the root of your repository.
(Quote from official docs)
My package.json is 2 levels deep (/folder1/folder2/package.json), so build.gradle is located 5 levels deep (/folder1/folder2/android/app/build.gradle).
So when I set up the build in AppCenter I'm able to specify the Project field (pointing to my package.json), but Build Variant combobox is empty.
Is there any solution for that? Can I specify Build Variant manually?
P.S. If I simply move the project one folder above - everything works fine. But I can't do that in my monorepository.
The workaround we are currently using: we created a separate repo with 1-level less nesting, and I'm copying my folder to another repo on each push (via TeamCity).
So, having a repo structure like this:
project
│───frontend
│ └───shared
│ └───web
│ └───react-native
│ │ package.json --> this is the folder we want to build in AppCenter
│ │ ...
│
└───backend
└── somefile.cs
We set up git-hooks to copy the frontend folder to another repo:
root
└───shared
└───web
└───react-native
│ package.json --> this is the folder we want to build in AppCenter
│ ...
So we got one level less deep repository which is ok for AppCenter.

Add dynamic feature module in a Eclipse Style Android project

I am trying to add dynamic feature module in my project. It was previously an Eclipse project so the structure is different from the Android Studio structure. The main application is in the root directory, not an independent module.
The project structure as follow:
/Project Root
Project Root Files
+Module1
+Dynamic Module
I want to add a dynamic feature module in the project, so I need to add the root project as the dependency of the dynamic module. Is there a way that I can do this? In the dynamic module build.gradle file, I tried ':Root' and ':', both did not work. Gradle said it could not resolve the root project.
Even I faced the above issue and was able to resolve it by referring the base module in the dependency module with the below approach.
dependencies {
implementation project(':')
}
If the base module is in the root of the project, one should refer the base module in the dependency module with the ":" symbol.
Using a project structure that gradle can deal with is the important bit here.
You can migrate the project Root to a different folder.
By convention that has been app.
You then can refer to it from dependent projects as :app.
The project structure would be then something like this:
.
├── build.gradle
├── app
│ ├── build.gradle
│ └── src
├── moduleA
│ ├── build.gradle
│ └── src
├── moduleB
│ ├── build.gradle
│ └── src

fastlane/supply dynamic what's new (changelogs)

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

OpenCV standalone installer opencv

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.

How to create the best Android app project structure with Android Studio and Gradle?

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.

Categories

Resources