Android build cannot find pytorch_android:addHeadersTobundleReleaseAar

hi all,

I am trying to build pytorch android from source by following this website: https://pytorch.org/mobile/android/#building-pytorch-android-from-source

I runned it on mac with zsh.

gradle: v5.6.4

jdk 8

witht newest ndk and sdk

git clone --recursive https://github.com/pytorch/pytorch
cd pytorch
git submodule sync
git submodule update --init --recursive

cd pytorch
sh ./scripts/build_pytorch_android.sh

at the end I recived the error:

Task :pytorch_android:bundleReleaseAar FAILED

FAILURE: Build failed with an exception.

  • Where:

Build file ‘/Users/huanghenglin/pytorch/android/pytorch_android/build.gradle’ line: 115

  • What went wrong:

Execution failed for task ‘:pytorch_android:bundleReleaseAar’.

Could not find method execute() for arguments [] on task ‘:pytorch_android:addHeadersTobundleReleaseAar’ of type org.gradle.api.DefaultTask.

what should I do to finish the compilar?

note:

I did changed the build_android.sh, at line 58 from

CMAKE_ARGS+=("-DCMAKE_PREFIX_PATH=$(python -c ‘from distutils.sysconfig import get_python_lib; print(get_python_lib())’)")
CMAKE_ARGS+=("-DPYTHON_EXECUTABLE=$(python -c ‘import sys; print(sys.executable)’)")

to

CMAKE_ARGS+=("-DCMAKE_PREFIX_PATH=$(python3 -c ‘from distutils.sysconfig import get_python_lib; print(get_python_lib())’)")
CMAKE_ARGS+=("-DPYTHON_EXECUTABLE=$(python3 -c ‘import sys; print(sys.executable)’)")

since the system cannot find my python3, but I did not see it is a problem.

1 Like

I used the pyenv to change the environment, it seems not a python issue

I resolved it by using gradle version 4.10.2