question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

failed to setup p4a on ubuntu (multiple issues)

See original GitHub issue

kivy: 1.10.0 cython: 0.26.1 p4a: 0.6.0 java: 1.8.0_144 (oracle) android ndk: r15c android sdk: 25.2.3 ubuntu: 16.04

cmd:

p4a apk --private $HOME/code/android/myapp --package=org.example.myapp --name "My application" --version 0.1 --bootstrap=sdl2 --requirements=python2,kivy --java-build-tool gradle --arch=armeabi-v7a --no-compile-pyo

output:

[INFO]:    Will compile for the following archs: armeabi-v7a
[INFO]:    Found Android API target in $ANDROIDAPI
[INFO]:    Available Android APIs are (25, 26, 27)
[INFO]:    Requested API target 26 is available, continuing.
[INFO]:    Found NDK dir in $ANDROIDNDK
[INFO]:    Got NDK version from $ANDROIDNDKVER
[INFO]:    Using Google NDK r15c
[INFO]:    Found virtualenv at /usr/local/bin/virtualenv
[INFO]:    Found the following toolchain versions: ['4.9']
[INFO]:    Picking the latest gcc toolchain, here 4.9
[INFO]:    Of the existing distributions, the following meet the given requirements:
[INFO]:    	unnamed_dist_6: includes recipes (hostpython2, sdl2_image, sdl2_mixer, sdl2_ttf, python2, sdl2, six, pyjnius, kivy), built for archs (armeabi-v7a)
[INFO]:    unnamed_dist_6 has compatible recipes, using this one
[INFO]:    Of the existing distributions, the following meet the given requirements:
[INFO]:    	unnamed_dist_6: includes recipes (hostpython2, sdl2_image, sdl2_mixer, sdl2_ttf, python2, sdl2, six, pyjnius, kivy), built for archs (armeabi-v7a)
[INFO]:    unnamed_dist_6 has compatible recipes, using this one
[INFO]:    -> directory context /home/millon/.local/share/python-for-android/dists/unnamed_dist_6
Traceback (most recent call last):
  File "/usr/local/bin/p4a", line 9, in <module>
    load_entry_point('python-for-android==0.6.0', 'console_scripts', 'p4a')()
  File "/usr/local/lib/python2.7/dist-packages/pythonforandroid/toolchain.py", line 975, in main
    ToolchainCL()
  File "/usr/local/lib/python2.7/dist-packages/pythonforandroid/toolchain.py", line 512, in __init__
    getattr(self, args.subparser_name.replace('-', '_'))(args)
  File "/usr/local/lib/python2.7/dist-packages/pythonforandroid/toolchain.py", line 150, in wrapper_func
    func(self, args)
  File "/usr/local/lib/python2.7/dist-packages/pythonforandroid/toolchain.py", line 754, in apk
    build_args = build.parse_args(args.unknown_args)
  File "/home/millon/.local/share/python-for-android/dists/unnamed_dist_6/build.py", line 567, in parse_args
    make_package(args)
  File "/home/millon/.local/share/python-for-android/dists/unnamed_dist_6/build.py", line 248, in make_package
    make_tar('src/main/assets/private.mp3', tar_dirs, args.ignore_path)
  File "/home/millon/.local/share/python-for-android/dists/unnamed_dist_6/build.py", line 187, in make_tar
    tf = tarfile.open(tfn, 'w:gz', format=tarfile.USTAR_FORMAT)
  File "/usr/lib/python2.7/tarfile.py", line 1691, in open
    return func(name, filemode, fileobj, **kwargs)
  File "/usr/lib/python2.7/tarfile.py", line 1738, in gzopen
    fileobj = gzip.GzipFile(name, mode, compresslevel, fileobj)
  File "/usr/lib/python2.7/gzip.py", line 94, in __init__
    fileobj = self.myfileobj = __builtin__.open(filename, mode or 'rb')
IOError: [Errno 2] No such file or directory: 'src/main/assets/private.mp3'

$HOME/code/android/myapp/main.py:

from kivy.app import App
from kivy.uix.button import Button

class Hello(App):
    def build(self):
        btn = Button(text='hello world!')

        return btn


if __name__ == '__main__':
    Hello().run()

I have no experience working with kivy. just trying to setup kivy on ubuntu 16.04 (kde neon ) for android. so, there might be something that I am missing. the myapp folder contains main.py only.

if I use

mkdir -p /home/millon/.local/share/python-for-android/dists/unnamed_dist_6/src/main/assets/
touch /home/millon/.local/share/python-for-android/dists/unnamed_dist_6/src/main/assets/private.mp3

I get a different error

IOError: [Errno 2] No such file or directory: 'src/main/res/drawable/icon.png'

after adding a icon

Traceback (most recent call last):
  File "/usr/local/bin/p4a", line 9, in <module>
    load_entry_point('python-for-android==0.6.0', 'console_scripts', 'p4a')()
  File "/usr/local/lib/python2.7/dist-packages/pythonforandroid/toolchain.py", line 975, in main
    ToolchainCL()
  File "/usr/local/lib/python2.7/dist-packages/pythonforandroid/toolchain.py", line 512, in __init__
    getattr(self, args.subparser_name.replace('-', '_'))(args)
  File "/usr/local/lib/python2.7/dist-packages/pythonforandroid/toolchain.py", line 150, in wrapper_func
    func(self, args)
  File "/usr/local/lib/python2.7/dist-packages/pythonforandroid/toolchain.py", line 785, in apk
    gradlew = sh.Command('./gradlew')
  File "/usr/local/lib/python2.7/dist-packages/sh.py", line 1028, in __init__
    raise CommandNotFound(path)
sh.CommandNotFound: ./gradlew

I didn’t install ant using apt, so, I add ant in PATH, and use ant instead of gradle. and get this error

[INFO]:    Will compile for the following archs: armeabi-v7a
[INFO]:    Found Android API target in $ANDROIDAPI
[INFO]:    Available Android APIs are (25, 26, 27)
[INFO]:    Requested API target 26 is available, continuing.
[INFO]:    Found NDK dir in $ANDROIDNDK
[INFO]:    Got NDK version from $ANDROIDNDKVER
[INFO]:    Using Google NDK r15c
[INFO]:    Found virtualenv at /usr/local/bin/virtualenv
[INFO]:    Found the following toolchain versions: ['4.9']
[INFO]:    Picking the latest gcc toolchain, here 4.9
[INFO]:    Of the existing distributions, the following meet the given requirements:
[INFO]:    	unnamed_dist_6: includes recipes (hostpython2, sdl2_image, sdl2_mixer, sdl2_ttf, python2, sdl2, six, pyjnius, kivy), built for archs (armeabi-v7a)
[INFO]:    unnamed_dist_6 has compatible recipes, using this one
[INFO]:    Of the existing distributions, the following meet the given requirements:
[INFO]:    	unnamed_dist_6: includes recipes (hostpython2, sdl2_image, sdl2_mixer, sdl2_ttf, python2, sdl2, six, pyjnius, kivy), built for archs (armeabi-v7a)
[INFO]:    unnamed_dist_6 has compatible recipes, using this one
[INFO]:    -> directory context /home/millon/.local/share/python-for-android/dists/unnamed_dist_6
[INFO]:    -> running ant debug
           working: Total time: 10 seconds                                                                   Exception in thread background thread for pid 16514:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/local/lib/python2.7/dist-packages/sh.py", line 2170, in background_thread
    handle_exit_code(exit_code)
  File "/usr/local/lib/python2.7/dist-packages/sh.py", line 1929, in fn
    return self.command.handle_command_exit_code(exit_code)
  File "/usr/local/lib/python2.7/dist-packages/sh.py", line 672, in handle_command_exit_code
    raise exc
ErrorReturnCode_1: 

  RAN: /home/millon/install/apache-ant-1.10.1/bin/ant debug

  STDOUT:
Buildfile: /home/millon/.local/share/python-for-android/dists/unnamed_dist_6/build.xml

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 25.2.5
 [checkenv] Installed at /home/millon/install/tools_r25.2.5-linux

-setup:
     [echo] Project Name: Myapplication-0.1
  [gettype] Project Type: Application

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:
     [copy] Copying 24 files to /home/millon/.local/share/python-for-android/dists/unnamed_dist_6/tmp-src

-build-setup:
[getbuildtools] Using latest Build Tools: 27.0.0
     [echo] Resolving Build Target for Myapplication-0.1...
[gettarget] Project Target:   Android 8.0.0
[gettarget] API level:        26
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: /home/millon/.local/share/python-for-android/dists/unnamed_dist_6/bin
    [mkdir] Created dir: /home/millon/.local/share/python-for-android/dists/unnamed_dist_6/bin/res
    [mkdir] Created dir: /home/millon/.local/share/python-for-android/dists/unnamed_dist_6/bin/rsObj
    [mkdir] Created dir: /home/millon/.local/share/python-for-android/dists/unnamed_dist_6/bin/rsLibs
    [mkdir] Created dir: /home/millon/.local/share/python-for-android/dists/unnamed_dist_6/gen
    [mkdir] Created dir: /home/millon/.local/share/python-for-android/dists/unnamed_dist_6/bin/classes
    [mkdir] Created dir: /home/millon/.local/share/python-for-android/dists/unnamed_dist_6/bin/dexedLibs
     [echo] ----------
     [echo] Resolving Dependencies for Myapplication-0.1...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency] 
[dependency] ------------------
     [echo] ----------
     [echo] Building Libraries with 'debug'...
   [subant] No sub-builds to iterate on

-code-gen:
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
     [echo] Handling aidl files...
     [aidl] No AIDL files to compile.
     [echo] ----------
     [echo] Handling RenderScript files...
     [echo] ----------
     [echo] Handling Resources...
     [aapt] Generating resource IDs...
     [echo] ----------
     [echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.

-pre-compile:

-compile:
    [javac] Compiling 26 source files to /home/millon/.local/share/python-for-android/dists/unnamed_dist_6/bin/classes
    [javac] warning: [options] source value 1.5 is obsolete and will be removed in a future release
    [javac] warning: [options] target value 1.5 is obsolete and will be removed in a future release
    [javac] warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
    [javac] /home/millon/.local/share/python-for-android/dists/unnamed_dist_6/tmp-src/org/kivy/android/PythonService.java:97: error: cannot find symbol
    [javac]         notification.setLatestEventInfo(context, serviceTitle, serviceDescription, pIntent);
    [javac]                     ^
    [javac]   symbol:   method setLatestEventInfo(Context,String,String,PendingIntent)
    [javac]   location: variable notification of type Notification
    [javac] Note: Some input files use or override a deprecated API.
    [javac] Note: Recompile with -Xlint:deprecation for details.
    [javac] 1 error
    [javac] 3 warnings

BUILD FAILED
/home/millon/install/tools_r25.2.5-linux/tools/ant/build.xml:716: The following error occurred while executing this line:
/home/millon/install/tools_r25.2.5-linux/tools/ant/build.xml:730: Compile failed; see the compiler error output for details.

Total time: 10 seconds


  STDERR:


[INFO]:    STDOUT (last 20 lines of 81):                                                                     
	-compile:	
    [javac] Compiling 26 source files to /home/millon/.local/share/python-for-android/dists/unnamed_dist_6/bin/classes	
    [javac] warning: [options] source value 1.5 is obsolete and will be removed in a future release	
    [javac] warning: [options] target value 1.5 is obsolete and will be removed in a future release	
    [javac] warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.	
    [javac] /home/millon/.local/share/python-for-android/dists/unnamed_dist_6/tmp-src/org/kivy/android/PythonService.java:97: error: cannot find symbol	
    [javac]         notification.setLatestEventInfo(context, serviceTitle, serviceDescription, pIntent);	
    [javac]                     ^	
    [javac]   symbol:   method setLatestEventInfo(Context,String,String,PendingIntent)	
    [javac]   location: variable notification of type Notification	
    [javac] Note: Some input files use or override a deprecated API.	
    [javac] Note: Recompile with -Xlint:deprecation for details.	
    [javac] 1 error	
    [javac] 3 warnings	
	
BUILD FAILED	
/home/millon/install/tools_r25.2.5-linux/tools/ant/build.xml:716: The following error occurred while executing this line:	
/home/millon/install/tools_r25.2.5-linux/tools/ant/build.xml:730: Compile failed; see the compiler error output for details.	
	
Total time: 10 seconds
[INFO]:    STDERR:
	
[INFO]:    COMMAND:
cd /home/millon/.local/share/python-for-android/dists/unnamed_dist_6 && /home/millon/install/apache-ant-1.10.1/bin/ant debug

[WARNING]: ERROR: /home/millon/install/apache-ant-1.10.1/bin/ant failed!

I was able to fix this problem using android api version 22 (setLatestEventInfo was removed in api 23). now, I can build, both launcher and app. launcher open, but app crash on opening. I will post logcat later.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
QuadTrianglecommented, Dec 21, 2017

@inclement oh, thanks. I am happy that you are working on this issue, even, after closing it. even, my last issue will be fixed by #1197

I have found a bug in setup.py https://github.com/kivy/python-for-android/blob/2b3d52bacd33992e040b39121221fa5dc55b86dd/setup.py#L46-L49 that’s why, installed version doesn’t include assets and drawable folder, gladlew and gladlew.bat file. I was able to fix the installation by adding '.gitkeep', 'gradlew*', here.

~I still don’t know why dists doesn’t contain assets and drawable folder, gladlew and gladlew.bat file.~

edit:

I have opened PR #1204 and #1205 to fix all my remaining issues.

0reactions
QuadTrianglecommented, Dec 31, 2017

@lrq3000 please see my PR #1204 and #1205 I have already fixed those errors.

pip install -U https://github.com/QuadTriangle/python-for-android/tarball/master
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to solve my Buildozer Error in Ubuntu? - Stack Overflow
for me, the issue was the shared folder. I used Ubuntu on VirtualBox, I copied the files from the shared folder to the...
Read more >
Getting Started — python-for-android 0.1 documentation
p4a can contain multiple distributions with different sets of requirements. build: A build refers to a compiled recipe or distribution. bootstrap: A bootstrap ......
Read more >
Persona 4 Arena Ultimax - PCGamingWiki PCGW
Persona 4 Arena Ultimax is a singleplayer and multiplayer side view arcade , fighting ... Press L or O at "Button Settings" for...
Read more >
Fix Kivy Buildozer Issue - Local and Cloud based ... - YouTube
Over the last few weeks, all the videos related to Kivy has a comment saying that the Buildozer issue is present when trying...
Read more >
buildozer - PyPI
Installing Buildozer with target Python 3 (default): ... Gradlew Build error for Android on Linux #1371 ... #706; APK using txt file in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found