libphonenumber-android
May 7, 2026 ยท View on GitHub
libphonenumber-android
Android port of Google's libphonenumber.
Why?
Google's libphonenumber is a great library but it has a major flaw when used on Android.
Internally the library uses Class.getResourceAsStream() method, which is very slow on Android.
The goal of this library is to fix these two issues.
Download
Gradle:
repositories {
mavenCentral()
}
dependencies {
implementation 'io.michaelrocks:libphonenumber-android:9.0.30'
}
Development
Run unit checks with:
./gradlew check
Run instrumentation integration tests on the Gradle-managed local emulator with:
./gradlew integrationTest
For DexGuard users
If your project is obfuscated with DexGuard you may need to add the following line to the DexGuard configuration:
-keepresourcefiles assets/io/michaelrocks/libphonenumber/android/**
API differences
This library is not fully compatible with the original libphonenumber.
- Every
libphonenumberclass is repackaged toio.michaelrocks.libphonenumber.android. PhoneNumberUtildoesn't contain agetInstance()method so you have to create an instance of this class with one ofPhoneNumberUtil.createInstance()methods and store it somewhere.PhoneNumberUtilnow has acreateInstance(Context)method, which is a default way to obtain an instance of this class on Android.
License
Copyright 2025 Michael Rozumyanskiy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.