android-sdk-tools icon indicating copy to clipboard operation
android-sdk-tools copied to clipboard

build-toos/aapt2 issue with gradle in android termux

Open amsitlab opened this issue 1 year ago • 1 comments

If we use gradle build tools in termux (android) to build android apps, android-sdk build-tools/<version>/aapt2 is unused cause android gradle plugin (AGP) will auto download and use aapt2 from https://maven.google.com/web/m_index.html#com.android.tools.build:aapt2 and that will produce an error in termux because downloaded file contains executable for linux and not compatible for termux

current solution:

  • use maven local repository in all build.gradle
  • convert all jar file in ~/.gradle/cache/modules-2/files-1/ to maven local repository format by using this script (without finalizedBy)
  • run gradle cacheToMavenLocal
  • replace executable aapt2 in .m2/repository/com/android/tools/build/aapt2/< version >/aapt2-< version >.jar (downloaded by AGP from here ) with aapt2 provided by termux
  • and rebuild gradle assembleDebug

amsitlab avatar Jan 03 '24 03:01 amsitlab

please refer to build-app readme

lzhiyong avatar Jan 03 '24 10:01 lzhiyong