gpt4 book ai didi

android - Flutter Plugin : crash_dump. cpp:无法附加到线程 185:权限被拒绝

转载 作者:行者123 更新时间:2023-12-04 23:42:41 26 4
gpt4 key购买 nike

我正在开发一个 Flutter 插件和一个简单的钢琴键盘布局,当 onKeyPressed 时调用 Flutter 插件和 onKeyUp钢琴键。钢琴应用程序可以在模拟器中运行,并且可以产生声音。但是,有时,应用程序会崩溃并显示错误消息:

F/crash_dump32(22593): crash_dump.cpp:474] failed to attach to thread 185: Permission denied
在模拟器中,弹出警告显示 System UI isn't responding带选项: Close the appWait .
如果我选择 Wait ,它将恢复工作,直到相同的线程错误再次出现。
在我的实现中,我有一个用 Kotlin 编写的类,它将在一个线程中运行:
class Synth : Runnable {
private lateinit var mThread: Thread
private var mRunning = false
private var mFreq = 440.0
private var mAmp = 0.0
private var mNumKeysDown = 0


fun start() {
mThread = Thread(this)
mRunning = true
mThread.start()
}

fun stop() {
mRunning = false
}

fun keyDown(key: Int): Int {
mFreq = Math.pow(1.0594630f.toDouble(), key.toDouble() - 69.0) * 440.0
mAmp = 1.0
mNumKeysDown += 1
return mNumKeysDown
}
}
以下是 Synth类是从用 Kotlin 编写的插件调用的:
  • 当插件从 Flutter 客户端启动时:
  • class PianoPlugin: FlutterPlugin, MethodCallHandler {

    fun setup(plugin: PianoPlugin, binaryMessenger: BinaryMessenger) {
    plugin.channel = MethodChannel(channelName)
    plugin.channel.setMethodCallHandler(plugin)
    plugin.synth = Synth()
    plugin.synth.start() // <- Start the thread
    }
      override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) {
    if (call.method == "getPlatformVersion") {
    result.success(android.os.Build.VERSION.RELEASE)
    } else if (call.method == "onKeyDown"){
    try {
    val arguments: ArrayList<Int> = call.arguments as ArrayList<Int>
    val numKeysDown: Int = synth.keyDown(arguments.get(0) as Int) // <- Function call

    result.success(numKeysDown)
    } catch (ex: Exception) {
    result.error("100", ex.message, ex.getStackTrace())
    }
    }
    我想知道是否有人遇到过类似的线程问题,可以分享一些可能原因的见解。非常感激!

    最佳答案

    我通过冷启动模拟器解决了它。

    关于android - Flutter Plugin : crash_dump. cpp:无法附加到线程 185:权限被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67755231/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com