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

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.

Related

Many function is unresolved after Android Studio Chipmunk(11.0.12) Update

There is no problem with all codes before the update.
But After the update, many functions are unresolved.
My Android Studio version.
error code1
error code2
error code3
All error contents are Unresolved reference:~~.
my dependencies 1
my dependencies 2
There are my dependencies.
There is an error in the code, but the build works fine.
What's the problem?
Your compiler is unable to generate project files. Change the room dependencies(if being used) to '2.4.2' and upgrade your gradle to 7.0+
Also go to Android Studio-> preferences-> Build, version...-> Build tools-> Gradle and change the Gradle JDK to 11.

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

Error: Method not found: 'Error.throwWithStackTrace'. Error.throwWithStackTrace(exception, stackTrace); im getting this error while running [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

Zip file app/build/intermediates/app_classes/release/classes.jar' already contains entry 'META-INF/MANIFEST.MF', cannot overwrite

When building my Android app with Android-Studio in debug, it works, but when building in release mode, I get the following error at the :app:bundleReleaseClasses step:
Zip file app/build/intermediates/app_classes/release/classes.jar' already contains entry 'META-INF/MANIFEST.MF', cannot overwrite
Building in CLI with ./gradlew assembleDebug (or even ./gradlew bundleReleaseClasses) works.
What could be the reason for this error in Android-Studio, knowing that it works in gradle CLI? I tried excluding this file in packagingOptions {}, but it does not seem to have any effect.
I tried this, this, this, this and a few other related questions, but did not find an answer.
Note that it fails with AGP 7.0.0, 7.0.1, 7.0.2, 7.0.3 and 7.0.4. Not sure if I should try going further back.
Just Update your Gradle plugin version version
I had the same error in Android Studio Chipmunk| 2021.2.1 and Gradle version 7.1.2
and after updating Gradle plugin version to 7.2.0 this problem is resolved.

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

Categories

Resources