当我尝试通过Buildozer初始化android Visualizer时出现密码错误

时间:2019-06-18 09:18:00

标签: java android python buildozer pyjnius

我在Python上有一些现有代码,并希望使用Kivy和Buildozer将其移植到android。 但是,我对本地android类“ Visualizer”有依赖性。 我的应用程序正确启动,但是当我在应用程序中单击“运行”按钮时,当我在Java中使用以下代码时会出现此错误

new Visualizer(0);

Visualizer = autoclass('[visualizer.class.....]')
v = Visualizer(0)

在python中

我授予了所有必需的运行时权限,例如RECORD_AUDIO,MODIFY_AUDIO和INTERNET

ERROR:
06-18 11:25:46.852 24619 24619 D VisualDj: Called set_on_data_capture_listener
06-18 11:25:46.892 24619 24619 D VisualDj: setPlayer1
06-18 11:25:46.968 24622 24622 I crash_dump32: performing dump of process 24619 (target tid = 24619)
06-18 11:25:46.969 24622 24622 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
06-18 11:25:46.969 24622 24622 F DEBUG   : Build fingerprint: 'HONOR/PRA-TL10/HWPRA-H:8.0.0/HONORPRA-TL10/373(C10):user/release-keys'
06-18 11:25:46.969 24622 24622 F DEBUG   : Revision: '0'
06-18 11:25:46.969 24622 24622 F DEBUG   : ABI: 'arm'
06-18 11:25:46.969 24622 24622 F DEBUG   : pid: 24619, tid: 24619, name: SDLThread  >>> org.vd.visualdj <<<
06-18 11:25:46.969 24622 24622 F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xd03a6020
06-18 11:25:46.969 24622 24622 F DEBUG   :     r0 00000000  r1 00000001  r2 00000000  r3 00000000
06-18 11:25:46.969 24622 24622 F DEBUG   :     r4 ef6e4540  r5 d03a6020  r6 00000018  r7 d03a6008
06-18 11:25:46.969 24622 24622 F DEBUG   :     r8 cd7f3dbc  r9 cd7f3dbc  sl 80047204  fp 00000000
06-18 11:25:46.969 24622 24622 F DEBUG   :     ip f50f0d94  sp cd7f3c88  lr f50cfc65  pc f50cf23a  cpsr 600b0030
06-18 11:25:47.268 24622 24622 F DEBUG   :
06-18 11:25:47.268 24622 24622 F DEBUG   : backtrace:
06-18 11:25:47.268 24622 24622 F DEBUG   :     #00 pc 0005223a  /system/lib/libbinder.so (_ZN7android6Parcel19ipcSetDataReferenceEPKhjPKyjPFvPS0_S2_jS4_jPvES6_+61)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #01 pc 00049347  /system/lib/libbinder.so (_ZN7android14IPCThreadState15waitForResponseEPNS_6ParcelEPi+350)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #02 pc 00048fd1  /system/lib/libbinder.so (_ZN7android14IPCThreadState8transactEijRKNS_6ParcelEPS1_j+152)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #03 pc 000419d1  /system/lib/libbinder.so (_ZN7android8BpBinder8transactEjRKNS_6ParcelEPS1_j+36)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #04 pc 0004bba3  /system/lib/libbinder.so (_ZNK7android16BpServiceManager12checkServiceERKNS_8String16E+74)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #05 pc 0004bacb  /system/lib/libbinder.so (_ZNK7android16BpServiceManager10getServiceERKNS_8String16E+190)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #06 pc 0002ba6d  /system/lib/libaudioclient.so (_ZN7android11AudioSystem17get_audio_flingerEv+144)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #07 pc 000276cd  /system/lib/libaudioclient.so (_ZN7android11AudioEffect3setEPK12audio_uuid_sS3_iPFviPvS4_ES4_15audio_session_ti+60)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #08 pc 0002767d  /system/lib/libaudioclient.so (_ZN7android11AudioEffectC1EPK12audio_uuid_sRKNS_8String16ES3_iPFviPvS7_ES7_15audio_session_ti+88)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #09 pc 000814e5  /system/lib/libmedia.so (_ZN7android10VisualizerC1ERKNS_8String16EiPFviPvS4_ES4_15audio_session_t+44)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #10 pc 000033bd  /system/lib/libaudioeffect_jni.so (_ZL37android_media_visualizer_native_setupP7_JNIEnvP8_jobjectS2_iP10_jintArrayP8_jstring+196)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #11 pc 00cbfc27  /system/framework/arm/boot-framework.oat (offset 0x5f6000) (android.media.audiofx.Visualizer.native_setup+150)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #12 pc 003e0931  /system/lib/libart.so (art_quick_invoke_stub_internal+64)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #13 pc 003e4ea3  /system/lib/libart.so (art_quick_invoke_stub+226)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #14 pc 000ac2d9  /system/lib/libart.so (_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+140)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #15 pc 001f27fb  /system/lib/libart.so (_ZN3art11interpreter34ArtInterpreterToCompiledCodeBridgeEPNS_6ThreadEPNS_9ArtMethodEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+238)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #16 pc 001edd71  /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+576)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #17 pc 003cb72d  /system/lib/libart.so (MterpInvokeDirect+356)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #18 pc 003d2d14  /system/lib/libart.so (ExecuteMterpImpl+14484)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #19 pc 001d5351  /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+340)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #20 pc 001da6a3  /system/lib/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+142)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #21 pc 001edd5b  /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+554)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #22 pc 003cb72d  /system/lib/libart.so (MterpInvokeDirect+356)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #23 pc 003d2d14  /system/lib/libart.so (ExecuteMterpImpl+14484)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #24 pc 001d5351  /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+340)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #25 pc 001da5f1  /system/lib/libart.so (_ZN3art11interpreter30EnterInterpreterFromEntryPointEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameE+92)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #26 pc 003c0fbd  /system/lib/libart.so (artQuickToInterpreterBridge+944)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #27 pc 003e46f1  /system/lib/libart.so (art_quick_to_interpreter_bridge+32)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #28 pc 003e0931  /system/lib/libart.so (art_quick_invoke_stub_internal+64)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #29 pc 003e4ea3  /system/lib/libart.so (art_quick_invoke_stub+226)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #30 pc 000ac2d9  /system/lib/libart.so (_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+140)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #31 pc 00334bb1  /system/lib/libart.so (_ZN3artL18InvokeWithArgArrayERKNS_33ScopedObjectAccessAlreadyRunnableEPNS_9ArtMethodEPNS_8ArgArrayEPNS_6JValueEPKc+52)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #32 pc 00335a2d  /system/lib/libart.so (_ZN3art35InvokeVirtualOrInterfaceWithJValuesERKNS_33ScopedObjectAccessAlreadyRunnableEP8_jobjectP10_jmethodIDP6jvalue+320)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #33 pc 0026d77d  /system/lib/libart.so (_ZN3art3JNI15CallVoidMethodAEP7_JNIEnvP8_jobjectP10_jmethodIDP6jvalue+436)
06-18 11:25:47.268 24622 24622 F DEBUG   :     #34 pc 00036b4f  /data/data/org.vd.visualdj/files/app/_python_bundle/site-packages/jnius/jnius.so

Python类(看起来错误不在这里)

import numpy as np
from jnius import autoclass, PythonJavaClass
from jnius.signatures import java_method

Log = autoclass('android.util.Log')
BaseAudio = autoclass('org.vd.VisualDj.BaseAudio')
base_audio = BaseAudio()


def set_on_data_capture_listener(callback):
    Log.d('VisualDj', 'Called set_on_data_capture_listener')

    class AudioListener(PythonJavaClass):
        __javainterfaces__ = ['android.media.audiofx.Visualizer$OnDataCaptureListener']

        @java_method('(Landroid/media/audiofx/Visualizer;[BI)V')
        def onWaveFormDataCapture(self, v, bytes, samplingRate):
            Log.d('VisualDj', 'Inside wave capture')
            try:
                y = np.asarray(bytes)
                y = y.astype(np.float32)
                callback(y)
            except IOError:
                print('IOError')

        @java_method('(Landroid/media/audiofx/Visualizer;[BI)V')
        def onFftDataCapture(self, v, bytes, samplingRate):
            pass

    base_audio.setPlayer(AudioListener())

Java类

public class BaseAudio {
    protected Visualizer visualizer;

    public void setPlayer(OnDataCaptureListener listener) {
        Log.d("VisualDj", "setPlayer1"); // This goes well
    try{
        visualizer = new Visualizer(0); // But this fails
    Log.d("VisualDj", "setPlayer0");
        visualizer.setCaptureSize(256);
        Log.d("VisualDj", "setPlayer2");
        visualizer.setDataCaptureListener((OnDataCaptureListener)listener, 12000, true, false);
        Log.d("VisualDj", "setPlayer3");
        visualizer.setEnabled(true);
        Log.d("VisualDj", "setPlayer4");
    }
    catch(Exception e){
        Log.e("VisualDj", "exception", e);
    }
    }

    public void release() {
        visualizer.release();
    }
}
My Buildozer config:
# (int) Target Android API, should be as high as possible.
android.api = 27

# (int) Minimum API your APK will support.
android.minapi = 21

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

# (str) Android NDK version to use
android.ndk = 17c

# (int) Android NDK API to use. This is the minimum API your app will support, it should usually match android.minapi.
android.ndk_api = 21

已编辑

我也忘了提到通过Android Studio进行部署时,上面提到的java类很好用

0 个答案:

没有答案