Strange error when upgrading play-services-auth from 15.0.0 to 16.0.1 - android-gradle-plugin

For my android project I upgraded play-services-auth library version from 15.0.0 to 16.0.1
Since then I see following error during the build and it also produces
ajcore files
I have removed my .gradle caches and done build and still see this error.
Anybody else seen this before, how do I fix it?
java.lang.IllegalStateException: Expecting .,<, or ;, but found authapi while unpacking Lcom/google/android/gms/common/api/internal/BaseImplementation$ApiMethodImpl;
at org.aspectj.util.GenericSignatureParser.parseClassTypeSignature(GenericSignatureParser.java:204)
at org.aspectj.util.GenericSignatureParser.parseFieldTypeSignature(GenericSignatureParser.java:155)
at org.aspectj.util.GenericSignatureParser.parseTypeArgument(GenericSignatureParser.java:267)

In my case, removing the Hugo logging plugin fixed the issue.
Check in your gradle file if you have it configured.
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'

It happens because some plugin (added by you) use libs:
org.aspectj:aspectjtools
or
org.aspectj:aspectjrt for codegeneration

Related

'#kotlin.ExperimentalStdlibApi' or '#OptIn(kotlin.ExperimentalStdlibApi::class)'

e: /Users/abc/update/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (29, 33): This declaration is experimental and its usage must be marked with '#kotlin.ExperimentalStdlibApi' or '#OptIn(kotlin.ExperimentalStdlibApi::class)'
i want to build the native project
Just upgraded to Gradle 7.5.1 and it works. Inside your android directory run:
./gradlew wrapper --gradle-version 7.5.1 --distribution-type=all
#steformicola answer didn't work for me but changing the gradle version in
android/gradle/wrapper/gradle-wrapper.properties
to distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
worked for me.
Look at this link for related issues.

react native problem with creating apk: gradle mergeDexRelease

My app works well on react-native-run-android and on gradlew clean provide me build success.
I used to check and creating the apk by using gradlew assembleRelease.
Recently, I faced an error while trying to create the APK and I cant find the right solution.
as far as I understand, some problem with the build.gradle or any gradle settings - the last feature I put was the mauron background geolocation (im not sure if that cause the problem).
I tried:
on gradle.properties :
android.useAndroidX=true
android.enableJetifier=true
org.gradle.daemon=true
org.gradle.configureondemand=true
org.gradle.jvmargs=-Xmx4608m -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
in build.gradle I added: implementation 'androidx.multidex:multidex:2.0.1' in the dependencies.
3.
defaultConfig {
...
multiDexEnabled true
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
// multiDexEnabled true
}
The gradle I used was 6.3. So I upgraded (downloaded from their website v7 but I think the project is still under 6.3).
My question is:
If the app works and build successfuly, was the error because of my code or the gradle settings?
Im over a week with that problem and out of any clue how to get it work.
the error I get:
> Task :app:mergeDexRelease FAILED
D8: Program type already present: org.apache.commons.io.Charsets
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Program type already present: org.apache.commons.io.Charsets
full picture: https://ibb.co/87pFnv1 , https://ibb.co/FxB8PWX
could anyone help me with it?
The error is not about multidex. It clearly says that one of your package is trying to add a library which is already there.
Since you have the name of the library you can put conditional implementation in your build.gradle to avoid redundant implementation.
for example
Implementation('new package that has module'){
exclude module: 'module to exclude'
}
Finally I solved the problem, Thanks Shashank Shekhar for directing me to the correct problem.
I used mauron85/react-native-background-geolocation package, was working fine until I tried to create apk.
in mauron85 issue #505 there was similar problem and someone fixed it by forking and maintaining the repo.
if anyone face that issue in future, I recommend to use #darron1217/react-native-background-geolocation as it solved the error.
Resolved: I have two packages #react-native-masked-view/masked-view (from previous developer) and #react-native-community/masked-view. Just remove #react-native-masked-view/masked-view package and try build.
https://github.com/react-native-masked-view/masked-view/issues/100#issuecomment-841634389 Thanks to: Navipro70

IntelliJ Error:java: java.lang.ExceptionInInitializerError

Every time I encounter this exception in IntelliJ, I fix it trivially and forget the fix easily.
Code:
package whatever;
import org.junit.Test;
public class TestClass
{
#Test
void test() {}
}
Scenario:
Add new TestClass.
Right-click TestClass.
Select "Run 'TestClass'" to run test cases.
The "Messages Build" pane shows:
Information:javac 9-ea was used to compile java sources
Information:Module "dummy" was fully rebuilt due to project configuration/dependencies changes
Information:8/16/17 11:35 PM - Compilation completed with 1 error and 0 warnings in 1s 663ms
Error:java: java.lang.ExceptionInInitializerError
What can possibly go wrong?
What are the likely issues in this simple scenario?
IntelliJ: COMMUNITY 2017.1 (idea-IC-171.4424.56)
To fix the issue, I do:
File -> Project Structure... -> Project Settings / Project -> Project SDK.
Change from "9-ea" to "1.8".
DETAILS
Apparently, the issue is discrepancies in selected JDK-s to build (java 9) and run (java 8).
I'm not sure how "9-ea" gets re-selected there for the same project - neither IntelliJ itself runs in "9-ea" JRE (according to Help -> About) nor JAVA_HOME env var is set to it nor other possible settings (like Maven -> Runner) suggest any "9-ea".
I also didn't manage to run the test under the same JDK (java 9) which it gets compiled under. However, it's unclear what JDK tests are run under because IntelliJ reports only about JDK for compilation.
If you use Lombok: For me it was a solution to set the newest version for my maven lombok dependency in the pom.xml.
*<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
<version>1.18.8</version>
</dependency>*
I was facing same error when i tried to run my application in IntelliJ-2019.2 version. Below are the steps i followed to resolve this issue.
Versions:
IntelliJ : IDEA-IntelliJ-2019.2
Java : jdk1.8_221
Go to below path in IntelliJ
File -> Project Structure -> Project -> Project SDK -> (select java version which you want to use )
(In my case under 'project SDK' java-11 was selected, I changed it to 'java8')
Click on 'Apply' and then 'OK'.
I feel I ran into this issue because IntelliJ was trying to compile my java classes using in-built java-11 whereas my java classes are built on java-8. So when i explicitly configured java-8 in IntelliJ, It worked!! Hope this helps.
I started seeing this exception once I installed Java 11 in my machine. JAVA_HOME was by default pointing to Java 11 and my project was still in Java 8. Changing JAVA_HOME to Java 8 jdk fixed the issue for me.
If you have multiple projects each running on a different JDK, use this command to temporarily change the Java version per command.
JAVA_HOME=/path/to/JVM/jdk/Home mvn clean install
If you have recently updated your IDE then you can try these steps.
Delete .idea directory for the idea project/workspace
Then go to File -> Invalidate Caches / Restart...
Once Idea is restarted re-add/import your module(s)
I faced a similar issue with JARs and Jena (while run from IntelliJ it works).
I was using Apache Jena v4.0.0 in my project and have built a JAR (with a main class for the JAR to act as a console app).
The JAR builts successfully with IntelliJ but when run throws java.lang.ExceptionInInitializerError ... Caused by: java.lang.NullPointerException. NPE suggests that something was not initialized properly.
The jar built with previous version Jena 3.17.0 works perfectly.
What I did to fix it
I've opened both the JARs, compared their META-INF folders and encountered the difference in
my.jar\META-INF\services\org.apache.jena.sys.JenaSubsystemLifecycle
The new version (jena v4.0.0) contains only one line:
org.apache.jena.tdb.sys.InitTDB
The old version (jena v3.17.0) contains two different lines:
org.apache.jena.riot.system.InitRIOT
org.apache.jena.sparql.system.InitARQ
I've added the old two lines to the file and repacked new JAR with it:
org.apache.jena.tdb.sys.InitTDB
org.apache.jena.riot.system.InitRIOT
org.apache.jena.sparql.system.InitARQ
It resolved my issue.
Update: recent Jena v4.4.0 builts with the same "bug".
I'm not an expert and there is probably a better way than patching a JAR by hand.
But I still hope that this solution will help someone like me.

Trouble with jitpack/gradle in Intellij

I'm still getting started with gradle, but I found jitpack to allow for including dependencies across my github repos.
I'm having issues getting dependencies to resolve, though. Some releases work, but other times I get "could not resolve."
I have managed to reproduce this with a couple of github repos:
I set up a repo to be depended on: https://github.com/bdleitner/dummy-dependency
and one to depend on it: https://github.com/bdleitner/dummy-client
From jitpack, I can see the build log for the 0.1.3 release of dummy-dependency:
https://jitpack.io/com/github/bdleitner/dummy-dependency/0.1.3/build.log
where it seems that everything is successful.
when logged in to jitpack, it can see this release and provides the compile statement:
compile 'com.github.bdleitner:dummy-dependency:0.1.3'
but even when I include that in the gradle.build file for dummy-client,
I get:
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all dependencies for configuration ':compileClasspath'.
> Could not resolve com.github.bdleitner:dummy-dependency:0.1.3.
Required by:
com.bdl:dummy-client:1.0-SNAPSHOT
> No cached version of com.github.bdleitner:dummy-dependency:0.1.3 available for offline mode.
> No cached version of com.github.bdleitner:dummy-dependency:0.1.3 available for offline mode.
> No cached version of com.github.bdleitner:dummy-dependency:0.1.3 available for offline mode.
I figure I'm probably missing something small and dumb, but I haven't been able to find it.
Apparently, I somehow managed to switch my gradle settings to offline mode (not sure how)... but unchecking that option appears to have fixed the issue.
Sorry to bother everyone.

Failed to load late-bound plugin: org.apache.maven.plugins:maven-resources-plugin

We have our local Maven repository which was working fine till yesterday.
Today we are getting the following error while building any project.
Failed to load late-bound plugin: org.apache.maven.plugins:maven-resources-plugin
We haven't change any settings. Any idea?
It's hard to say because you skipped the next line that prints the Reason. A typical output looks like:
[WARN] Failed to load plugin: org.apache.maven.plugins:maven-resources-plugin. Adding to late-bound plugins list.
Reason: Failed to load plugin. Reason: The plugin 'org.apache.maven.plugins:maven-resources-plugin' does not exist or no valid version could be found
It would have been interesting to join this line to find a fix for the root cause of the problem.
I resolved it.
I had to delete the plugins folder on my local repository then Maven downloaded the plugins again.
It works fine now.