Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with Android API 23 #573

Closed
agaleazzi opened this issue Oct 13, 2017 · 3 comments
Closed

Problem with Android API 23 #573

agaleazzi opened this issue Oct 13, 2017 · 3 comments

Comments

@agaleazzi
Copy link

agaleazzi commented Oct 13, 2017

I need to use the package android.media.midi introduced with API Level 23. So I wrote a JAVA class containing the statement:
import android.media.midi.MidiManager
and I added the file to android.add_src in buildozer.spec
android.add_src = ./jlib/MidiOutFacade.java
Furthermore I also changed this section:

# (int) Android API to use
android.api = 19

# (int) Minimum API required
android.minapi = 23

# (int) Android SDK version to use
android.sdk = 23

# (str) Android NDK version to use
android.ndk = 9c`
But I've got the following error:
-compile:	
    [javac] Compiling 27 source files to /home/osboxes/PycharmProjects/MyPrj/.buildozer/android/platform/build/dists/MyPrj/bin/classes	
    [javac] /home/osboxes/PycharmProjects/MyPrj/.buildozer/android/platform/build/dists/MyPrj/tmp-src/MidiOutFacade.java:5: error: package android.media.midi does not exist	
    [javac] import android.media.midi.MidiManager;	
    [javac]                          ^	
    [javac] Note: Some input files use or override a deprecated API.	
    [javac] Note: Recompile with -Xlint:deprecation for details.	
    [javac] 1 error	
	
BUILD FAILED	
/home/osboxes/.buildozer/android/platform/android-sdk-23/tools/ant/build.xml:716: The following error occurred while executing this line:	
/home/osboxes/.buildozer/android/platform/android-sdk-23/tools/ant/build.xml:730: Compile failed; see the compiler error output for details.	

It seems reasonable because it still use api 19, but when I changed also androd.api = 23 I've got a more weird error (complete log):

# Check configuration tokens
# Ensure build layout
# Check configuration tokens
# Preparing build
# Check requirements for android
# Run 'dpkg --version'
# Cwd None
Debian 'dpkg' package management program version 1.18.4 (amd64).
This is free software; see the GNU General Public License version 2 or
later for copying conditions. There is NO warranty.
# Search for Git (git)
#  -> found at /usr/bin/git
# Search for Cython (cython)
#  -> found at /usr/local/bin/cython
# Search for Java compiler (javac)
#  -> found at /usr/lib/jvm/java-8-openjdk-amd64/bin/javac
# Search for Java keytool (keytool)
#  -> found at /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/keytool
# Install platform
# Run 'pip install -q --user "appdirs" "colorama>=0.3.3" "sh>=1.10,<1.12.5" "jinja2" "six"'
# Cwd None
# Apache ANT found at /home/osboxes/.buildozer/android/platform/apache-ant-1.9.4
# Android SDK found at /home/osboxes/.buildozer/android/platform/android-sdk-23
# Android NDK found at /home/osboxes/.buildozer/android/platform/android-ndk-r9c
# Check application requirements
# Check garden requirements
# Compile platform
# Run '/usr/bin/python -m pythonforandroid.toolchain create --dist_name=QuarterToneNew --bootstrap=sdl2 --requirements=kivy,pyjnius --arch armeabi-v7a --copy-libs --color=always --storage-dir=/home/osboxes/PycharmProjects/MyPrj/.buildozer/android/platform/build'
# Cwd /home/osboxes/PycharmProjects/MyPrj/.buildozer/android/platform/python-for-android-master
[INFO]:    Will compile for the following archs: armeabi-v7a
[INFO]:    Found Android API target in $ANDROIDAPI
[INFO]:    Available Android APIs are (19, 23, 26)
[INFO]:    Requested API target 23 is available, continuing.
[INFO]:    Found NDK dir in $ANDROIDNDK
[INFO]:    Got NDK version from $ANDROIDNDKVER
[INFO]:    Using Google NDK r9c
[INFO]:    Found virtualenv at /home/osboxes/.local/bin/virtualenv
[WARNING]: ndk_platform doesn't exist: /home/osboxes/.buildozer/android/platform/android-ndk-r9c/platforms/android-23/arch-arm
[INFO]:    Found the following toolchain versions: ['4.6', '4.8', 'clang3.3']
[INFO]:    Picking the latest gcc toolchain, here 4.8
[ERROR]:   3python-for-android cannot continue; aborting
# Command failed: /usr/bin/python -m pythonforandroid.toolchain create --dist_name=MyPrj--bootstrap=sdl2 --requirements=kivy,pyjnius --arch armeabi-v7a --copy-libs --color=always --storage-dir=/home/osboxes/PycharmProjects/MyPrj/.buildozer/android/platform/build
# 
# 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 also tried to set a more recent NDK, but buildozer isn't able to download it.
Did anyone ever try to use api level 23?

@micahjohnson150
Copy link

I am not sure but I don't think 9c will work with API 23. I successfully use API 22 and NDK 10c using python 2. Based on this link sounds like maybe you could get away with 10C or 10e as well. You might give it a try.

https://stackoverflow.com/questions/34124668/ndk-for-the-android-6-0-api

@tito
Copy link
Member

tito commented Dec 15, 2017

This issue got fixed in python-for-android

@tito tito closed this as completed Dec 15, 2017
@guysoft
Copy link
Contributor

guysoft commented Jul 25, 2023

I can access this class using something like this:

from jnius import autoclass, cast
from plyer.platforms.android import activity

"..."

print("Testing midi")
MidiManager = autoclass('android.media.midi.MidiManager')
# Context = autoclass('android.app.Application')
Context = autoclass('android.content.Context')
service = activity.getSystemService(Context.MIDI_SERVICE)
m = cast('android.media.midi.MidiManager', service)
print(m.getDevices())

Output is:

07-26 02:33:45.415  2167  2319 I python  : dprint: Testing midi
07-26 02:33:45.425  2167  2319 I python  : dprint: [<android.media.midi.MidiDeviceInfo at 0x6e09baff60 jclass=android/media/midi/MidiDeviceInfo jself=<LocalRef obj=0x5b72 at 0x6e09b696d0>>, <android.media.midi.MidiDeviceInfo at 0x6e09bafa60 jclass=android/media/midi/MidiDeviceInfo jself=<LocalRef obj=0x5b42 at 0x6e09b69730>>, <android.media.midi.MidiDeviceInfo at 0x6e09baf560 jclass=android/media/midi/MidiDeviceInfo jself=<LocalRef obj=0x5b22 at 0x6e09b69750>>]
07-26 02:33:45.425  2167  2319 I python  : dprint: Done

But I see no one wrote a wrapper for it. If someone could share it would be wonderful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants