hbb20 / CountryCodePickerProject

Country Code Picker (CCP) is an android library which provides an easy way to search and select country or international phone code. Also supports Android EditText phone mask and international phone validation.
Apache License 2.0
1.52k stars 505 forks source link

Unable to Use the .aar file. App force closes #90

Closed jiveshwar closed 7 years ago

jiveshwar commented 7 years ago

Please help. Whenever I am adding .aar to my project using the method - https://stackoverflow.com/questions/29826717/how-to-import-a-aar-file-into-android-studio-1-1-0-and-use-it-in-my-code

It doesn't work for me after screen becomes visible. The CountryPicker seems on the MainActivity screen in installed app, but when I click on the CountryCode with National-Flag icon to get the list of country dropdown, the app force closes on Android 6, Does not even opens the MainActivity in Android 4.4.4 (Custom Device) and Android 7.1.1 (OnePlus 5).

Please help

hbb20 commented 7 years ago

As long as you can see the CountryCode with National Flag, your setup looks alright.

Can you please post the crash report? That is the best way for us to understand the problem.

Also please let us know the version of the Android studio.

jiveshwar commented 7 years ago

Thanks for your prompt reply. I have uploaded the simple sample project i created at wetransfer - https://we.tl/hqn1AWkVkk

Simple Project I created after importing the .aar file and just including its xml and java file code as u mentioned in your github repo

Thanks. Actually i don't know what logcat is. I am a newbie.

hbb20 commented 7 years ago

Thank you for uploading this project, it helped me find the problem.

Here is how you can make this work:

Add missing dependencies

When you are adding aar file for CCP it does not include other dependencies required by CCP. To include those missing dependencies you can add them in gradle file of your project.

Add following dependencies in your dependencies code block

compile 'com.android.support:recyclerview-v7:26.+'
compile 'com.futuremind.recyclerfastscroll:fastscroll:0.2.5'
compile 'com.googlecode.libphonenumber:libphonenumber:8.5.2'

so finally your gradle file will look like

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.test.testforusingccp"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:recyclerview-v7:26.+'
    compile 'com.futuremind.recyclerfastscroll:fastscroll:0.2.5'
    compile 'com.googlecode.libphonenumber:libphonenumber:8.5.2'
    testCompile 'junit:junit:4.12'
    compile project(':ccp-release')
}

If this works for you, please close the issue.

hbb20 commented 7 years ago

Did this work for you?

hbb20 commented 7 years ago

For now I'm closing this issue. If you still have the problem, feel free to comment below with details.