Skip to content

Commit 7630222

Browse files
committed
Fixed ndk version check when no version found
1 parent 6fc1303 commit 7630222

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

pythonforandroid/recommendations.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717
def get_recommended_ndk():
1818
pass
1919

20+
2021
def check_ndk_version(ndk_dir):
2122
# Check the NDK version against what is currently recommended
2223
version = read_ndk_version(ndk_dir)
2324

2425
if version is None:
25-
return # it doesn't matter
26-
26+
return # if we failed to read the version, just don't worry about it
27+
2728
major_version = version.version[0]
2829

2930
info('Found NDK revision {}'.format(version))
@@ -37,14 +38,15 @@ def check_ndk_version(ndk_dir):
3738
RECOMMENDED_NDK_VERSION))
3839
warning(NEW_NDK_MESSAGE)
3940

41+
4042
def read_ndk_version(ndk_dir):
4143
"""Read the NDK version from the NDK dir, if possible"""
4244
try:
4345
with open(join(ndk_dir, 'source.properties')) as fileh:
4446
ndk_data = fileh.read()
4547
except IOError:
4648
info('Could not determine NDK version, no source.properties '
47-
'in the NDK dir')
49+
'in the NDK dir')
4850
return
4951

5052
for line in ndk_data.split('\n'):
@@ -53,12 +55,13 @@ def read_ndk_version(ndk_dir):
5355
else:
5456
info('Could not parse $NDK_DIR/source.properties, not checking '
5557
'NDK version')
58+
return
5659

5760
# Line should have the form "Pkg.Revision = ..."
5861
ndk_version = LooseVersion(line.split('=')[-1].strip())
5962

6063
return ndk_version
61-
64+
6265

6366
MIN_TARGET_API = 26
6467
RECOMMENDED_TARGET_API = 27 # highest version tested to work fine with SDL2
@@ -69,6 +72,7 @@ def read_ndk_version(ndk_dir):
6972
'and are not recommended. Note that the Target API can be higher than '
7073
'your device Android version, and should usually be as high as possible.')
7174

75+
7276
def check_target_api(api, arch):
7377
"""Warn if the user's target API is less than the current minimum
7478
recommendation
@@ -78,7 +82,7 @@ def check_target_api(api, arch):
7882
raise BuildInterruptingException(
7983
'Asked to build for armeabi architecture with API '
8084
'{}, but API {} or greater does not support armeabi'.format(
81-
self.android_api, ARMEABI_MAX_TARGET_API),
85+
api, ARMEABI_MAX_TARGET_API),
8286
instructions='You probably want to build with --arch=armeabi-v7a instead')
8387

8488
if api < MIN_TARGET_API:
@@ -90,14 +94,15 @@ def check_target_api(api, arch):
9094
RECOMMENDED_NDK_API = 21
9195
OLD_NDK_API_MESSAGE = ('NDK API less than {} is not supported'.format(MIN_NDK_API))
9296

97+
9398
def check_ndk_api(ndk_api, android_api):
9499
"""Warn if the user's NDK is too high or low."""
95100
if ndk_api > android_api:
96101
raise BuildInterruptingException(
97102
'Target NDK API is {}, higher than the target Android API {}.'.format(
98103
ndk_api, android_api),
99104
instructions=('The NDK API is a minimum supported API number and must be lower '
100-
'than the target Android API'))
105+
'than the target Android API'))
101106

102107
if ndk_api < MIN_NDK_API:
103108
warning(OLD_NDK_API_MESSAGE)

0 commit comments

Comments
 (0)