Skip to content

Commit 127c581

Browse files
committed
upgrade android_new -> android + android -> android_old. Closes #497
1 parent b656922 commit 127c581

File tree

8 files changed

+49
-30
lines changed

8 files changed

+49
-30
lines changed

README.rst

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Buildozer currently supports packaging for Android via the `python-for-android
1212
<http://github.com/kivy/python-for-android/>`_
1313
project, and for iOS via the kivy-ios project. iOS and OSX are still under work.
1414

15-
For Android: please have a look at `Android-SDK-NDK-Informations
15+
For Android: please have a look at `Android-SDK-NDK-Informations
1616
<https://github.com/kivy/kivy/wiki/Android-SDK-NDK-Informations>`_. Please note that
1717
the default SDK/NDK coded in Buildozer works for Python 2.
1818

@@ -42,7 +42,7 @@ Installing Buildozer with python2 support:
4242

4343
buildozer init
4444
# edit the buildozer.spec, then
45-
buildozer android_new debug deploy run
45+
buildozer android debug deploy run
4646

4747
Installing Buildozer with python3 support:
4848
------------------------------------------
@@ -71,10 +71,9 @@ The pip package does not yet support python3.
7171

7272
#. Finally, build, deploy and run the app on your phone::
7373

74-
buildozer android_new debug deploy run
75-
76-
#. Please note the "android_new" buildozer target, and use that for any and all buildozer commands you run (even if the docs just say "android"). Python3 only works with the **android_new** toolchain.
74+
buildozer android debug deploy run
7775

76+
#. Please note the "android" buildozer target, and use that for any and all buildozer commands you run (even if the docs just say "android").
7877

7978

8079
Examples of Buildozer commands:
@@ -83,17 +82,17 @@ Examples of Buildozer commands:
8382
::
8483

8584
# buildozer target command
86-
buildozer android_new clean
87-
buildozer android_new update
88-
buildozer android_new deploy
89-
buildozer android_new debug
90-
buildozer android_new release
85+
buildozer android clean
86+
buildozer android update
87+
buildozer android deploy
88+
buildozer android debug
89+
buildozer android release
9190

9291
# or all in one (compile in debug, deploy on device)
93-
buildozer android_new debug deploy
92+
buildozer android debug deploy
9493

9594
# set the default command if nothing set
96-
buildozer setdefault android_new debug deploy run
95+
buildozer setdefault android debug deploy run
9796

9897

9998
Usage
@@ -106,9 +105,9 @@ Usage
106105
buildozer --version
107106

108107
Available targets:
109-
android Android target, based on python-for-android project (old toolchain)
110-
ios iOS target, based on kivy-ios project
111-
android_new Android target, based on python-for-android project (new toolchain)
108+
android Android target, based on python-for-android project
109+
ios iOS target, based on kivy-ios project
110+
android_old Android target, based on python-for-android project (old toolchain)
112111

113112
Global commands (without target):
114113
distclean Clean the whole Buildozer environment.
@@ -127,7 +126,7 @@ Usage
127126
run Run the application on the device
128127
serve Serve the bin directory via SimpleHTTPServer
129128

130-
Target "android" commands:
129+
Target "android_old" commands:
131130
adb Run adb from the Android SDK. Args must come after --, or
132131
use --alias to make an alias
133132
logcat Show the log from the device
@@ -136,7 +135,7 @@ Usage
136135
list_identities List the available identities to use for signing.
137136
xcode Open the xcode project.
138137

139-
Target "android_new" commands:
138+
Target "android" commands:
140139
adb Run adb from the Android SDK. Args must come after --, or
141140
use --alias to make an alias
142141
logcat Show the log from the device
@@ -196,7 +195,7 @@ Using your devices via the VM
196195
There is a little icon on the bottom left that represent an USB plug.
197196
Select it, and select your android device on it. Then you can check:
198197

199-
- `buildozer android_new adb -- devices`
198+
- `buildozer android adb -- devices`
200199

201200
If it doesn't, use Google. They are so many differents way / issues
202201
depending your phone that Google will be your only source of

buildozer/__init__.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ def __init__(self, filename='buildozer.spec', target=None):
152152
def set_target(self, target):
153153
'''Set the target to use (one of buildozer.targets, such as "android")
154154
'''
155+
target = self.translate_target(target)
155156
self.targetname = target
156157
m = __import__('buildozer.targets.{0}'.format(target),
157158
fromlist=['buildozer'])
@@ -914,6 +915,23 @@ def package_full_name(self):
914915
# command line invocation
915916
#
916917

918+
def translate_target(self, target, inverse=False):
919+
# FIXME at some point, refactor to remove completely android old toolchain
920+
if inverse:
921+
if target == "android":
922+
target = "android_old"
923+
elif target == "android_new":
924+
target = "android"
925+
else:
926+
if target == "android":
927+
target = "android_new"
928+
elif target == "android_new":
929+
self.error("ERROR: The target android_new is now android")
930+
exit(1)
931+
elif target == "android_old":
932+
target = "android"
933+
return target
934+
917935
def targets(self):
918936
for fn in listdir(join(dirname(__file__), 'targets')):
919937
if fn.startswith('.') or fn.startswith('__'):
@@ -924,7 +942,7 @@ def targets(self):
924942
try:
925943
m = __import__('buildozer.targets.{0}'.format(target),
926944
fromlist=['buildozer'])
927-
yield target, m
945+
yield self.translate_target(target, inverse=True), m
928946
except NotImplementedError:
929947
pass
930948
except:
@@ -1032,8 +1050,8 @@ def run_command(self, args):
10321050

10331051
# maybe it's a target?
10341052
targets = [x[0] for x in self.targets()]
1035-
if command not in targets:
1036-
print('Unknown command/target {}'.format(command))
1053+
if self.translate_target(command, inverse=True) not in targets:
1054+
print('Unknown command/target {}'.format(self.translate_target(command, inverse=True)))
10371055
exit(1)
10381056

10391057
self.set_target(command)

buildozer/default.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ android.arch = armeabi-v7a
198198
# (str) Filename to the hook for p4a
199199
#p4a.hook =
200200

201-
# (str) Bootstrap to use for android builds (android_new only)
201+
# (str) Bootstrap to use for android builds
202202
# p4a.bootstrap = sdl2
203203

204204

buildozer/targets/android.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838

3939
class TargetAndroid(Target):
40-
targetname = 'android'
40+
targetname = 'android_old'
4141
p4a_directory = "python-for-android"
4242
p4a_branch = 'old_toolchain'
4343
p4a_apk_cmd = "python build.py"

buildozer/targets/android_new.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# coding=utf-8
22
'''
3-
Android target, based on python-for-android project (new toolchain)
3+
Android target, based on python-for-android project
44
'''
55

66
import sys
@@ -11,7 +11,7 @@
1111

1212

1313
class TargetAndroidNew(TargetAndroid):
14-
targetname = 'android_new'
14+
targetname = 'android'
1515
p4a_branch = "stable"
1616
p4a_directory = "python-for-android-master"
1717
p4a_apk_cmd = "apk --debug --bootstrap="

buildozer/targets/ios.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@
2020
$provisioningProfiles = glob('*.mobileprovision');
2121
$plists = glob('*.plist');
2222
23-
$sr = stristr( $_SERVER['SCRIPT_URI'], '.php' ) === false ?
23+
$sr = stristr( $_SERVER['SCRIPT_URI'], '.php' ) === false ?
2424
$_SERVER['SCRIPT_URI'] : dirname($_SERVER['SCRIPT_URI']) . '/';
2525
$provisioningProfile = $sr . $provisioningProfiles[0];
2626
$ipa = $sr . $ipas[0];
2727
$itmsUrl = urlencode( $sr . 'index.php?plist=' . str_replace( '.plist', '', $plists[0] ) );
2828
2929
3030
if ($_GET['plist']) {
31-
$plist = file_get_contents( dirname(__FILE__)
32-
. DIRECTORY_SEPARATOR
31+
$plist = file_get_contents( dirname(__FILE__)
32+
. DIRECTORY_SEPARATOR
3333
. preg_replace( '/![A-Za-z0-9-_]/i', '', $_GET['plist']) . '.plist' );
3434
$plist = str_replace('_URL_', $ipa, $plist);
3535
header('content-type: application/xml');
@@ -59,6 +59,7 @@
5959
'''
6060

6161
class TargetIos(Target):
62+
targetname = "ios"
6263

6364
def check_requirements(self):
6465
checkbin = self.buildozer.checkbin

buildozer/targets/osx.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929

3030
class TargetOSX(Target):
31+
targetname = "osx"
3132

3233
def ensure_sdk(self):
3334
self.buildozer.info('Check if kivy-sdk-packager exists')

buildozer/tools/packer/http/welcome/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ <h2>How to use the VM</h2>
5555
# update the build directory (issue with virtualbox shared folder and symlink)
5656
build_dir = /build/myapp
5757
</pre></li>
58-
<li>Build your application: <code>buildozer android_new debug</code></li>
59-
<li>Build and deploy, run and get the logs: <code>buildozer android_new debug deploy run logcat</code></li>
58+
<li>Build your application: <code>buildozer android debug</code></li>
59+
<li>Build and deploy, run and get the logs: <code>buildozer android debug deploy run logcat</code></li>
6060
</ol>
6161

6262
<h2 id="sharefolder">Share a folder</h2>

0 commit comments

Comments
 (0)