@@ -177,7 +177,7 @@ def update_project(self, android_platform):
177
177
sdk_tool_path = os .path .join (self .sdk_root , "tools" , "android" )
178
178
179
179
# check the android platform
180
- target_str = self .check_android_platform (self .sdk_root , android_platform , manifest_path , False )
180
+ target_str = self .check_android_platform (self .sdk_root , android_platform , manifest_path )
181
181
182
182
# update project
183
183
command = "%s update project -t %s -p %s" % (cocos .CMDRunner .convert_path_to_cmd (sdk_tool_path ), target_str , manifest_path )
@@ -275,55 +275,22 @@ def update_lib_projects(self, sdk_root, sdk_tool_path, android_platform, propert
275
275
abs_lib_path = os .path .join (property_path , lib_path )
276
276
abs_lib_path = os .path .normpath (abs_lib_path )
277
277
if os .path .isdir (abs_lib_path ):
278
- target_str = self .check_android_platform (sdk_root , android_platform , abs_lib_path , True )
278
+ target_str = self .check_android_platform (sdk_root , android_platform , abs_lib_path )
279
279
command = "%s update lib-project -p %s -t %s" % (cocos .CMDRunner .convert_path_to_cmd (sdk_tool_path ), abs_lib_path , target_str )
280
280
self ._run_cmd (command )
281
281
282
282
self .update_lib_projects (sdk_root , sdk_tool_path , android_platform , abs_lib_path )
283
283
284
- def select_default_android_platform (self , min_api_level ):
285
- ''' select a default android platform in SDK_ROOT
286
- '''
287
-
288
- sdk_root = cocos .check_environment_variable ('ANDROID_SDK_ROOT' )
289
- platforms_dir = os .path .join (sdk_root , "platforms" )
290
- ret_num = - 1
291
- ret_platform = ""
292
- if os .path .isdir (platforms_dir ):
293
- for dir_name in os .listdir (platforms_dir ):
294
- if not os .path .isdir (os .path .join (platforms_dir , dir_name )):
295
- continue
296
-
297
- num = self .get_api_level (dir_name , raise_error = False )
298
- if num >= min_api_level :
299
- if ret_num == - 1 or ret_num > num :
300
- ret_num = num
301
- ret_platform = dir_name
302
-
303
- if ret_num != - 1 :
304
- return ret_platform
305
- else :
306
- return None
307
-
308
-
309
284
def get_api_level (self , target_str , raise_error = True ):
310
- special_targats_info = {
311
- "android-4.2" : 17 ,
312
- "android-L" : 20
313
- }
314
-
315
- if special_targats_info .has_key (target_str ):
316
- ret = special_targats_info [target_str ]
285
+ match = re .match (r'android-(\d+)' , target_str )
286
+ if match is not None :
287
+ ret = int (match .group (1 ))
317
288
else :
318
- match = re . match ( r'android-(\d+)' , target_str )
319
- if match is not None :
320
- ret = int ( match . group ( 1 ) )
289
+ if raise_error :
290
+ raise cocos . CCPluginError ( MultiLanguage . get_string ( 'COMPILE_ERROR_NOT_VALID_AP_FMT' , target_str ),
291
+ cocos . CCPluginError . ERROR_PARSE_FILE )
321
292
else :
322
- if raise_error :
323
- raise cocos .CCPluginError (MultiLanguage .get_string ('COMPILE_ERROR_NOT_VALID_AP_FMT' , target_str ),
324
- cocos .CCPluginError .ERROR_PARSE_FILE )
325
- else :
326
- ret = - 1
293
+ ret = - 1
327
294
328
295
return ret
329
296
@@ -348,42 +315,26 @@ def get_target_config(self, proj_path):
348
315
cocos .CCPluginError .ERROR_PARSE_FILE )
349
316
350
317
# check the selected android platform
351
- def check_android_platform (self , sdk_root , android_platform , proj_path , auto_select ):
318
+ def check_android_platform (self , sdk_root , android_platform , proj_path ):
352
319
ret = android_platform
353
320
min_platform = self .get_target_config (proj_path )
354
321
if android_platform is None :
355
- # not specified platform, found one
356
- cocos .Logging .info (MultiLanguage .get_string ('COMPILE_INFO_AUTO_SELECT_AP' ))
357
- ret = self .select_default_android_platform (min_platform )
322
+ # not specified platform, use the one in project.properties
323
+ ret = 'android-%d' % min_platform
358
324
else :
359
325
# check whether it's larger than min_platform
360
326
select_api_level = self .get_api_level (android_platform )
361
327
if select_api_level < min_platform :
362
- if auto_select :
363
- # select one for project
364
- ret = self .select_default_android_platform (min_platform )
365
- else :
366
- # raise error
367
- raise cocos .CCPluginError (MultiLanguage .get_string ('COMPILE_ERROR_AP_TOO_LOW_FMT' ,
368
- (proj_path , min_platform , select_api_level )),
369
- cocos .CCPluginError .ERROR_WRONG_ARGS )
370
-
371
- if ret is None :
372
- raise cocos .CCPluginError (MultiLanguage .get_string ('COMPILE_ERROR_AP_NOT_FOUND_FMT' ,
373
- (proj_path , min_platform )),
374
- cocos .CCPluginError .ERROR_PARSE_FILE )
328
+ # raise error
329
+ raise cocos .CCPluginError (MultiLanguage .get_string ('COMPILE_ERROR_AP_TOO_LOW_FMT' ,
330
+ (proj_path , min_platform , select_api_level )),
331
+ cocos .CCPluginError .ERROR_WRONG_ARGS )
375
332
376
333
ret_path = os .path .join (cocos .CMDRunner .convert_path_to_python (sdk_root ), "platforms" , ret )
377
334
if not os .path .isdir (ret_path ):
378
335
raise cocos .CCPluginError (MultiLanguage .get_string ('COMPILE_ERROR_NO_AP_IN_SDK_FMT' , ret ),
379
336
cocos .CCPluginError .ERROR_PATH_NOT_FOUND )
380
337
381
- special_platforms_info = {
382
- "android-4.2" : "android-17"
383
- }
384
- if special_platforms_info .has_key (ret ):
385
- ret = special_platforms_info [ret ]
386
-
387
338
return ret
388
339
389
340
def ant_build_apk (self , build_mode , custom_step_args ):
0 commit comments