Nonsense
The goal is to do mobile development, this focus on Android development.
To confirm that I was able to compile correctly as APK, I first tried the full package apk on the Mac.
There is no internet talk so troublesome, also do not have to download his Ubuntu image, that is a bit more than the pit, but also to download more things. For a whole day, half of the time is spent waiting for downloads.
There is no edge to write, and all of the places on the whole to say, if there are readers to do it, leave a message to me.
Preparatory work
My environment is Mac, the brew is installed and the python pip
Install good kivy. Mac under the DMG, directly installed on it.
Stable wall tool is necessary, a large number of dependent software is to be turned over the wall to install. I used the shadownsocks, based on my own VPS.
A good mentality. The pit is still a little bit more, don't hit the computer. Look at the log in the face of problems
Steps
Official documents, but not in detail: http://kivy.org/docs/guide/packaging-android.html
Focus on the introduction of the Buildozer this artifact, the province of a lot of kung fu rely entirely on this.
At first I was stupid enough to download the Android SDK ndk.
No need to do anything, first install Buildozer
The code is as follows |
Copy Code |
git clone https://github.com/kivy/buildozer.git CD Buildozer sudo python setup.py install
|
Create a folder at random, called Test. Initialize to Buildozer project
The code is as follows |
Copy Code |
mkdir test CD test Buildozer Init
|
Inside will generate the configuration file Buildozer.spec, for the time being, nothing, no need to change
Write a Hello World
The code is as follows |
Copy Code |
#!/usr/bin/env python #-*-Coding:utf-8-*- Import Kivy From Kivy.app Import app From Kivy.uix.label Import label __version__ = ' 0.1 ' Class MyApp (APP): def build (self): Return Label (text= ' Hello World ') if __name__ = = ' __main__ ': MYAPP (). Run ()
|
Note __version__ = ' 0.1 ' must have the filename saved as main.py (consistent with profile)
Kivy main.py
It's OK to see that it works.
Start compilation:
Buildozer-v Android Debug
The first pit (license garbled)
Perform the above compilation and it will start downloading all sorts of dependencies. Android SDK Ndk, you don't have to worry about anything.
Then I suddenly reported a python coding error and stopped.
Looks like is Unicodeerro what, according to the stack information, I entered the expect.py, the error section of the content print out.
The result is the SDK or NDK's license statement, I rub, there is no Chinese ah, all kinds of places I do not use Chinese, why did?
Expect.py also did a utf-8 codec.
Finally carefully looked at the license, unexpectedly the middle of a paragraph do not know what ghost characters, print out is????
Google programmers are not dizzy, knock wrong.
I've added reload (SYS) utf-8 to all places. Wood is useful and almost hopeless.
Suddenly thought, that said that the character with Utf-8 can not decode and encode,expect.py own claim to make a, originally is well-intentioned, the result is self-defeating.
Directly modify expect.py, the error place decode encode all removed, let it directly manipulate the original string. And then it's gone ....
Second pit (Cython version problem)
Compiled to the back, anyway reported an error, similar to the
Error don't use this file, it is the result of a failed Cython compilation
All kinds of misunderstandings, no more information on the log.
The error location appears to be at Cython compile time.
So I demoted Cython from then Cython version 0.21 to Cython version 0.20, so it passed.
sudo pip install cython=0.20--upgrade
Command right not too remember that's the point anyway
I have the absolute spirit to be able to pass the AH ... Cry!!!
Third Pit (not complete compilation tool)
The eyes are going to start packing, and the results seem to be such a mistake
The code is as follows |
Copy Code |
Traceback (most recent call last): File "build.py", line 412, in <module> Make_package (args) File "build.py", line 336, in Make_package Subprocess.check_call ([ANT, Arg]) File "/usr/lib64/python2.7/subprocess.py", line 542, in Check_call Raise Calledprocesserror (Retcode, cmd) Subprocess. Calledprocesserror:command ' [' Ant ', ' Debug '] ' returned Non-zero exit status 1
|
People want to cry no tears, the error message is basically not. This error message is executed on this
The code is as follows |
Copy Code |
# Run/usr/bin/python build.py--name ' My application '--version 0.1--package Org.test.myapp--private/users/bigzhu/and Roid/.buildozer/android/app--SDK--MINSDK 8--permiss Ion BLUETOOTH--orientation Landscape Debug "
|
You're an egg, don't you? Do you dare to make the information clearer?
So I want to manually perform a look at the error, finally in the project folder under the
. buildozer/android/platform/python-for-android/dist
Found the build.py, one execution, said that the Android SDK Platform-tools does not exist ... I'll rub!!!.
Find Buildozer installed SDK here: ~/.buildozer/android/platform/android-sdk-21/tools/
Run Android and load the Platform-tools (I've installed an SDK before.) Added environmental variables, causing me to load the wrong place and reload again.
Complete
There are other pits during the period. These three are relatively large, but also relatively deceptive, small I google under the past.
So the Warriors, there are questions remember to give me a message, because the details I can't remember. Original is Bigzhu:http://www.111cn.net Oh.
Plug in the phone and execute
Buildozer Android Debug Deploy run
When I saw Hello world on my cell phone, I almost had tears in my eyes.