| 37 | |
| 38 | |
| 39 | def resolve_android_jar(android_sdk_root, android_api_level): |
| 40 | requested = android_sdk_root / 'platforms' / android_api_level / 'android.jar' |
| 41 | if requested.is_file(): |
| 42 | return requested, android_api_level |
| 43 | |
| 44 | platforms = android_sdk_root / 'platforms' |
| 45 | available = sorted( |
| 46 | [path for path in platforms.glob('android-*') if (path / 'android.jar').is_file()], |
| 47 | key=lambda path: int(path.name.split('-')[1]) if path.name.split('-')[1].isdigit() else -1) |
| 48 | if available: |
| 49 | fallback = available[-1] |
| 50 | print('Requested %s was not found, using %s for bridge compilation.' % |
| 51 | (android_api_level, fallback.name), flush=True) |
| 52 | return fallback / 'android.jar', fallback.name |
| 53 | |
| 54 | raise RuntimeError('No Android platform android.jar found under %s' % platforms) |
| 55 | |
| 56 | |
| 57 | def resolve_ndk_root(android_sdk_root, value): |