Android port of Google's libphonenumber

Overview

Build Status Android Arsenal

libphonenumber-android

Android port of Google's libphonenumber.

Why?

Google's libphonenumber is a great library but it has to major flaws when used on Android:

  1. It adds about 7k methods to a final dex. Not anymore, since 7.7.0.
  2. 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:8.12.39'
}

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.

  1. Every libphonenumber class is repackaged to io.michaelrocks.libphonenumber.android.
  2. PhoneNumberUtil doesn't contain a getInstance() method so you have to create an instance of this class with one of PhoneNumberUtil.createInstance() methods and store it somewhere.
  3. PhoneNumberUtil now has a createInstance(Context) method, which is a default way to obtain an instance of this class on Android.

License

Copyright 2017 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.
Comments
  • IllegalStateException: missing metadata

    IllegalStateException: missing metadata

    I got this exception:

    java.lang.IllegalStateException: missing metadata: /io/michaelrocks/libphonenumber/android/data/PhoneNumberMetadataProto_PR at io.michaelrocks.libphonenumber.android.MetadataManager.getMetadataFromSingleFileName(MetadataManager.java:122) at io.michaelrocks.libphonenumber.android.MetadataManager.getMetadataFromMultiFilePrefix(MetadataManager.java:108) at io.michaelrocks.libphonenumber.android.MultiFileMetadataSourceImpl.getMetadataForRegion(MultiFileMetadataSourceImpl.java:72) at io.michaelrocks.libphonenumber.android.PhoneNumberUtil.getMetadataForRegion(PhoneNumberUtil.java:2232) at io.michaelrocks.libphonenumber.android.PhoneNumberUtil.getCountryCodeForValidRegion(PhoneNumberUtil.java:2393) at io.michaelrocks.libphonenumber.android.PhoneNumberUtil.getCountryCodeForRegion(PhoneNumberUtil.java:2381)

    opened by mohalaci 9
  • Vodafone & Ooredoo in Oman is not verified

    Vodafone & Ooredoo in Oman is not verified

    @MichaelRocks , As Vodafone started providing services in Oman but this API is not updated. Please update this so new numbers of Oman can be verified.

    opened by HafizZaroonR 6
  • Move away from jcenter since it'll be shutdown on May 1st 2021

    Move away from jcenter since it'll be shutdown on May 1st 2021

    https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/

    This is unfortunate, but there's not much we can do other than moving away from it. Here's a couple of links that might help with the migration:

    https://chris.banes.dev/publishing-to-maven-central/ https://github.com/autonomousapps/dependency-analysis-android-gradle-plugin/blob/main/PUBLISHING.asciidoc

    opened by tfcporciuncula 5
  • Upgrading to android gradle plugin version above 3.1.4 breaks library

    Upgrading to android gradle plugin version above 3.1.4 breaks library

    When updating to gradle 4.6 and gradle plugin 3.2.1 we get the following error

    java.lang.IllegalStateException: missing metadata: /io/michaelrocks/libphonenumber/android/data/PhoneNumberMetadataProto_US
    
    	at io.michaelrocks.libphonenumber.android.MetadataManager.getMetadataFromSingleFileName(MetadataManager.java:122)
    	at io.michaelrocks.libphonenumber.android.MetadataManager.getMetadataFromMultiFilePrefix(MetadataManager.java:108)
    	at io.michaelrocks.libphonenumber.android.MultiFileMetadataSourceImpl.getMetadataForRegion(MultiFileMetadataSourceImpl.java:72)
    	at io.michaelrocks.libphonenumber.android.PhoneNumberUtil.getMetadataForRegion(PhoneNumberUtil.java:2228)
    	at io.michaelrocks.libphonenumber.android.PhoneNumberUtil.parseHelper(PhoneNumberUtil.java:3183)
    	at io.michaelrocks.libphonenumber.android.PhoneNumberUtil.parse(PhoneNumberUtil.java:3042)
    	at io.michaelrocks.libphonenumber.android.PhoneNumberUtil.parse(PhoneNumberUtil.java:3032)
    	at co.switchapp.objects.PhoneNumber$Companion.formatWithParentheses(PhoneNumber.kt:157)
    	at co.switchapp.objects.PhoneNumber.getFormattedWithParenthesesAndOptionalLabel(PhoneNumber.kt:92)
    	at co.switchapp.objects.PhoneNumber.getFormattedWithParenthesesAndLabel(PhoneNumber.kt:85)
    	at co.switchapp.objects.Contact.getFormattedPrimaryPhoneWithLabel(Contact.kt:886)
    	at co.switchapp.objects.ContactTest.phoneNumbersFormattedWithLabel(ContactTest.kt:24)
    
    opened by leofirespotter 5
  • Version 7.7.0 is not available on JCenter

    Version 7.7.0 is not available on JCenter

    Hi, I've noticed you update the library to 7.7.0 and it's awesome. The issue is that in Readme file you updated version to 7.7.0 but it's not available on JCenter where the latest is still 7.6.1

    opened by volodia-chornenkyy 5
  • NZ Govt's COVID-19 tracing app using libphonenumber with no attribution

    NZ Govt's COVID-19 tracing app using libphonenumber with no attribution

    Hi there, I've been looking into the New Zealand Government's COVID-19 tracing app, which was released today. After decompiling the main classes.dex, I noticed io.michaelrocks.libphonenumber.android in the package.

    I haven't been able to find any attribution notices for any libraries being used - their attribution and copyright page only covers attribution of images taken through the app, and shouts-out their development team. I additionally noticed at least 4 other Apache 2.0-licensed libraries in use.

    Not sure if this is a concern to you or not, but figured I should let you know.

    opened by kaisparkle 4
  • Update files

    Update files

    updating files to follow Google implementation v8.10.5 of Feb 08, 2019.

    Follow the Google Release Notes: Feb 06, 2019: v8.10.5 Metadata changes:

    • Updated phone metadata for region code(s): AE, AG, AI, AM, AR, AS, AT, AU, AZ, BA, BB, BE, BG, BM, BO, BR, BS, BT, BW, BY, CG, CH, CL, CO, DE, DM, DZ, ES, FI, FR, GB, GD, GE, GR, GU, HN, HR, IE, IL, IN, IT, JM, JO, JP, KG, KN, KP, KR, KY, LC, LI, LK, LT, LU, MA, MC, MD, MG, MM, MP, MS, MU, MV, MW, MX, MY, NA, NC, NE, NF, NL, NO, NZ, PE, PH, PL, PY, RO, RU, SA, SB, SC, SE, SG, SI, SK, SM, SN, SO, SR, SX, TC, TJ, TM, TO, TR, TT, TZ, UG, UY, VC, VG, VI, VN, XK, ZM, ZW
    • Updated short number metadata for region code(s): BR, TH
    • Updated geocoding data for country calling code(s): 54 (en), 55 (en, pt)
    • Updated carrier data for country calling code(s): 55 (en)
    • Updated / refreshed time zone meta data.

    Jan 24, 2019: v8.10.4 Metadata changes:

    • Updated phone metadata for region code(s): AR, AT, BH, BI, CL, CN, CW, CZ, DE, FI, FM, HK, KR, LA, LU, ML, NC, NE, PA, SB, TT, ZW
    • Updated short number metadata for region code(s): AR, KR
    • Updated geocoding data for country calling code(s): 54 (en, es), 686 (en)
    • Updated carrier data for country calling code(s): 254 (en), 507 (en), 599 (en), 880 (en)

    Jan 08, 2019: v8.10.3 Code changes:

    • Better documentation for getLengthOfNationalDestinationCode to emphasise that not every number has one.
    • Removed unused code in the AsYouTypeFormatter: We no longer have numbers in formatting matching patterns, only \d. Metadata changes:
    • Updated phone metadata for region code(s): EG, GM, HK, LR, MM, NG, SD, UZ, VN, VU
    • Updated geocoding data for country calling code(s): 249 (en)
    • Updated carrier data for country calling code(s): 84 (en), 95 (en), 220 (en), 231 (en), 852 (en, zh, zh_Hant), 965 (ar)
    • Updated / refreshed time zone meta data.

    Dec 06, 2018: v8.10.2 Metadata changes:

    • Updated phone metadata for region code(s): 882, AE, AL, AR, BD, BR, CN, ID, IN, JM, LK, MG, MU, MX, OM, SI, UA, ZW
    • Updated short number metadata for region code(s): IN, MG, MX, SI
    • Updated geocoding data for country calling code(s): 52 (en, es), 261 (en)
    • Updated carrier data for country calling code(s): 66 (en), 91 (en), 386 (en), 968 (en)
    • Updated / refreshed time zone meta data.
    opened by mesquitaa 4
  • Updating metadata files

    Updating metadata files

    When testing the library I noticed that the MetaData file from Mexico was out of date, so I updated it.

    The old metadata version did not validate city code 56 phones.

    Updated to others metadata according to v8.10.5 release 02/06/19 from google library.

    Release details from google library:

    Feb 06, 2019: v8.10.5 Metadata changes:

    • Updated phone metadata for region code(s): AE, AG, AI, AM, AR, AS, AT, AU, AZ, BA, BB, BE, BG, BM, BO, BR, BS, BT, BW, BY, CG, CH, CL, CO, DE, DM, DZ, ES, FI, FR, GB, GD, GE, GR, GU, HN, HR, IE, IL, IN, IT, JM, JO, JP, KG, KN, KP, KR, KY, LC, LI, LK, LT, LU, MA, MC, MD, MG, MM, MP, MS, MU, MV, MW, MX, MY, NA, NC, NE, NF, NL, NO, NZ, PE, PH, PL, PY, RO, RU, SA, SB, SC, SE, SG, SI, SK, SM, SN, SO, SR, SX, TC, TJ, TM, TO, TR, TT, TZ, UG, UY, VC, VG, VI, VN, XK, ZM, ZW
    • Updated short number metadata for region code(s): BR, TH
    • Updated geocoding data for country calling code(s): 54 (en), 55 (en, pt)
    • Updated carrier data for country calling code(s): 55 (en)
    • Updated / refreshed time zone meta data.

    Jan 24, 2019: v8.10.4 Metadata changes:

    • Updated phone metadata for region code(s): AR, AT, BH, BI, CL, CN, CW, CZ, DE, FI, FM, HK, KR, LA, LU, ML, NC, NE, PA, SB, TT, ZW
    • Updated short number metadata for region code(s): AR, KR
    • Updated geocoding data for country calling code(s): 54 (en, es), 686 (en)
    • Updated carrier data for country calling code(s): 254 (en), 507 (en), 599 (en), 880 (en)

    Jan 08, 2019: v8.10.3 Code changes:

    • Better documentation for getLengthOfNationalDestinationCode to emphasise that not every number has one.
    • Removed unused code in the AsYouTypeFormatter: We no longer have numbers in formatting matching patterns, only \d. Metadata changes:
    • Updated phone metadata for region code(s): EG, GM, HK, LR, MM, NG, SD, UZ, VN, VU
    • Updated geocoding data for country calling code(s): 249 (en)
    • Updated carrier data for country calling code(s): 84 (en), 95 (en), 220 (en), 231 (en), 852 (en, zh, zh_Hant), 965 (ar)
    • Updated / refreshed time zone meta data.

    Dec 06, 2018: v8.10.2 Metadata changes:

    • Updated phone metadata for region code(s): 882, AE, AL, AR, BD, BR, CN, ID, IN, JM, LK, MG, MU, MX, OM, SI, UA, ZW
    • Updated short number metadata for region code(s): IN, MG, MX, SI
    • Updated geocoding data for country calling code(s): 52 (en, es), 261 (en)
    • Updated carrier data for country calling code(s): 66 (en), 91 (en), 386 (en), 968 (en)
    • Updated / refreshed time zone meta data.
    opened by mesquitaa 4
  • Build release build failed

    Build release build failed

    My Jenkins told me that:

    Exception while processing task java.io.IOException: proguard.ParseException: Unknown option '-keepresourcefiles' in line 1 of file '/Users/jenkins-2/jenkins-slave/workspace/app/proguard/proguard-libphonenumber-android.pro'
    

    looks like -keepresourcefiles in-keepresourcefiles assets/io/michaelrocks/libphonenumber/android/** is not recognized. Does anyone encounter this?

    opened by cyberrob-zz 3
  • Oman Valid phone number shows a error

    Oman Valid phone number shows a error

    Oman latest phone number shows a error. Please Update the phone number validation for Oman. Sample Number : +968 77****** - > starts with 77 , 8 digit number. @MichaelRocks

    opened by ShilpaSankaralingam 2
  • Public API inconsistency

    Public API inconsistency

    com.google.i18n.phonenumbers.CountryCodeToRegionCodeMap.getCountryCodeToRegionCodeMap() has been public for some time but io.michaelrocks.libphonenumber.android.CountryCodeToRegionCodeMap.getCountryCodeToRegionCodeMap() is package private

    bug 
    opened by mklkj 2
Owner
Michael Rozumyanskiy
Michael Rozumyanskiy
Android port of Simon Tatham's Puzzles. *git replace in use* - you might want to {{ git fetch origin 'refs/replace/*:refs/replace/*' }}

This is the README accompanying the source code to Simon Tatham's puzzle collection. The collection's web site is at <https://www.chiark.greenend.org.

Chris Boyle 470 Dec 22, 2022
Freegemas libGDX is an Android and Java desktop port of Freegemas, which in turn is an open source version of the well known Bejeweled.

freegemas-gdx Freegemas libGDX is an Android, HTML 5 and Java desktop port of Freegemas, which in turn is an open source version of the well known Bej

David Saltares 144 Jun 21, 2022
Pw0 Framewrok - magical android pentest app 🔮! Pixie Dust, Handshakes, Deauth, Nmap, Port scanner and more!

Pw0 Framework Pw0 Framewrok - magical android pentest app ?? ! Features: Pixie Dust Handshakes Deauth Nmap Port scanner and more! Version: 0.2 Beta Au

Huntmix 17 Sep 27, 2021
Pw0 Framewrok - magical android pentest app 🔮! Pixie Dust, Handshakes, Deauth, Nmap, Port scanner and more!

Pw0 Framework Pw0 Framewrok - magical android pentest app ?? ! Features: Pixie Dust Handshakes Deauth Nmap Port scanner and more! Version: 0.2 Beta Au

Zalexdev 17 Sep 27, 2021
This application is android port to desktop applicaton Scrcpy.

scrcpy-android This application is android port to desktop applicaton Scrcpy. This application mirrors display and touch controls from a remote androi

狸小华 50 Dec 20, 2022
A semi-official port of the open source Anki spaced repetition flashcard system to Android

AnkiDroid A semi-official port of the open source Anki spaced repetition flashcard system to Android. Memorize anything with AnkiDroid! Features night

AnkiDroid 5.8k Dec 30, 2022
Unnamed-SDVX-Clone Android Port

Note usc-app only support android version >= 11 Also currently not support touch control!! Installation guide Install app from release Game files are

SieR 36 Dec 11, 2022
android-delicious Delicious Android is an Android app which helps you access and save bookmarks via Delicious. It's available over at Google Play.

Delicious Android Delicious Android is an Android app which helps you access and save bookmarks via Delicious. It's available over at Google Play. Fea

Alexander Blom 137 Nov 20, 2022
Android cutout screen support Android P. Android O support huawei, xiaomi, oppo and vivo.

CutoutScreenSupport Android cutout screen support Android P. Android O support huawei, xiaomi, oppo and vivo. Usage whether the mobile phone is cutout

hacket 5 Nov 3, 2022
FoldingNavigationDrawer-Android This is a sample project present how to use Folding-Android to add Folding Efect to Navigation Drawer.

FoldingNavigationDrawer-Android Sample (Play Store Demo) This is a sample project present how to use Folding-Android to add Folding Efect to Navigatio

null 242 Nov 25, 2022
Twidere-Android Twidere is a powerful twitter client for Android 1.6+ 1 , which gives you a full Holo experience and nearly full Twitter's feature.

Twidere for Android Material Design ready and feature rich Twitter/Mastodon/Fanfou app for Android 4.1+. Enjoy Fediverse now! Twidere-Android is maint

Twidere Project 2.7k Jan 2, 2023
:movie_camera: Movie discovery app showcasing Android best practices with Google's recommended architecture: MVVM + Repository + Offline support + Android Architecture Components + Paging library & Retrofit2.

Popular Movies Stage 1 + Stage 2 Discover the most popular and top rated movies playing. Movies data fetched using themoviedb.org API. ✨ Screenshots M

Yassin AJDI 189 Nov 26, 2022
Extensible Android mobile voice framework: wakeword, ASR, NLU, and TTS. Easily add voice to any Android app!

Spokestack is an all-in-one solution for mobile voice interfaces on Android. It provides every piece of the speech processing puzzle, including voice

Spokestack 57 Nov 20, 2022
Aggregated Android news, articles, podcasts and conferences about Android Development

DroidFeed Curated news feed for Android Developers! Stay up to date with the latest Android Development news. Built for the Android developer communit

Dogan Gulcan 183 Dec 2, 2022
Shreyas Patil 2.1k Dec 30, 2022
A simple app to showcase Androids Material Design and some of the cool new cool stuff in Android Lollipop. RecyclerView, CardView, ActionBarDrawerToggle, DrawerLayout, Animations, Android Compat Design, Toolbar

#Android-LollipopShowcase This is a simple showcase to show off Android's all new Material Design and some other cool new stuff which is (new) in Andr

Mike Penz 1.8k Nov 10, 2022
The Android startup used to schedule tasks, jobs while launching Android App.

Android Startup, schedule your startup jobs Introduction AndroidStartup is an open source project used to refine your Andriod App startup. Compared wi

ShouHeng 46 Aug 24, 2022
Android playground project with modularization by feature (android libraries), unit tests, MVVM & MVI.

Movies Movies is a simple project to study and play with some android components, architecture and tools for Android development. Tech Stack This proj

Christopher Elias 333 Dec 30, 2022
🌄 Photo editor using native modules for iOS and Android. Inherit from 2 available libraries, Brightroom (iOS) and PhotoEditor (Android)

React Native Photo Editor (RNPE) ?? Image editor using native modules for iOS and Android. Inherit from 2 available libraries, Brightroom (iOS) and Ph

Baron Ha. 242 Dec 28, 2022