2

I'm getting this strange behavior that I'm not able to import OnSuccessListener to my code after git cloning and building in a different machine (this resolved fine in my previous machine). However the project builds fine and runs on the emulator. But I'm not able to write firebase related codes further as the listener isn't resolving.

enter image description here

I tried cleaning the project, rebuilding, invalidating the cache but still no luck.

Gradle Dependencies,

dependencies {

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.android.support:support-v4:27.1.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.google.firebase:firebase-firestore:17.0.4'
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-auth:16.0.2'
    implementation 'com.google.android.gms:play-services-auth:15.0.1'
    implementation 'com.facebook.android:facebook-android-sdk:4.34.0'
    implementation 'com.android.support:design:27.1.1'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.google.android.gms:play-services-location:15.0.1'
    implementation 'com.github.drawers:SpinnerDatePicker:1.0.6'
    implementation 'com.github.yalantis:ucrop:2.2.2'
}
Nisse Engström
  • 4,738
  • 23
  • 27
  • 42
channae
  • 951
  • 1
  • 12
  • 28
  • Have you tried removing `.idea/libraries` ? – Anatolii Sep 02 '18 at 11:16
  • I tried removing build folder and rebuild the project. Still project builds fine with above not resolving error in the given class. – channae Sep 02 '18 at 11:20
  • Tried deleting .idea/* still no luck – channae Sep 02 '18 at 11:24
  • I think the method for OnSuccessListner may be of a different class. Block the code for this method. And write it again, it will ask for from which class you want to create the method. Then select the correct one. – Ammar Bukhari Sep 02 '18 at 11:30
  • Have you tried to manually import `OnSuccessListener` using this line `import com.google.android.gms.tasks.OnSuccessListener;`? Please responde with @. – Alex Mamo Sep 03 '18 at 09:02

2 Answers2

2

Please try adding this into your app-gradle file.

implementation 'com.google.android.gms:play-services-tasks:16.0.1'

seymatanoglu
  • 151
  • 1
  • 9
-1

What you do is make all the firebase and gms version of the same number like for example:

implementation 'com.google.firebase:firebase-auth:102.0' implementation 'com.google.android.gms:play-services-auth:10.2.0'

Al Foиce ѫ
  • 4,195
  • 12
  • 39
  • 49
  • This is no longer a requirement, latest libraries can have different versions without clashing – cutiko Aug 29 '19 at 14:01
  • Yes this is not a requirement for firebase sdk. In fact google suggests you to use the latest firebase library. Also sometimes there are no matching version numbers with respective firebase services. – channae Aug 30 '19 at 02:25