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