Cannot resolve symbol 'ImmutableList' in Android studio - android-studio

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())

Android Studio suggests the firebase-crashlytics-buildtools dependency to import the ImmutableList class. Doing so resulted in a big increase of the file (bundle) size.
Try instead including guava as a dependency, if you are not using crashlythics in your app:
// graddle
implementation 'com.google.guava:guava:31.1-android'
// java class/code
import com.google.common.collect.ImmutableList;
This has a much smaller impact on the file size. In my case, the bundle was 2MB compared to 10 MB if using crashlythics-buildtools.

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

exclude flutter export from import suggestions

I often times import cupertino.dart instead of material.dart when having to import widgets because its the first suggested options.
Its not a real problem but for the sake of consistency I want to prevent importing cuppertino.dart so it is not listed in the import suggestions and only use widgets.dart or material.dart instead.
Is there a way to configure Android Studio or Dart Analyzer to prevent cuppertino.dart to show in suggestions?
Seems no, but there is a workaround: You can write a linter to examine your code and warn (or error) whenever you see imports of cupertino.dart. That linter can even automatically correct the code (by replacing cupertino with material).
Some methodology thoughts: I often want something to be automatically performed ("import material not cupertino" in your case); but later I realized it is hard or not exist yet, but some verifier is good enough ("manually import; but warn if you import the wrong one").
You can create an export file with your exports inside and call this file afterwards.
For example create an exportsFile:
export 'package:flutter/material.dart';
And now call this file when you wants:
import 'exportsFile.dart';

Xzing barcode : I'm getting type mismatch error in fragment using androidx.fragment.app.Fragment

I'm using Android studio 4.0, coding in Kotlin and I'm still really new at Android development.I need to integrate the Xzing barcode libray. I've copied some code from the tutorial at [https://tutorialwing.com/implement-android-qr-code-scanner-using-zxing-library-in-kotlin/][1]. The tutorial uses the following import statement:
import android.app.Fragment
I've modified a fragment that was generated with the Navigation Drawer Activity template. It uses the androidx fragment import statment:
import androidx.fragment.app.Fragment
The errors it occurs on the following line with the "this" reference:
qrScanIntegrator = IntentIntegrator.forFragment(this)
The error is:
Type mismatch: Required Fragment! found HomeFragment
Changing my import to the older version to the older version is not recommended and if I do I get a lot of other errors.
What can I do to get zxing to work with the androidx fragment?
Thanks
The ZXing library is no longer maintained, and that particular class (IntentIntegrator) only supports android.app.Fragment which is the deprecated Android framework version of the AndroidX Fragment class.
You have a few possible options here:
Fork the ZXing library, and change the android.app.Fragment import to use the androidx.fragment.app.Fragment version instead.
Delegate the IntentIntegrator calls to your Activity instead, and have the results forwarded to your Fragment.
Simply duplicate the Intent initialization code from IntentIntegrator to a helper class of your own. The IntentIntegrator methods are just convenience methods to build an Intent and call startActivityForResult(). You'll still be able to use the IntentIntegrator.parseActivityResult method to interpret the result that comes back.
I would recommend going with option #3.
As a longer term alternative, you may also want to consider looking into Firebase ML Kit since ZXing is no longer maintained.

Cannot import com.google.android.libraries.(anything)

I am trying to add a maps activity to my android project using android studio, and I copied the code from developer.google.com which contains the documentation for retrieving the current location. But there in the import part there are some lines
import com.google.android.libraries.(something)
which is giving the error even though I edited the dependencies in build.gradle, but still it is not working
cannot resolve symbol libraries
any suggestions, thanks in advance
Try to delete .gradleand .ideafolder and sync the project again.
You can find above files in Project Window on the left side of IDE

setting up google play expansion file library in android studio

I am trying to use apk expansion files in my android project, I've read this
http://developer.android.com/google/play/expansion-files.html
I tried to follow those steps, but I cannot figure out how to set up / include in my project / google play apk expansion library.
I've been searching for hours, didn't find right answer. Any help?
I just tried to set up the modules listed in http://developer.android.com/google/play/expansion-files.html today, but the play_apk_expansion/downloader_library cannot be imported as supplied.
The issue is a stale library reference in play_apk_expansion/downloader_library/project.properties
Update the last line from:
android.library.reference.1=../market_licensing
to:
android.library.reference.1=../../play_licensing/library
Note the extra ../
Then use File -> New -> Import Module... to import the play_apk_expansion/downloader_library as usual. It will also import the play_licensing/library as library but that can be renamed to something more useful afterwards.
I have not found a better way than importing via eclipse, so I have set up a github repo where this has already been done:
https://github.com/coltsoftware/ExpansionAPKsAndroidStudio
Copy sdk/extras/google/play_licening/library to Eclipse workspace
Copy sdk/extras/google/play_apk_expansion/downloader_library to Eclipse workspace
Eclipse: New --> Android project from sources to create two library projects from the above copied files. Don't forget to make the correct library reference to play_licening for downloader_library.
Android Studio: New --> Import Module, and import play_licening first, and then downloader_library.
To use Andrew's answer with Android Studio 2.1, I needed to update:
market_apk_expansion/downloader_library/project.properties
to
android.library.reference.1=../../market_licensing/library
before I could import the module as described.

Web Essentials v2.8 LESS import error

For better organization, I have a main .less file that imports other .less files using the #import syntax. In order for the Web Essentials Preview window to work I also have #import-once at the top of each .less file that imports the variables.less file.
This solution worked wonderfully until I upgraded to Web Essentials 2.8. Now I'm unable to import any .less file that has #import or #import-once declared in it. My main .less file no longer compiles.
If I remove the #import-once statements, the preview window is useless since I can't see the compiled CSS without importing my variables file.
I also had a case where I imported a .less file into a ruleset, as defined by lesscss.org in the Importing into ruleset section. This also no longer works since the upgrade to v2.8.
Has anyone else experienced these issues or have a resolution?
Thanks
This seems to be a bug -> Feature in the latest version of the WebEssentials because of a new feature in Less 1.4.0. as Anwar describes. See the changelog of Less:
1.4.0 Beta 1 & 2 (2013-03-07)
default behaviour of import is to import each file once. #import-once has been removed.
Either
Update your files to use the new syntax (remove the -once from your imports)
Or
To use the older version of the engine, download the previous (2.7) version and don't update until you know it has been fixed.
Or
Or you can configure your Visual Studio to look at the Nightly Build feed from Web Essentials to download the very latest version (caution, nightly builds may contain other bugs or stop working from time to time). TO do so go to Tools -> Options -> Extensions & Updates and add the feed: http://vswebessentials.com/nightly/feed.ashx
Which seems to add a workaround that makes it work with the old syntax as well.
In Less v1.4.0 #import-once has been removed and #import imports once by default. This means that with the following
#import “file.less”; #import “file.less”;
The second file is ignored.
I think that one is causing issue with import statements.

Resources