Xamarin Android google libraries defining the same class - android

I updated the libraries on my Xamarin Android application, and I get the following error:
com.google.android.gms.internal.ads.zza is defined multiple times: obj\Debug\120\lp\107\jl\bin\classes.jar:com/google/android/gms/internal/ads/zza.class, obj\Debug\120\lp\116\jl\bin\classes.jar:com/google/android/gms/internal/ads/zza.class
Here are the libraries that collide based on the manifest files found in these folders:
com.google.android.gms.gass -> Xamarin.GooglePlayServices.Gass version 120.0.0.7
com.google.android.gms.ads.impl -> I assume it's Xamarin.GooglePlayServices.Ads version 121.3.0
Is there any thoughts how can I overcome this issue? My app does not build. I tried many version combinations, none of them helped.
I tried many version combinations, none of them helped.

I have checked the android natived library: com.google.android.gms:play-services-gass 20.0.0, its last updated time is Apr 07, 2021. This is the Xamarin.GooglePlayServices.Gass nuget package 120.0.0.x in the xamarin.
And the native library com.google.android.gms: play-services-ads version 20.0.0 is published at Apr 05, 2021. So I created a sample to test the two nuget packages:
Xamarin.GooglePlayServices.Ads version 120.0.0
Xamarin.GooglePlayServices.Gass version 120.0.0.7
The error message disappeared. In addition, you can also uninstall the Xamarin.GooglePlayServices.Gass and only use the Xamarin.GooglePlayServices.Ads version 121.3.0, it should contains the api in the Xamarin.GooglePlayServices.Gass.

Related

Flutter Error: 'Error.throwWithStackTrace' [duplicate]

So i am trying to get started with riverpod and creating a new flutter project with the "click and counter" default sample.
As soon as I add on the pubspec
flutter_hooks: ^0.18.0
hooks_riverpod: ^2.0.0
And
import 'package:hooks_riverpod/hooks_riverpod.dart';
I get this error on the debug console and can't figure it out what is the problem
: Error: Method not found: 'Error.throwWithStackTrace'.
../…/framework/provider_base.dart:904
Error.throwWithStackTrace(error, chain);
^^^^^^^^^^^^^^^^^^^
: Error: A non-null value must be returned since the return type 'Never' doesn't allow null.
../…/framework/provider_base.dart:898
Never _rethrowProviderError(Object error, StackTrace stackTrace) {
^
Error.throwWithStackTrace was added in Dart 2.16 (Flutter version 2.10 from Feb 8, 2022).
https://api.flutter.dev/flutter/dart-core/Error/throwWithStackTrace.html
(Check the #Since annotation.)
If your Flutter/Dart version is below that, you'll get the error you saw.
Two options that may help are:
Specify an exact version of dependencies (don't use ^ ahead of version)
upgrade Flutter/Dart to at least 2.10/2.16
flutter upgrade
If your problematic package (hooks_riverpod: ^2.0.0 in your case) is listed with ^, it'll use the latest version that doesn't break dependencies.
I'm guessing that when you created a new project and used that same dependency version, upon initial pub get it downloaded a newer version of the package (or a newer version of a dependency that that package uses) into "pub cache" which is relying on the new Error API method.
Your project will store this information in:
<your_project_dir>/dart_tool/package_config.json
The min Dart SDK version listed for the package should normally have changed from 2.12 to 2.16. (update: it's been updated now) This would give us a hint that we need to update our Flutter/Dart if we see our build failing.
In an earlier version of this answer, I noted that the ^ prefix on package dependency versions is supposed to prevent these types of issues, but I'm no longer certain it was meant to cover this situation where the underlying platform needs to be updated (as opposed to a breaking change in the API of the package itself).
Anyways, at first glance, it might make sense to go from 2.0.0 to 3.0.0 for a package version # when it depends on a new core Dart API method that did not exist when 2.0.0 was published.
Notes
The author of riverpod also wrote the new API for Error.throwWithStackTrace so likely the latest version of hooks_riverpod is using the latest API changes. (The version you're listing 2.0.0 is pre-release currently). You could try earlier versions of riverpod in your pubspec.yaml (such as 1.0.3)
for anyone facing " Method not found: 'Error.throwWithStackTrace' " with firebase.
try to add this to your pubspec.yaml
dependency_overrides:
firebase_messaging_platform_interface: 3.1.6
I saw this.
How about trying flutter pub upgrade?
If it is not resolved, then check analyzer version and check which dependency locks that.
As noted in Baker's answer, Error.throwWithStackTrace was recently added in Dart 2.16.
If you're getting an error about Error.throwWithStackTrace not being found for some package, the package author neglected to update their package's minimum Dart SDK version. You should report that to the package maintainer. In the meantime, you should use an earlier version of the problematic package or use a newer version of the Dart SDK.
Try running flutter upgrade
By this it will upgrade your flutter and dart SDK version and hope it resolves your issue
if you are still facing the issues after "flutter upgrade" or you use this line of code in pubspec.yaml
dependency_overrides:
firebase_messaging_platform_interface: 3.1.6
you receive this type of errors
java.lang.AssertionError: annotationType(): unrecognized Attribute name MODULE (class com.sun.tools.javac.util.UnsharedNameTable$NameImpl)
at com.sun.tools.javac.util.Assert.error(Assert.java:133)
at com.sun.tools.javac.code.TypeAnnotations.annotationType(TypeAnnotations.java:231)
at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.separateAnnotationsKinds(TypeAnnotations.java:294)
at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitMethodDef(TypeAnnotations.java:1066)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:778)
at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:275)
at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
so Try to upgrade your gradle version, this line in your build.gradle
classpath 'com.android.tools.build:gradle:4.1.0'
after doing that it may be possible it ask you to change your
gradle-wrapper.properties
distributionUrl=https://services.gradle.org/distributions/gradle-6.1.1-all.zip
to
distributionUrl=https://services.gradle.org/distributions/gradle-6.5-all.zip
also upgarde this packages
firebase_core: ^1.10.0
firebase_messaging: ^11.1.0

Jacoco java.lang.instrument.IllegalClassFormatException: Error while instrumenting Class

I recently moved to another computer and needed to reset all my environment.
So, this tests was working before.
But I didnt remember which version of Java/JDK I was using before.
Well, the problem is:
java.lang.instrument.IllegalClassFormatException: Error while instrumenting path/to/class
I'm using Jacoco "0.8.1"
java --version
openjdk 17.0.1 2021-10-19
and JDK 1.8
Can anyone know how to handle with it?
Strange to see statement
and JDK 1.8
together with
java --version
openjdk 17.0.1 2021-10-19
from the last one seems that actually you're using JDK 17
I'm using Jacoco "0.8.1"
We (developers of JaCoCo) advice to always use latest released version as new versions come with fixes and improvements (IMO updating versions of your dependencies and tools - is a very good practice also in general), so please try this - as of today latest released JaCoCo version is 0.8.7, and exactly in this version JDK 17 support was added.
Java 17 need jacoco 0.8.8 and above. reload pom.xml and it works
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.8</version>
</plugin>
While I was Testing my build in cmd using the command mvnw test, i got "Build Erorr" java.lang.instrument.IllegalClassFormatException: Error while instrumenting sun/util/resources/cldr/provider/CLDRLocaleDataMetaInfo.
Step to perform:
1.Where to analyse the error.
Always check for build error or any test report under project folder /target/surefire-reports.
As this a build erorr checkin the dump file
Check for error message . In this particular scenario the error message is
"Jacocojava.lang.instrument.IllegalClassFormatException: Error while instrumenting sun/util/resources/cldr/provider/CLDRLocaleDataMetaInfo"
2.Investigate what is causing this error. The java version i had is 17 and Jacoco version i had is 0.8.5. So check your java verison and Jacoco verison
3.Checking java version Cmd enter java - version : it will display the version
example C:\Automation\projectJenkins\jgsu-spring-petclinic>java -version
java version "17.0.6" 2023-01-17 LTS
4.For java 15 and above the jococ version compatable is 0.8.7.
Open the pom file of your project and update jococ version. check under Generic properties . Update you version as 0.8.7
example:
<jacoco.version>0.8.7</jacoco.version>
save the file
last step. test your build.
cmd run MVNW test .
The issue was reolved and succesfull build was built.

How can I fix "unexpected element <queries> found in <manifest>" error?

All of a sudden, I am getting this build error in my Android project:
unexpected element <queries> found in <manifest>
How do I fix it?
The Android Gradle Plugin needs to know about new manifest elements, particularly
for the manifest merger process. The plugin has a tendency to get confused if it
sees elements in the manifest merger that it does not recognize, tossing out
build errors like the one in the question.
In this case, Android 11 introduced <queries> as a manifest element, and older versions of the Android Gradle Plugin do not know about that element.
The fact that this occurs from manifest merger means that simply upgrading a dependency
might bring about this error. For example, if you upgrade to the latest
version of com.awesome:awesome-library, and it contained a <queries> element
in its manifest, you might crash with the aforementioned error in your builds,
even without any other changes in your code.
Google released a series of patch versions of the Android Gradle Plugin to address this:
3.3.3
3.4.3
3.5.4
3.6.4
4.0.1
If you are using an existing plugin in the 3.3.* through 4.0.* series, upgrade
to the associated patch version (or higher) from that list, and you should no longer
run into that error (e.g., classpath 'com.android.tools.build:gradle:4.0.1').
If you are using Android Studio 4.1 or higher, with a matching
Android Gradle Plugin (e.g., in the 4.1.* series), you should be fine without
any changes. Those plugin versions were already aware of <queries>.
See this Android Developers Blog post for more.
I had this issue in Flutter, but I believe this solution will work for both Flutter and native Flutter development.
Follow these steps
Read this short blog post to get some understanding: Preparing your Gradle build for package visibility in Android 11
Delete the .gradle folder inside the Android folder, i.e., android > .gradle
In the project build.gradle file, upgrade your class path appropriately based on the blog in the link above, e.g., I upgraded to classpath 'com.android.tools.build:gradle:4.0.1'
Upgrade the distribution URL too. It's in android>gradle>gradle-wrapper.properties file appropriately. E.g., I upgraded it to distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
You can invalidate caches and restart your Android Studio. Make sure you have a good Internet connection, because it will download the new Gradle files.
I also suddenly had the same issue two days ago in Android Studio 4.1.1. I solved the issue by upgrading the build Gradle version.
Previous setting in the build.gradle file of the project was:
classpath("com.android.tools.build:gradle:3.5.3")
Current setting:
classpath("com.android.tools.build:gradle:3.5.4")
The issue was gone immediately. :)
Fixing the error is very simple.
Update your Android Studio to the last version
and use the last stable Gradle plugin version.
At the current time, I use Android Studio version 4.1.3 with Gradle Plugin 6.8.2
For use in queries, you should write queries code in out of application tag, not inside application tag.
For more information, see the photo below:
I had this error in the react-native-image-crop-picker library, and I solved this problem by updating the Gradle version as mentioned in previous answers.
It was:
classpath("com.android.tools.build:gradle:3.5.3")
Updated to:
classpath("com.android.tools.build:gradle:3.5.4")
And I ran a:
cd android && ./gradlew clean && cd .. && npx react-native run-android
Then it worked OK.
Due to the new default settings and features for package visibility in Android 11 that need to add <queries>, you must update your Android Gradle plugin.
Google has added some patches to current versions listed in Android Gradle plugin release notes, 4.0.0 (April 2020).
If you want to use a newer version of Android Gradle, you should search for a compatible wrapper from Android Gradle plugin release notes, Update Gradle.
Update your Gradle version to 4.0.1 or later.
File android/gradle/wrapper/gradle-wrapper.properties: update the distribution URL to:
distributionUrl=https://services.gradle.org/distributions/gradle-6.7-all.zip
File android/build.gradle: update the Gradle plugin:
classpath 'com.android.tools.build:gradle:4.1.2'
to 4.0.1 or later. Here it is 4.1.2 with Gradle version to 6.5 or later.
You can see the distribution chart at How to update gradle in android studio?

Unexpected failure during lint analysis of module-info.class

has anyone else seen this error:
Errors found:
/home/ligi/git/walleth/app/module-info.class: Error: Unexpected failure during lint analysis of module-info.class (this is a bug in lint or one of the libraries it depends on)
Stack: NullPointerException:InvalidPackageDetector.checkClass(InvalidPackageDetector.java:112)←AsmVisitor.runClassDetectors(AsmVisitor.java:154)←LintDriver.runClassDetectors(LintDriver.kt:1461)←LintDriver.checkClasses(LintDriver.kt:1329)←LintDriver.runFileDetectors(LintDriver.kt:1096)←LintDriver.checkProject(LintDriver.kt:895)←LintDriver.analyze(LintDriver.kt:416)←LintCliClient.run(LintCliClient.java:235)
You can set environment variable LINT_PRINT_STACKTRACE=true to dump a full stacktrace to stdout. [LintError]
Applies to variants: noGethNoFirebaseForFDroidOnlineDebug
/home/ligi/git/walleth/app/module-info.class: Error: Unexpected failure during lint analysis of module-info.class (this is a bug in lint or one of the libraries it depends on)
Stack: NullPointerException:
I only found this project facing the same problem:
https://github.com/mozilla-mobile/android-components/issues/1730
any workaround would be nice
The Android tooling for Android Studio 3.3 and earlier chokes on module-info.class files that are required by the Java Platform Module System (JPMS). Which is mind boggling considering that Java 9, the first version that shipped with the JPMS, came out in September 2017 and Java 11, the first LTS release with the JPMS, came out in September 2018, around 4 months before Android Studio 3.3. The relevant bug in the Android issue tracker: [lint] InvalidPackage crashes on module-info.class from byte-buddy
So, workarounds:
Upgrade the Android tooling to a beta of 3.4 or later. I tested 3.4.0-beta05 on one of my projects and it worked well.
Downgrade whatever library you're using to a version that does not yet support the JPMS (i.e. does not include a module-info.java).
To ignore this error, I defined this in my lint.xml:
<issue id="LintError">
<ignore regexp=".*module-info\.class.*"/>
</issue>
The above mentioned workarounds did not work for me:
Updating Android build tools to 3.4.1 didn't help
I couldn't downgrade the dependency that lead to this problem

Failed to find target with hash string 'android-25'

I have Android Studio 2.2. I am trying to open a project, but I get the error "Failed to find target with hash string 'android-25'". Below the error message I see a link "Install missing platform(s) and sync project". If I click this link, I get another error, which says
"The following packages are not available: - Package id
platforms;android-25".
In the Android SDK tool, I can see "Android 7.0" (API level 24) already installed. On checking the details about Android verisons and its API levels, I found that Android Nougat has API levels 24-25. I would like to know how I can update the SDK from API24 to 25?
You don't need to update anything. Just download the SDK for API 25 from Android SDK Manager or by launching Android standalone SDK manager. The error is for missing platform and not for missing tool.
Well, I was suffering with this Issue but finally I found the solution.
Problem Starts Here:
["Install missing platform(s) and sync project" (link) doesn't work & gradle sync failed]
Problem Source: Just check out the app -> src-build.gradle and you will find the parameters
compileSdkVersion 25
buildToolsVersion "25.0.1"
targetSdkVersion 25
Note: You might find these parameters with different values e.g
compileSdkVersion 23 etc.
These above parameters in build.gradle creates error because their values are not compatible with your current SDK version.
The solution to This error is simple, just open a new project in your Android Studio, In that new project goto app -> src-build.gradle.
In build.gradle file of new project find these parameters:
In my case these are:
compileSdkVersion "26"
buildToolsVersion "26.0.1"
targetSdkVersion 26
Now copy these parameters from your new project build.gradle file and post them in the same file of the other project(having Error).
I got similar problem
1: I tried to resolve with the answer which is marked correct above But I was not able to get the system setting which was quit amazing (On MacBook).
Most of the time such errors & issues comes because of replacing your grade file with other grade file ,due which gradel does not sync properly and while building the project issue comes . The issue is bascially related to non syncing for platform tools
Solution a: Go to File and then to Your project strucutre -modules -app-Properties -build tool version -click on options which is required for your project (if required build tool version not there chose any other). This will sync the grade file and now you can go to gradel and change target version and build tool version as per your requirement .you will prompted to download the required platform tool to sync it , now click on install tool version and let project to build
Solution b: Try Anuja Ans if you can get option of system setting and install platform tool.
Make sure your computer is connected to the internet, then click on the link that comes with the error message i.e "install missing platform(s) and sync project". Give it a few seconds especially if your computer has low specs, it will bring up a window called SDK Quickfix Installation and everything is straightforward from there.
I got same exception while running gradle build for my android project.
Caused by: java.lang.IllegalStateException: Failed to find target with hash string 'android-27'
This issue related to android SDK version enable for your Android Studio.
Please find the solution of this problem from attached screen.
You can open the SDK standalone by going to installation directory, just right click on the SDK Manager.exe and click on run as Administrator. i hope it will help.
the default gradle version 3.3 may have some bugs, I switched to gradle 3.5 and everything got ok
I have got same error for Android-28. In SDK manager - SDK Platform it shows me that Android API 28 is partially installed and no further updates available. so that I updated ANDROID-SDK-BUILD-TOOLS from SDK Tools and after restarting project. It will work. This might be helpful for other who faces same issue as I faced.
It seems like that it is only me who are so clumsy, because i have yet to found a solution that my case required.
I am developing a multi-modular project, thus base android module configuration is extracted in single gradle script. All the concrete versions of sdks/libs are also extracted in a script.
A script containing versions looked like this:
...
ext.androidVersions = [
compile_sdk_version : '27',
min_sdk_version : '19',
target_sdk_version : '27',
build_tool_version : '27.0.3',
application_id : 'com.test.test',
]
...
Not accustomed to groovy syntax my eye has not spotted that the values for compile, min and target sdks were not integers but STRINGS! Therefore a compiler rightfully complained about not being able to find an sdk a version of which would match HASH STRING '27'.
So the solution would be to make sdk's versions integers:
...
ext.androidVersions = [
compile_sdk_version : 27,
min_sdk_version : 19,
target_sdk_version : 27,
build_tool_version : '27.0.3',
application_id : 'com.test.test',
]
...
I had similar issue for android-29. My issue occurred because when AS was unzipping one downloaded SDK I had stopped it. For solving the issue disable gradle offline mode then sync with gradle files. You may need to set proxy and enable it.

Categories

Resources