mirror of
https://github.com/NaitLee/Cat-Printer.git
synced 2025-05-21 09:40:10 -07:00
Merge pull request #54 from sync1211/fix-android-docs
Improve Android build instructions
This commit is contained in:
commit
c4a5ef7577
@ -53,8 +53,14 @@ Make 3 folders inside:
|
|||||||
### Git Repositories
|
### Git Repositories
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Remember to use your path
|
# Define your build directories
|
||||||
DIR_GIT="/mnt/data/@/git-repo/"
|
DIR_BUILD="/mnt/data/@"
|
||||||
|
DIR_GIT="$DIR_BUILD/git-repo/"
|
||||||
|
|
||||||
|
# Make sure both directories exist
|
||||||
|
mkdir -p $DIR_BUILD
|
||||||
|
mkdir -p $DIR_GIT
|
||||||
|
|
||||||
cd $DIR_GIT
|
cd $DIR_GIT
|
||||||
|
|
||||||
# Cat-Printer
|
# Cat-Printer
|
||||||
@ -116,8 +122,8 @@ System doesn’t understand it. Let’s replace them as symlinks:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# you may already have these from p4a guide
|
# you may already have these from p4a guide
|
||||||
ANDROIDSDK="/mnt/data/@/android"
|
ANDROIDSDK="$DIR_BUILD/android"
|
||||||
ANDROIDNDK="/mnt/data/@/android/android-ndk-r23b"
|
ANDROIDNDK="$DIR_BUILD/android/android-ndk-r23b"
|
||||||
# feel free to check this script
|
# feel free to check this script
|
||||||
python3 $DIR_GIT/Cat-Printer/build-android/fix-ndk-execs.py $ANDROIDNDK
|
python3 $DIR_GIT/Cat-Printer/build-android/fix-ndk-execs.py $ANDROIDNDK
|
||||||
```
|
```
|
||||||
@ -175,15 +181,15 @@ The most tricky fact is that none of these things work out-of-the-box.
|
|||||||
We should glue them up by hand.
|
We should glue them up by hand.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# let’s put those environment variables required by python-for-android here
|
# append target paths and environment variables required by python-for-android (adjust if necessary)
|
||||||
nano ~/.bashrc
|
echo '
|
||||||
# append in the end. use your target paths!
|
export DIR_BUILD="/mnt/data/@"
|
||||||
export ANDROIDSDK="/mnt/data/@/android"
|
export ANDROIDSDK="$DIR_BUILD/android"
|
||||||
export ANDROIDNDK="/mnt/data/@/android/android-ndk-r23b"
|
export ANDROIDNDK="$DIR_BUILD/android/android-ndk-r23b"
|
||||||
export ANDROIDAPI="30"
|
export ANDROIDAPI="30"
|
||||||
export NDKAPI="21"
|
export NDKAPI="21"' >> .bashrc
|
||||||
|
|
||||||
# after that, apply these
|
# reload environment variables
|
||||||
source ~/.bashrc
|
source ~/.bashrc
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -191,12 +197,12 @@ source ~/.bashrc
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# define shortcut(s). use your target paths!
|
# define shortcut(s). use your target paths!
|
||||||
DIR_GIT="/mnt/data/@/git-repo/"
|
DIR_GIT="$DIR_BUILD/git-repo/"
|
||||||
DIR_P4A="/usr/local/lib/python3.10/dist-packages/pythonforandroid/"
|
DIR_P4A="/usr/local/lib/python3.10/dist-packages/pythonforandroid/"
|
||||||
|
|
||||||
# p4a will generate some intermediate data. “expose” this to the host for convenient manipulation.
|
# p4a will generate some intermediate data. “expose” this to the host for convenient manipulation.
|
||||||
mkdir -p ~/.local/share/
|
mkdir -p ~/.local/share/
|
||||||
ln -s /mnt/data/@/p4a/ ~/.local/share/python-for-android
|
ln -s $DIR_BUILD/p4a/ ~/.local/share/python-for-android
|
||||||
|
|
||||||
# give p4a the bleak recipe. fortunately, p4a will resolve this symlink
|
# give p4a the bleak recipe. fortunately, p4a will resolve this symlink
|
||||||
ln -s $DIR_GIT/bleak/bleak/backends/p4android/recipes/bleak $DIR_P4A/recipes/bleak
|
ln -s $DIR_GIT/bleak/bleak/backends/p4android/recipes/bleak $DIR_P4A/recipes/bleak
|
||||||
@ -223,7 +229,7 @@ cd $DIR_GIT
|
|||||||
cp $DIR_P4A/bootstraps/webview/build/src/main/java/org/kivy/android/PythonActivity.java ./
|
cp $DIR_P4A/bootstraps/webview/build/src/main/java/org/kivy/android/PythonActivity.java ./
|
||||||
# some sed script doing the dirty work
|
# some sed script doing the dirty work
|
||||||
sed -i 's/import android.webkit.WebView;/import im.delight.android.webview.AdvancedWebView;/' PythonActivity.java
|
sed -i 's/import android.webkit.WebView;/import im.delight.android.webview.AdvancedWebView;/' PythonActivity.java
|
||||||
sed -i -r 's/\bWebView\b/AdvancedWebView;/g' PythonActivity.java
|
sed -i -r 's/\bWebView\b/AdvancedWebView/g' PythonActivity.java
|
||||||
```
|
```
|
||||||
|
|
||||||
Not the end yet —
|
Not the end yet —
|
||||||
@ -320,7 +326,7 @@ keytool -genkey -v -keystore mykeyfile.key -keyalg RSA -keysize 2048 -validity 1
|
|||||||
cd $DIR_GIT/Cat-Printer/build-android/
|
cd $DIR_GIT/Cat-Printer/build-android/
|
||||||
# <dot><slash><3><tab>
|
# <dot><slash><3><tab>
|
||||||
# pass the path to keyfile as parameter
|
# pass the path to keyfile as parameter
|
||||||
./3-formal-build.sh mykeyfile.key
|
./3-formal-build.sh mykeyfile.key # On later versions of python-for-android, the keystore needs to be specified via "--keystore mykeyfile.key --signkey mykey"
|
||||||
# again, feel free to check this file
|
# again, feel free to check this file
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -333,6 +339,19 @@ If it also worked, congrats again!
|
|||||||
|
|
||||||
Try the ultimate helper `1-build.sh`, if you also have everything in [development.md](../development.md) done.
|
Try the ultimate helper `1-build.sh`, if you also have everything in [development.md](../development.md) done.
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
Common issues and fixes:
|
||||||
|
|
||||||
|
| Error message | Fix |
|
||||||
|
|-|-|
|
||||||
|
| path may not be null or empty string. path='null' | Keystore needs to be specified via `--keystore <keyfile>` |
|
||||||
|
| `/usr/bin/javac` is missing | JDK needs to be installed and selected as active java installation. |
|
||||||
|
| setuptools could not be imported | Fixed by specifying a different python version by adding `--requirements=pip,setuptools,wheel,hostpython3==3.9.16,python3==3.9.16,$(cat build-deps.txt)` |
|
||||||
|
| No such file or directory `bleak/setup.py` | Run `2-clean-up-build.sh` or [download the bleak source code from PyPi](https://pypi.org/project/bleak/#files) |
|
||||||
|
| No such file or directory `build-android/dist` | Create a bare bundle before creating an APK |
|
||||||
|
| JAVA_HOME is not set and no 'java' command could be found in your PATH. | Install a JDK (e.g. `openjdk-19-jdk`) |
|
||||||
|
|
||||||
## The End
|
## The End
|
||||||
|
|
||||||
You made it! You now have ability to contribute much more, outside of Cat-Printer. Try to bring an app in your mind to reality, with just Python, Web, and this build environment.
|
You made it! You now have ability to contribute much more, outside of Cat-Printer. Try to bring an app in your mind to reality, with just Python, Web, and this build environment.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user