Skip to content

Dependency scanner for Android applications (option to scan for Qt plugins)

License

Notifications You must be signed in to change notification settings

bialasjaroslaw/dependencyscanner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Motivation

Due to the fact that Qt dependency scanner for Android is broken, and can not be 100% trusted I decided to write my own tool that respects sub dependencies.

How it is better?

First of all it is smaller and does not require access to Qt or precompiled Qt tools. Second of all (and most important) it is checking sub-dependencies which is not available for androiddeployqt. Example:

LibA->LibB
Application->LibA

If you decide to link all your libs statically it is fine as all dependencies will be detected (because Application will have them as direct ones). Unfortunately it is not always so simple, and sometimes libraries are compiled as shared ones. I was trying to leverage some of undocumented variables that can be put in JSON file used for Qt for Android deployment, but doing that means rest of libraries will not be detected (either full auto or full manual specification, there is nothing you can do to add your own libraries to auto detected dependencies).

In above case only Qt based dependencies of Application will be detected. LibA will be ignored as well as LibB. You can always add some dummy code to force linking to some dependencies, but if you forgot, this will be known at the runtime.

But I still need plugins!

Some libraries like Qt5Sql will provide an interface to operate on DBs, but real implementation is provided in a form of plugin (which might be unavailable if you will hide your dependency behind some nice abstraction). In this case even manually copying library itself will not help.

OK, I am screwed...

Indeed. But as always there is solution. All information can be obtained from libraries that have been already build. There is just one small issue (but I will mention about it later).

Example use

It is enough to launch provided tools for build directory and specify what should be done

qtandroiddependencyscanner \
  --directory build/android-build/libs \ # build directory, scan all archs
  --platform 29 \ # have to know platform for system dependencies
  --json build/android_deployment_settings.json \ # can use JSON to set some stuff
  --fix # fix missing

Above JSON file generated by Qt/CMake is used to set some things like Qt installation path and NDK directory. These values can also be set without JSON (see --help).

Without -f/--fix option you will just see what will happen (it is like a dry run)

Plugins

There are still some plugins required and there is a second tool for that

qtpluginresolver \
  --directory build/android-build/libs \ # like above
  --json build/android_deployment_settings.json \ # like above
  --deploy # deploy plugins to arch subdirectories

Issue

Because Qt creator is making all build steps at once, you have to either add custom step in QtCreator or add custom CMake target that will run at the end of build or somewhere in the middle of the install process (if you have one). In case of CI/build scripts it should be enough to run this before androiddeployqt (or after but do not use --gradle switch as this will immediately produce APK/AAB and some stuff won't be there yet)

Testing & Dependencies

Project requires some fairly popular libraries to be build fmt, spdlog and nlohmann_json. If you have them thats great, if not either add like I did with CLI11 (which was not available for my distribution), or install system-wide. This might be changed in the future (I will add them as optional dependencies that will be fetched automatically).

Not tested on Windows (yet). Right now only linux-x64 host is supported (I have hardcoded it, sue me!).

I spend couple hours of my time to write this code so if you think that there is a room for improvement, create an issue or PR.

About

Dependency scanner for Android applications (option to scan for Qt plugins)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published