docs
docs copied to clipboard
More generic solution for integration conan in gradle build system for Android projects
Problem
https://docs.conan.io/en/latest/integrations/android_studio.html page provides a solution for a single ABI project, if you need to support x86 or arm64-v8a this will not work out of box
Proposed solution
I have implemented a simple Gradle plugin for Android NDK CMake project https://gist.github.com/CAMOBAP795/ed9aa6a7549787b5eea4b2048b896747
At this time it supports CMake only, but I think it should be enough
I ready to get some feedback/critics )
I don't know how that gradle plugin work, but I think it would just change the profile to use when compiling for a different architecture (String profile = 'android-${abi}'
), right?
@danimtb close to truth
Plugin user will need to:
- Include plugin into
build.gradle
withapply from: "${rootDir}/conan.gradle"
command - Configure plugin with
conan {
conanfile = 'src/main/cpp/conanfile.txt'
profile = 'android-${abi}'
}
Where profile
is template string for conan profile
which will depends on abi
(in fact it's template string and abi
can be skipped
I understand that this automates some parts for changing the arch without changing anything, just building the project for the desired arch (probably selecting that in the Android Studio IDE).
However, I am not sure if this plugin will make the example you linked above (still works for just one arch) more clear...
At least you only need to have the profiles in the profiles folder with the right naming as stated above profile = 'android-${abi}'}
I understand that this automates some parts for changing the arch without changing anything, just building the project for the desired arch (probably selecting that in the Android Studio IDE).
This configured on Gradle config level in build.gradle
, abiFilters
in https://gist.github.com/CAMOBAP795/ed9aa6a7549787b5eea4b2048b896747 , gradle just do build for each declared abi
However, I am not sure if this plugin will make the example you linked above (still works for just one arch) more clear...
I have tried to keep it as simple as possible, from another point I tried to handle possible error cases too return clear messages too...
Anyway I'm ready to improve it or answer any questions
At least you only need to have the profiles in the profiles folder with the right naming as stated above profile = 'android-${abi}'}
I thought about using a dictionary (like {'armeabi-v7a: 'profile_armv7', 'x86': 'profile_x86'}
) instead of the template string.
Also, there are no restrictions to keep a profile in ~/.conan/profiles
, firstly plugin check profile relative to current build.gradle
plugin
I see... Thanks a lot for the clarification. We could add a link to your repo with the gradle plugin to the integrations section
Any update on this? The gists is not available. I struggling with the same issue.
Actual gist link https://gist.github.com/CAMOBAP/ed9aa6a7549787b5eea4b2048b896747