Generate Signed APK - Error:java: invalid source release: 14 - android

Recently I started with Flutter and made an app, now I am trying to sign the APK for the release version as documented in: https://developer.android.com/studio/publish/app-signing
I have searched a lot on the internet but I have absolutely no clue what I am doing wrong..
When I try to generate the signed APK with my Keystore I am running into an error:
Information:java: Errors occurred while compiling module 'vista_presentie'
Information:javac 1.8.0_242-release was used to compile java sources
Information:Module "vista_presentie" was fully rebuilt due to project configuration/dependencies changes
Information:28-10-2020 19:42 - Build completed with 1 error and 0 warnings in 5 s 852 ms
** Error:java: invalid source release: 14
If I need to give some more information from the code I will update this question as soon as possible, please just ask me :)
Kind Regards,
Kevin

It seems you're using Java 1.8 to compile but in your android studio project you may have set the java language level to 14.
In Android Studio, go to Project Structure -> Modules -> Properties and
set Source Compatibility and Target Compatibility to 1.8 (Java 8)

Related

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.

Android Studio 3.0.1 Error: Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly

I've installed Android studio 3.0.1 then tried to build very first app by choosing an empty activity, but I've got this message:
Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly
and the error message like this:
Unable to resolve dependency for ':app#releaseUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0.
Could not resolve com.android.support:appcompat-v7:26.1.0.
Required by:
project :app
Could not resolve com.android.support:appcompat-v7:26.1.0.
> Could not parse POM https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.pom
> Already seen doctype.
The first part of log message is like this:
2018-01-03 11:11:12,671 [d thread 8] WARN - ect.sync.idea.ProjectSetUpTask - Already seen doctype.
Consult IDE log for more details (Help | Show Log)
2018-01-03 11:11:12,671 [d thread 8] INFO - e.project.sync.GradleSyncState - Gradle sync failed: Already seen doctype.
I've tried some suggested solutions like changing gradle version, update Kotlin plugin(!) and so, but they didn't work.
Any solution?
This problem occurs when the Build Tools Version is not set for the project.
You just set the build tools version by following this process...
By opening your project structure [File->Project Structure] and selecting the Build Tools Version from app's property tab in Modules section.
This will add build tools version to your gradle file (Module:app) and re-sync the project.
The problem caused by my connection. I needed to set proxy to download some components.
For me the issue was one of the external libraries required SDK 28 but android studio didnt have it so it did not work. I installed SDK 28 and the problem was fixed. I saw the problem in the log file it generated
The error happens under fluctuating network. So at first make sure your connection is stable. Plus, if you are using any VPN check your gradle.properties is configured correctly.
The correct form of VPN connection on gradle.properties is as follows,
systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=8080
systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=8080
My host connection is 127.0.0.1, and its port is 8080 for both http and https.
Just one more thing, make sure adding https (It is mandatory).
I had the same problem when i was upgrading to android studio 3.1.2 and the problem i was using the previous JDK which i installed before 5 years back.
The steps:-
Go to File -> Project Structures -> SDK Location -> JDK Location -> check the
Option Use embedded JDK (recommended).
I tried all suggestions, only one works for me:
open 'Gradle' tab on right vertical panel
right click on project name
'Refresh Gradle Dependencies' and wait background downloading
right click on project name again
'Reload Gradle Project' and wait refreshing
I was also stuck with the same issue for quite few minutes till I figured out the solution:
So you have to visit Gradle Releases and
there scroll down a little bit and you will find the plugin version and required gradle version. Make sure you use the latest version of both or the ones which are compatible with each other.
For today I am using :
Android Gradle Plugin Version - 7.0.2
Gradle Version - 7.2
You can update it by navigating to:
> File -> Project Structure -> Project
Suddenly My Project showing this Error(Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly). Then i Try to various solutions but not solved.
Then i close the android studio, and open the project location and delete the .idea and .iml file, After deleting this file open the project again on Android studio, after that the project working fine.
I had the same problem, I did download gradle version and used it as a local distribution.
Settings/Build,../Gradle/Use local distribution.
Else you will have to reinstall all the software.
The solution is kinda of very simple.
It's because the "compileSdkVersion" that you are using
in your build.gradle (Module:app) is higher than the SDK installed in your Android studio.
Now, what to do?
Just go on SDK Manager and download an Api Level higher or equal to your "compileSdkVersion" and you're done
Look at the manifest, something may have to go wrong there. In my case I had this label
<uses-sdk android: minSdkVersion = "7" android: targetSdkVersion = "15" />, which was from an example.
Then the error is displayed, and the correspondent is now updated <uses-sdk android: minSdkVersion = "15" android: targetSdkVersion = "27" />
As #oyeraghib said,
Visit this link to check the compatibility of your Android Gradle Plugin in comparison with Gradle itself. I was using an older version of both and updated to version 7 in both.
File -> Project Structure -> Project
It may take a while. Wait for it to load.
change the grade version to the latest one in gradle-wrapper
Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly
Go to gradle scripts -> build gradle(app) -> made following changes:
Finally it works.

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.

Compiling android application using Java 8

My application is not yet migrated to gradle, we still use Ant build script.
Recently one of our dependent libraries started using Java 8 features.
In order to compile using Java-8 lib, configured ant script to use java 1.8.
with this change, the compilation is successful, but failing in dex phase.
With 20.x build tools I got
"Bad Class File Magic (cafebabe)" error.
With 24.x build tools I got
"[dex] PARSE ERROR: unsupported class file version 52.0"
Seems to get rid of the dex error, i need to use jack toolchain, however as mentioned earlier, I am not using Gradle builds.
Is there any way to use dex with java-8 code? or Jack tools is the only solution?

Generated class list does not exist {module root}\build\intermediates\data-binding-info\release\_generated.txt

I am trying to get data binding set up in my Android project, and I am getting an error whenever I try to build. The top of the stack trace is as follows:
java.lang.RuntimeException: failure, see logs for details. Generated class list does not exist C:\git\android-lm\androidCore\build\intermediates\data-binding-info\debug\\_generated .txt
at android.databinding.tool.util.L.printMessage(L.java:100)
at android.databinding.tool.util.L.e(L.java:87)
at android.databinding.tool.util.Preconditions.check(Preconditions.java:25)
at android.databinding.tool.DataBindingBuilder.readGeneratedClasses(DataBindingBuilder.java:130)
at android.databinding.tool.DataBindingBuilder.getJarExcludeList(DataBindingBuilder.java:118)
at com.android.build.gradle.internal.LibraryTaskManager$16.getExcludeList(LibraryTaskManager.java:550)
at com.android.build.gradle.internal.tasks.LibraryJarTransform.transform(LibraryJarTransform.java:154)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:151)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:148)
at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:55)
at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:47)
at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:147)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(A nnotationProcessingTaskFactory.java:243)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(Annota tionProcessingTaskFactory.java:219)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(Ann otationProcessingTaskFactory.java:230)
Environment:
Windows 8.1
Android Studio 1.4.1 (also tried in 1.3)
Gradle plugin for Android 1.5.0-beta1
Gradle 2.4
Build tools 23.0.2
Target SDK version 23, min version 21 (also tried targeting 22)
Android Library project depending on a variety of java and other android libraries
Dagger, dbFlow with apt code generation.
I have removed all code from my project that actually uses types from the data binding libraries - just the act of enabling data binding in my build.gradle causes this error. I have tried clean and rebuild, clearing my .gradle folder, clearing all .\build folders, restarting android studio but to no avail. The error occurs both from the command line and from within AS.
Any help greatly appreciated.
Most likely, you have this block:
dataBinding {
enabled = true
}
in a module's build.gradle when there are nothing in that module that triggers databinding.

Categories

Resources