How to use Place Picker even if now its deprecated?

4.8k Views Asked by At

I am developing an application right now and I am using place picker, but right now its deprecated. I want to still use it in my app until its completely gone. What do i need to do?

I tried to use the compat library of the places but i got an error showing compiling error.


app module:

   buildscript {
    repositories {
         maven { url 'https://maven.fabric.io/public' }
     }

     dependencies {
         classpath 'io.fabric.tools:gradle:1.+'
     } } apply plugin: 'com.android.application' apply plugin: 'io.fabric'

 android {
     compileSdkVersion 27
     defaultConfig {
         applicationId "com.lim.therapist"
         minSdkVersion 21
         targetSdkVersion 27
         versionCode 2
         versionName "1.1"
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
     }
     buildTypes {
         release {
             minifyEnabled false
             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
         }
     } } ext {
     permissionsDispatcherVersion = '2.2.0' }

 repositories {
     maven { url 'https://jitpack.io' }
     maven { url 'https://maven.fabric.io/public' } } dependencies {
     implementation "com.github.hotchemi:permissionsdispatcher:${permissionsDispatcherVersion}"
     implementation 'com.android.support:support-v4:27.1.1'
     annotationProcessor "com.github.hotchemi:permissionsdispatcher-processor:${permissionsDispatcherVersion}"
     implementation fileTree(include: ['*.jar'], dir: 'libs')
     //noinspection GradleCompatible
     implementation 'com.android.support:appcompat-v7:27.1.1'
     implementation 'com.android.support.constraint:constraint-layout:1.1.0'
     implementation 'com.android.support:design:27.1.0'
     implementation 'com.cocosw:bottomsheet:1.+@aar'
     implementation 'com.isseiaoki:simplecropview:1.1.4'
     implementation 'com.github.bumptech.glide:glide:3.7.0'
     implementation 'com.github.florent37:singledateandtimepicker:1.2.2'
     implementation 'de.hdodenhof:circleimageview:2.0.0'
     implementation 'com.android.support:multidex:1.0.1'
     implementation 'com.amitshekhar.android:android-networking:1.0.0'
     implementation 'com.google.code.gson:gson:2.8.2'
     implementation 'org.jsoup:jsoup:1.8.1'
     implementation 'com.github.hani-momanii:SuperNova-Emoji:1.1'
     implementation 'com.android.support:recyclerview-v7:27.1.1'
     implementation 'com.android.support:cardview-v7:27.1.1'
     implementation 'com.ToxicBakery.viewpager.transforms:view-pager-transforms:1.2.32@aar'
     implementation 'com.google.firebase:firebase-messaging:11.8.0'
     implementation 'com.google.firebase:firebase-core:11.8.0'
     implementation 'com.google.android.gms:play-services:11.8.0'
     implementation 'com.google.android.gms:play-services-maps:11.8.0'
     implementation 'com.google.android.gms:play-services-location:11.8.0'

     implementation 'com.kyleduo.switchbutton:library:1.4.5'
     implementation 'com.github.PhilJay:MPAndroidChart:v3.0.1'
     implementation('com.crashlytics.sdk.android:crashlytics:2.9.4@aar') {
         transitive = true;
     } }

 apply plugin: 'com.google.gms.google-services'


project module:

// Top-level build file where you can add configuration options common
to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'

        classpath 'com.google.gms:google-services:4.2.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    } }



allprojects {
    repositories {
        google()
        jcenter()
    } }

task clean(type: Delete) {
    delete rootProject.buildDir }


Logcat:

 019-02-14 03:09:18.684 28156-28156/com.lim.therapist E/AndroidRuntime:
 FATAL EXCEPTION: main Process: com.lim.therapist, PID: 28156
 java.lang.RuntimeException: Failure delivering result
 ResultInfo{who=null, request=65637, result=2, data=null} to activity
 {com.lim.therapist/com.lim.therapist.ui.activity.BaseActivity}:
 java.lang.NullPointerException: intent must not be null at
 android.app.ActivityThread.deliverResults(ActivityThread.java:4271) at
 android.app.ActivityThread.handleSendResult(ActivityThread.java:4315)
 at android.app.ActivityThread.-wrap19(Unknown Source:0) at
 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1647)
 at android.os.Handler.dispatchMessage(Handler.java:106) at
 android.os.Looper.loop(Looper.java:164) at
 android.app.ActivityThread.main(ActivityThread.java:6518) at
 java.lang.reflect.Method.invoke(Native Method) at
 com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) Caused
 by: java.lang.NullPointerException: intent must not be null at
 com.google.android.gms.common.internal.zzbq.checkNotNull(Unknown
 Source:9) at
 com.google.android.gms.location.places.ui.zza.getStatus(Unknown
 Source:2) at
 com.google.android.gms.location.places.ui.PlaceAutocomplete.getStatus(Unknown
 Source:0) at
 com.lim.therapist.ui.fragment.ArtistProfileView.onActivityResult(ArtistProfileView.java:491)
 at
 android.support.v4.app.FragmentActivity.onActivityResult(FragmentActivity.java:156)
 at
 com.lim.therapist.ui.activity.BaseActivity.onActivityResult(BaseActivity.java:523)
 at android.app.Activity.dispatchActivityResult(Activity.java:7280) at
 android.app.ActivityThread.deliverResults(ActivityThread.java:4267) at
 android.app.ActivityThread.handleSendResult(ActivityThread.java:4315) 
 at android.app.ActivityThread.-wrap19(Unknown Source:0)  at
 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1647) 
 at android.os.Handler.dispatchMessage(Handler.java:106)  at
 android.os.Looper.loop(Looper.java:164)  at
 android.app.ActivityThread.main(ActivityThread.java:6518)  at
 java.lang.reflect.Method.invoke(Native Method)  at
 com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 
 2019-02-14 03:09:18.981 28156-28156/com.lim.therapist
 E/UncaughtException: java.lang.RuntimeException: Failure delivering
 result ResultInfo{who=null, request=65637, result=2, data=null} to
 activity
 {com.lim.therapist/com.lim.therapist.ui.activity.BaseActivity}:
 java.lang.NullPointerException: intent must not be null at
 android.app.ActivityThread.deliverResults(ActivityThread.java:4271) at
 android.app.ActivityThread.handleSendResult(ActivityThread.java:4315)
 at android.app.ActivityThread.-wrap19(Unknown Source:0) at
 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1647)
 at android.os.Handler.dispatchMessage(Handler.java:106) at
 android.os.Looper.loop(Looper.java:164) at
 android.app.ActivityThread.main(ActivityThread.java:6518) at
 java.lang.reflect.Method.invoke(Native Method) at
 com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) Caused
 by: java.lang.NullPointerException: intent must not be null at
 com.google.android.gms.common.internal.zzbq.checkNotNull(Unknown
 Source:9) at
 com.google.android.gms.location.places.ui.zza.getStatus(Unknown
 Source:2) at
 com.google.android.gms.location.places.ui.PlaceAutocomplete.getStatus(Unknown
 Source:0) at
 com.lim.therapist.ui.fragment.ArtistProfileView.onActivityResult(ArtistProfileView.java:491)
 at
 android.support.v4.app.FragmentActivity.onActivityResult(FragmentActivity.java:156)
 at
 com.lim.therapist.ui.activity.BaseActivity.onActivityResult(BaseActivity.java:523)
 at android.app.Activity.dispatchActivityResult(Activity.java:7280) at
 android.app.ActivityThread.deliverResults(ActivityThread.java:4267)

I want to continue using the place picker. please help me. I'm new to stackoverflow, sorry for anything that is not eye pleasing. Thank you

1

There are 1 best solutions below

0
Wojuola Ayotola On

Use the compatibility library

    dependencies {
  implementation 'com.google.android.libraries.places:places-compat:1.0.0'
}

The Place Picker is not supported in the new client library. To continue using the Place Picker through the deprecation period, be sure to install the compatibility library.

Check link for more information. Link