i want to convert my python and kivy files into signed and unsigned apk. i work on windows but for compiling using python for android in ubuntu in vm ware. After installing all necessary modules like kivy, python for android and android studio.
when i am compiling it's showing error that sdk not found.
is there any option for generating apk in windows or ubuntu or linux.
i also heard about buildozer and it also works on windows.
please suggest me something on it i'm new to kivy.
thanks
1
I suggest using buildozer instead of p4a - the buildozer uses it internally. It can also automatically download specified android sdk for you.
Install it using pip: sudo pip install buildozer
Once you have it installed, go to your project directory and type:
buildozer init
# edit the buildozer.spec, then
buildozer android_new debug deploy run
Find more info on the github.
Related
I'm trying to create an app for android using buildozer that needs to use OpenCV and therefore python 3(Due to the fact that OpenCV is only compatible with python 3+). But, when I pass buildozer -v android_new debug or buildozer android_new release or buildozer android_new debug deploy run logcat, it returns the same error:
Command failed: python -m pythonforandroid.toolchain --color=always --storage-dir=/home/kivy/KivyApp/.buildozer/android/platform/build create --dist_name=myapp21 --bootstrap=sdl2 --requirements=kivy,opencv,python3 --arch armeabi-v7a --copy-libs
The directory mentioned in the error message (/home/kivy/KivyApp/.buildozer/android/platform/build) is empty, and I believe that the reason this doesn't work is that the python version on the buildozer virtual machine is Python 2.7.13, and when the requirements stated in the buildozer.spec file are kivy, opencv, and python3, it tries to pip install them resulting in an error for the last 2.
The Buildozer.spec file:
https://docs.google.com/document/d/1UAHekPUatAOrdIU_zFRwoPWgQKd-d0L3QsRXOr2Lo4Q/edit?usp=sharing
So, in general, I wanted to fully understand the problem before trying to install a new version of python on the buildozer virtual machine. If my assumption is incorrect, please correct me and if possible, direct me to the correct answer.
Thanks!
It is not a wonder. Python3 and android and Kivy is still in experimental state.
https://kivy.org/doc/stable/guide/packaging-android.html
Better to wait or to use Python2.7
I have finally managed to build an apk for python 3 and kivy using buildozer, but when I start it on my device I get the following error
I am using a Linux vm for virtual box on widows to build the apk.
Can you please help me solve this issue.
Is it possible to build the APK of an expo app locally?
The doc says:
If you haven’t used exp before, the first thing you’ll need to do is login with your Expo account using exp login.
I tried exp start, exp build:android but the commands require a login.
I don't want to build the APK using expo server. Is there a way to run this build locally? So no login and push of source code required?
If not, can I view the whole source code of the generated APK?
New to the party, so guessing this wasn't available at the time of the post - Instructions for building expo apps locally:
Building Standalone Apps on Your CI
Update Jan, 2023:
You may want to check out the updated version:
This doc was archived in August 2022 and will not receive any further updates. SDK 46 is the last SDK supported by Classic Builds and the Classic Build service will stop running for all SDK versions after January 4, 2023. Check out Running builds on your own infrastructure and Triggering builds from CI.
if you want to generate apk eject the CRNA with npm run eject command. Then you will get android and ios folders suppurate in mac and you will get an only android folder in windows. and follow the instruction which is in a given link below
"https://facebook.github.io/react-native/docs/signed-apk-android.html"
I've straggled with similar issue, I managed to solve it following several steps found on the web, and tweaking a bit:
https://forums.expo.io/t/expokit-full-local-build-without-publish-android/31400/2
Run the https server your machine, note that the server must have a certificate since it is a HTTPS server (I used port 4443), but it does not need to be trusted by your machine - it works anyway (I found it easy to use: https://gist.github.com/dergachev/7028596 - Python 2.7,
https://gist.github.com/dergachev/7028596#gistcomment-1989299 - Python 3.X)
Go to your Expo project folder, make sure there is no dist
folder in it; alternatively you can provide dist path with the --output-dir flag
(the react-native bundle and assets will be generated to it).
Open command line and run:
expo export -t bare --dev --public-url https://localhost:4443/, once done you will have the android bundle and assets in the output-dir (default - dist)
Copy the android bundle from dist/bundles/android-<bunch of numbers (MD5)>.js to <YourExpoProjectFolder>/android/app/src/main/assets/index.android.bundle and to <YourExpoProjectFolder>/android/app/build/generated/assets/react/release/index.android.bundle (note: the name of the bundle must be index.android.bundle)
In /dist/bundles/assets you'll have your assets files, but they would be named as their MD5 value, copy each of them to <YourExpoProjectFolder>/android/app/src/main/assets/, but add the asset_ prefix and .<ext> for each. e.g. for a PNG image file with MD5 value of de57a0c7a3a23aabcaceaf1185b1e79e:
copy <YourExpoProjectFolder>/dist/bundles/assets/de57a0c7a3a23aabcaceaf1185b1e79e <YourExpoProjectFolder>/android/app/src/main/assets/asset_de57a0c7a3a23aabcaceaf1185b1e79e.png
cd android
gradlew.bat assemble
expo diagnostics output:
Expo CLI 3.18.6 environment info:
System:
OS: Windows 10 10.0.18363
Binaries:
Node: 12.16.2
Yarn: 1.22.0
npm: 6.14.4
npmPackages:
expo: ~37.0.3 => 37.0.8
react: ~16.9.0 => 16.9.0
react-native: ~0.61.5 => 0.61.5
react-navigation: ^4.3.9 => 4.3.9
If you want to build the app locally without using the turtle CLI of expo, you can build it just how you would build a normal react native app
But beware that you will have to touch some native android code (gradle only)
But only one or two files....
Steps:
Generate a release Keystore by keytool
Link the keystore in build.gradle file
Run cd android && ./gradlew assembleRelease to build the apk
Check out this post to follow these steps in detail
Motivation: build local, test performance of release build on a real device.
Environment: Expo SDK 46 managed project, on AlmaLinux 8.6 (ymmv)
Caution:
I keep a copy of my entire project dir in case things get messed up:
cd <project *parent* dir>
\cp -far <project dir name> <project dir name>.bak
and update that when appropriate with
cd <project dir> # if not there
rsync -atvi --delete . ../<project dir name>.bak/
Steps to create android project dirs/files and a debug build apk :
cd <project dir>
npx expo run:android # not the same as "npm run android"
see ref in official expo docs here
release build:
cd <projectDir>/android/app
keytool -genkey -v -keystore <projectName>.keystore -alias <<projectName>> -keyalg RSA -keysize 2048 -validity 10000
ammend android/app/build.gradle file - see details here but do not use the build instructions (atow). Then ...
cd ../../ # to project dir
npx expo run:android --no-install --no-bundler --variant release
(although tbh I'm guessing for now that --no-bundler is to do with the Metro server)
You should find a release apk in
<project dir>/android/app/build/outputs/apk/release
Note this includes full expo and the build can take quite a while. It took more than 12 mins on the following:
Operating System: AlmaLinux 8.6
KDE Plasma Version: 5.23.3
KDE Frameworks Version: 5.88.0
Qt Version: 5.15.2
Kernel Version: 4.18.0-372.32.1.el8_6.x86_64 (64-bit)
Graphics Platform: X11
Processors: 12 × Intel® Xeon® CPU E5-2620 v3 # 2.40GHz
Memory: 31.1 GiB of RAM
Graphics Processor: AMD CEDAR
You can reduce build time and the final apk size by going for an expo development build or moving your code to a porn project (plain old react-native) :-)
I am new to kivy, and try to build an app for android using kivy.
When i was creating an apk for the app
buildozer android debug
with log_level=2
it shows:
Tool unzip is missing
Command failed: ./distribute.sh -m "kivy" -d "kivytut"
Buildozer failed to execute the last command
The error might be hidden in the log above this error
Please read the full log, and search for it before
raising an issue with buildozer itself.
In case of a bug report, please add a full log with log_level = 2
I'm unable to find any tool called upzip for buidozer(python-for-android) on the internet.
Help.
install unzip using:
sudo apt-get install unzip
moreover following are the tools that must be installed:
git
ant
python2
cython (can be installed via pip)
a Java JDK (e.g. openjdk-7)
zlib (including 32 bit)
libncurses (including 32 bit)
unzip
virtualenv (can be installed via pip)
ccache (optional)
These are several dependencies for python-for-android
I just installed Android NDK, r5b, and while trying to follow the steps from Exploring the hello-jni Sample, on the command line I receive the error:
MacBook-2:~ mvermant$ cd ndk/samples/hello-jni
MacBook-2:hello-jni mvermant$ android update project -p . -s
-bash: android: command not found
I'm using Eclipse Helios release 2 with Android SDK r10 and ADT 10.0.0 on MAC 10.6.6. I have also checked to have GNU Make 3.81, and installed GNU Awk(though I am not sure it's in the right place).
I've searched a lot, and seems there might be a class path missing somewhere, but I can't figure out where exactly and what to do to fix it.
You should make sure the tools directory of your android-sdk is on your (shell) path.
Something like:
export PATH="/path/to/sdk/tools:$PATH"
before you execute your command.
In general you will also need two other directories to be on your path:
/path/to/sdk/platform-tools - for adb and other android sdk tools
/path/to/ndk - for ndk-build and ndk-gdb, which are ndk tools
You can also do some setup so that you don't have to run these commands every time you open Terminal.