cpp_client_telemetry icon indicating copy to clipboard operation
cpp_client_telemetry copied to clipboard

Modernize android build

Open anod opened this issue 2 years ago • 5 comments

The current android build uses an outdated Gradle, cmake and java build dependencies and requires outdated IDE Android Studio 4 to run the project

Suggested to upgrade

  1. Gradle and android Gradle plugin
  2. Compile SDK version
  3. Cmake
  4. Test project dependcies
  5. Java 17

Can we upgrade it? Is there any additional guidance?

anod avatar Feb 02 '23 07:02 anod

@anod It would be good to upgrade the android build toolset we are using. I am not Java/Android expert, will this anyway change the minimum sdk version we correctly support, as I know few teams still needing support for Android 4.4 (sdk level 19) ?

lalitb avatar Feb 09 '23 07:02 lalitb

Thanks @lalitb I think there is no need to update minimum version. I will test and comeback with more details. it might require to upgrade cmake, is there limitation for cmake version capabilities.

anod avatar Feb 09 '23 15:02 anod

it might require to upgrade cmake, is there limitation for cmake version capabilities.

Which cmake version to upgrade to ? Ideally it would be good to support 3.1.0 as minimum version, and conditionally include any feature required from higher version:

cmake_minimum_required(VERSION 3.1.0)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12")
  ...
endif()

lalitb avatar Feb 09 '23 16:02 lalitb

Can I ask so that when we implement this, we can specify what versions of Android deps to use via env vars. My team needs this layer to be compatible with certain versions of NDK and SDK.. I wonder if we can use something like this:

export SDKAPILevelOverride=android-28
export NDKAPILevelOverride=latest

or what not. Similar how it's handled in Unreal Engine. It's a moving target for us.

maxgolov avatar Feb 16 '23 01:02 maxgolov

For SDK level there is an option to overlay default config with custom tools.gradle.user file I think app which depends on the lib upgrades a library defined target sdk, lowering target sdk can cause unpredictable behavior

Regarding NDK, There is a default NDK mapping between Gradle plugin and NDK NDK version can be overridden via ANDROID_NDK_VERSION env variable

Regarding cmake, current version is 3.10, but there is a warning

CMake Warning at /Users/algavris/Library/Android/sdk/ndk/23.1.7779620/build/cmake/android-legacy.toolchain.cmake:416 (message):
  An old version of CMake is being used that cannot automatically detect
  compiler attributes.  Compiler identification is being bypassed.  Some
  values may be wrong or missing.  Update to CMake 3.19 or newer to use
  CMake's built-in compiler identification.

anod avatar Feb 24 '23 20:02 anod