@@ -79,6 +79,7 @@ def check_python_dependencies():
79
79
import imp
80
80
from appdirs import user_data_dir
81
81
import logging
82
+ from distutils .version import LooseVersion
82
83
83
84
from pythonforandroid .recipe import (Recipe , PythonRecipe , CythonRecipe ,
84
85
CompiledComponentsPythonRecipe ,
@@ -771,12 +772,24 @@ def apk(self, args):
771
772
build_type = ctx .java_build_tool
772
773
if build_type == 'auto' :
773
774
info ('Selecting java build tool:' )
774
- if exists ('gradlew' ):
775
+
776
+ build_tools_versions = os .listdir (join (ctx .sdk_dir , 'build-tools' ))
777
+ build_tools_versions = sorted (build_tools_versions ,
778
+ key = LooseVersion )
779
+ build_tools_version = build_tools_versions [- 1 ]
780
+ info (('Detected highest available build tools '
781
+ 'version to be {}' ).format (build_tools_version ))
782
+
783
+ if build_tools_version >= '25.0' and exists ('gradlew' ):
775
784
build_type = 'gradle'
776
785
info (' Building with gradle, as gradle executable is present' )
777
786
else :
778
787
build_type = 'ant'
779
- info (' Building with ant, as no gradle executable detected' )
788
+ if build_tools_version < '25.0' :
789
+ info ((' Building with ant, as the highest '
790
+ 'build-tools-version is only {}' ).format (build_tools_version ))
791
+ else :
792
+ info (' Building with ant, as no gradle executable detected' )
780
793
781
794
if build_type == 'gradle' :
782
795
# gradle-based build
0 commit comments