在 Android 中使用 LibPhoneNumber google lib
库 libphonenumber 无法在 Android 上运行,异常情况如下: “由以下原因引起:java.lang.UnsupportedOperationException:不支持 CANON_EQ 标志”
网页中的描述说该库适用于“智能手机”,但 Android 不支持 CANON_EQ reg_ex 标志。
我错过了什么吗?
The library libphonenumber doesn't work on Android and the exception says:
"Caused by: java.lang.UnsupportedOperationException: CANON_EQ flag not supported"
The description in the webpage says that the lib is for "Smartphones" but Android doesn't support CANON_EQ reg_ex flag..
Am I missing something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
如果您使用的是 Android studio,请使用
implementation 'com.googlecode.libphonenumber:libphonenumber:8.12.32'
如果您想下载最新的 JAR 文件,请转到
http://mvnrepository.com/artifact/com.googlecode.libphonenumber/libphonenumber
If you're using Android studio use
implementation 'com.googlecode.libphonenumber:libphonenumber:8.12.32'
If you want to download the latest JAR file goto
http://mvnrepository.com/artifact/com.googlecode.libphonenumber/libphonenumber
您好,请使用此功能传递电话号码和国家代码,例如印度 91
Hi Please use this function to pass phone number and country code like india 91
请尝试使用下载页面中的 libphonenumber-2.5.1.jar:
http://code.google.com/p /libphonenumber/downloads/list
Right-Number 项目中的 jar 可以工作,因为它们使用的是 libphonenumber-2.4.jar。 CANON_EQ 标志是在 v2.5 中引入的,但现在已从 2.5.1 中删除,以便与 Android 兼容,直到它支持该标志。
Please try using libphonenumber-2.5.1.jar from the download page:
http://code.google.com/p/libphonenumber/downloads/list
The jar from the Right-Number project works because they are using libphonenumber-2.4.jar. The CANON_EQ flag was introduced in v2.5, but is now removed from 2.5.1 to be compatible with Android until it supports the flag.
编译 'com.googlecode.libphonenumber:libphonenumber:7.1.1'
在你的 gradle 中使用此依赖项。
检查这个https://github.com/googlei18n/libphonenumber
compile 'com.googlecode.libphonenumber:libphonenumber:7.1.1'
Use this dependency in you gradle.
check this https://github.com/googlei18n/libphonenumber
在安卓上:
On android :
我自己也曾遇到过同样的问题,并且能够使用以下版本解决它:
http://code.google.com/p/right-number/source/browse/trunk/RightNumber/libs/libphonenumber.jar
此版本是来自 Right-Number 项目,该项目旨在构建一个用于处理电话号码的用户界面在 Android 上格式化。
我已经在我的项目中使用了它并且运行良好。
I've struggled with the exact same question myself, and was able to solve it by using the following version:
http://code.google.com/p/right-number/source/browse/trunk/RightNumber/libs/libphonenumber.jar
This version is from the Right-Number project that aims to build a user interface for dealing with phone number formatting on Android.
I've used it in my project and it works fine.
提交问题:
http://code.google.com/p/libphonenumber/issues/ list
我在最新版本中遇到了类似的问题,他们很快就回答了我的问题。这绝对只是一个已经出现的错误,如果你想修复它,你应该报告它。他们花了 10 分钟才承认我的问题,15 分钟后他们说他们已经准备好了补丁。
Right-Number 上的罐子只是一个较旧的版本。
Submit an issue at:
http://code.google.com/p/libphonenumber/issues/list
I had a similar issue with the newest revision and they were very fast with answering my issue. It's definitely just a bug which has surfaced and you should report it if you want it fixed. Took them 10 minutes to acknowledge my issue and 15 min after that they said they had a patch ready for it.
The jar at Right-Number is just an older revision.
新版本的 libphonenumber http://code.google.com/p/libphonenumber/ 是为 Java 1.5 编译,现在可以在较旧的 Android 系统上运行。
以前的版本是针对 Java 1.6 编译的,但您可以使用提供的源代码为任何版本重新编译。
The new version of libphonenumber http://code.google.com/p/libphonenumber/ is compiled for Java 1.5 and will now work on older android systems.
Previous versions were compiled for Java 1.6, but you could have re-compiled for any version using the supplied source code.