Cannot resolve symbol 'ImmutableList' in Android studio

Viewed 106

I try to implement Google Play Pay but don`t know how solve this problem:Type of ImmutableList cannot be resoclved. Should I import some package?

I have search with Google and no any question like this(Android studio)

ImmutableList.of(QueryProductDetailsParams.Product.newBuilder()
                                            .setProductId("product_id_example")
                                            .setProductType(BillingClient.ProductType.SUBS)
                                            .build())
1 Answers

I run into the same problem. By hovering with the pointer over 'ImmutableList' I selected the entry Add dependency on com.google.firebase:firebase-crashlitics-builtools and import...

This action created the following line in the import section of my activity file

import com.google.firebase.crashlytics.buildtools.reloc.com.google.common.collect.ImmutableList;

and the following line in the build.gradle file:

implementation 'com.google.firebase:firebase-crashlytics-buildtools:2.7.1'

However, the word reloc in the import line initially appeared in red color with the hint Cannot resolve symbol 'reloc'. Then I noticed that in the build.gradle file, android studio was offering to change the version of the crashlytics-buildtools from 2.7.1 to 2.9.1. After doing so and syncing gradle, the word reloc was no longer red and ImmutableList was recognized correctly.

I wonder whether it is really necessary to import the firebase crashlytics-buildtools for the integration of the Google Billing Library (I use it for an app with in-app purchases) or if there is a more simple way to do this.

Related