android kivy libmtdev.so.1 丢失问题排故记

在直接将LRC的Client代码复制到android手机上,采用pydroid运行时,运行中会出现一个错误:libmtdev.so.1 无法打开

那么发散一下,无法打开可能存在原因:

1、没有该文件?

2、没有权限?(排除,理由:其他库都可以正常加载)

那么没有该文件的解决思路:

1、安装mtdev库(排除:搜索过程中并未找到安装方法)

2、替代库

那么如何替代呢?

于是去kivy的文档里搜索了一番,看到了一个Python mtdev,先看看他是啥

 

Module: kivy.lib.mtdev

Added in 1.0.0

The mtdev module provides Python bindings to the Kernel multi-touch transformation library, also known as mtdev (MIT license).

The mtdev library transforms all variants of kernel MT events to the slotted type B protocol. The events put into mtdev may be from any MT device, specifically type A without contact tracking, type A with contact tracking, or type B with contact tracking. See the kernel documentation for further details.

Warning

This is an external library and Kivy does not provide any support for it. It might change in the future and we advise you don’t rely on it in your code.

 

那么我们可以看到,是 1.0.0 版本引入的一个多点触控转换的第三方库,这里记录下 Provider 这个关键字,应该只要有这个 Provider 的,一般都是第三方的, kivy 不负责维护的。

既然是第三方,除了mtdev还有其他的第三方库吧?

继续看前面的搜索结果,发现了这一项Auto Create Input Provider Config Entry for Available MT Hardware (linux only).

引起我注意的是 Config,那么 Config 是什么呢?

在 Programming Guide 里面有这么一项:Configure Kivy (当然,之前看 kivy 的文档时也看到过 Config 这个类),

 

The Config object is an instance of a modified Python ConfigParser. See the ConfigParser documentation for more information.

Kivy has a configuration file which determines the default settings. In order to change these settings, you can alter this file manually or use the Config object. Please see the Configure Kivy section for more information.

 

那么 Config 就是用来配置kivy的,既然是配置 kivy 的,那么就应该能够配置 kivy 使用哪个第三方库,于是我们回到前面的链接

Auto Create Input Provider Config Entry for Available MT Hardware (linux only)

[input]
# using mtdev
device_%(name)s = probesysfs,provider=mtdev
# using hidinput
device_%(name)s = probesysfs,provider=hidinput
# using mtdev with a match on name
device_%(name)s = probesysfs,provider=mtdev,match=acer

我们不适用mtdev,于是将示例文件中的hidinput部分保留,得到了

[input]
# using hidinput
device_%(name)s = probesysfs,provider=hidinput

保存为 config.ini 即可

 

那么最后就是将这个配置应用生效了,那么这里得谢谢kivy的文档了,我们再回去看看 Configure kivy 中是如何配置的

Local configuration

Sometimes it’s desired to change configuration only for certain applications or during testing of a separate part of Kivy for example input providers. To create a separate configuration file you can simply use these commands:

from kivy.config import Config

Config.read(<file>)
# set config
Config.write()

于是我们找到了本地配置的代码,添加到主程序中即可。

BTW,Config.write() 可以删掉,至于他是干什么的,不删掉试试就知道了(手动滑稽)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值