Skip to content

failed to setup p4a on ubuntu (multiple issues) #1191

@QuadTriangle

Description

@QuadTriangle

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions