Runtime jar files should have the same version - android

I ran flutter build apk command, and got this error message:
-warning: runtime JAR files in the classpath should have the same version. These files were found in the classpath:
C:/Users/df/.gradle/caches/transforms-3/c4db2a2e2bfa2cf0924c25e91aac4d6a/transformed/jetified-kotlin-stdlib-jdk8-1.5.30.jar (version 1.5)
C:/Users/df/.gradle/caches/transforms-3/b0126bc96e555a2082a27f473d9f94a5/transformed/jetified-kotlin-stdlib-jdk7-1.6.10.jar (version 1.6)
C:/Users/df/.gradle/caches/transforms-3/2326aa9655cc3a19a1b75942737122e7/transformed/jetified-kotlin-stdlib-1.7.10.jar (version 1.7)
C:/Users/df/.gradle/caches/transforms-3/b051c0392c8cb298c95166e24c62b4c4/transformed/jetified-kotlin-stdlib-common-1.7.10.jar (version 1.7)
warning: some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath
C:\Users\df\.gradle\caches\modules-2\files-2.1\androidx.annotation\annotation\1.5.0\857678d6b4ca7b28571ef7935c668bdb57
e15027\annotation-1.5.0.jar!\META-INF\annotation.kotlin_module: error: module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
C:\Users\df\.gradle\caches\transforms-3\2326aa9655cc3a19a1b75942737122e7\transformed\jetified-kotlin-stdlib-1.7.10.jar
!\META-INF\kotlin-stdlib.kotlin_module: error: module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
C:\Users\df\.gradle\caches\transforms-3\b051c0392c8cb298c95166e24c62b4c4\transformed\jetified-kotlin-stdlib-common-1.7
.10.jar!\META-INF\kotlin-stdlib-common.kotlin_module: error: module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileReleaseKotlin'.
> Compilation error. See log for more details
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 17m 38s
Running Gradle task 'assembleRelease'... 1074.0s
┌─ Flutter Fix ───────────────────────────────────────────────────────────────────────────────────────┐
│ [!] Your project requires a newer version of the Kotlin Gradle plugin. │
│ Find the latest version on https://kotlinlang.org/docs/gradle.html#plugin-and-versions, then update │
│ C:\Users\df\AndroidStudioProjects\healthypub\android\build.gradle: │
│ ext.kotlin_version = '<latest-version>'
I have already installed the latest version of Kotlin Gradle plugin which is version 1.8.0 RC2 in Android Studio. Please help me fix this issue. I want to get apk file.

Related

How to tackle an error : Build failed with an exception

Launching lib\main.dart on M2006C3MII in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
Where:
Build file 'C:\Users\Rana\Desktop\Flutter Projects\new_soft\android\build.gradle' line: 26
What went wrong:
A problem occurred evaluating root project 'android'.
A problem occurred configuring project ':app'.
Could not open proj generic class cache for build file 'C:\Users\Rana\Desktop\Flutter Projects\new_soft\android\app\build.gradle' (C:\Users\Rana.gradle\caches\7.5\scripts\52edrvulxtnk4ivgfae602cyx).
> BUG! exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 63
Try:
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 3s
Exception: Gradle task assembleDebug failed with exit code 1
Post your project build gradle codes in question
This error message is indicating that there is a compatibility issue between the version of the Java compiler being used to build the project and the version of the compiled class files. The error message specifically mentions that the "major version 63" of the class file is not supported by the compiler.
The major version numbers of Java class files follow a release-versioning scheme. In this case, "63" likely corresponds to Java SE 11 (18.9), while the compiler being used may not support that version.
To resolve this issue, you may need to update the compiler to a version that supports the class file major version, or alternatively, you can try to recompile the class files with a compatible version of the Java compiler.
This answer can help you open it

Error occurred while implement livekit_client: ^0.5.9 package #flutter

error:
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring project ':livekit_client'.
Could not load compiled classes for build file 'C:\src\flutter.pub-cache\hosted\pub.dartlang.org\livekit_client-0.5.9\android\build.gradle' from cache.
Failed to notify project evaluation listener.
Could not get unknown property 'android' for project ':livekit_client' of type org.gradle.api.Project.
Could not find method implementation() for arguments [project ':flutter_webrtc'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Could not find method implementation() for arguments [project ':device_info_plus'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Could not get unknown property 'android' for project ':livekit_client' of type org.gradle.api.Project.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 6s
Exception: Gradle task assembleDebug failed with exit code 1
**Flutter version**
PS D:\AndroidStudioProjects\git_repo\talky> flutter --version
Flutter 2.10.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 5464c5bac7 (3 weeks ago) • 2022-04-18 09:55:37 -0700
Engine • revision 57d3bac3dd
Tools • Dart 2.16.2 • DevTools 2.9.2
PS D:\AndroidStudioProjects\git_repo\talky>
**AndroidMainfest.xml**
required permissions +
<application
.....
.....
<service
android:name="de.julianassmann.flutter_background.IsolateHolderService"
android:enabled="true"
android:exported="false"
android:foregroundServiceType="mediaProjection" />
</application>
**Kotlin version - 1.6.10
Project level Build gradle
Dependency
**
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
flutter clean,pub get,invalidcash restart not work
How I solved my problem by following the below method:
remove the problem making package from
/.pub-cache/hosted/pub.dartlang.org
Run flutter pub get
change this:
distributionUrl=https://services.gradle.org/distributions/gradle-5.6.2-all.zip
to this:
distributionUrl=https://services.gradle.org/distributions/gradle-6.5-all.zip
and then in project-folder/buil.gradle
change this:
classpath 'com.android.tools.build:gradle:3.5.0'
to this:
classpath 'com.android.tools.build:gradle:4.1.1'
and then run this command
flutter clean
build or run your project. In this version livekit_client : ^0.5.9 android gradle has been updated. thats why we need to update android project gradle to 4.1.1.
good luck.

flutter master channel issue

Launching lib\main.dart on AOSP on IA Emulator in debug mode...
Running Gradle task 'assembleDebug'...
Warning: The plugin path_provider_android requires Android SDK version 31.
Warning: The plugin shared_preferences_android requires Android SDK version 31.
One or more plugins require a higher Android SDK version.
Fix this issue by adding the following to D:\App Dev Projects\marvelyprojects\android\app\build.gradle:
android {
compileSdkVersion 31
...
}
Parameter format not correct -
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
Multiple task action failures occurred:
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.window:window-java:1.0.0-beta04.
AAR metadata file: C:\Users\ashra.gradle\caches\transforms-2\files-2.1\8f42c4deb4a5577a51d166e18b5fb030\jetified-window-java-1.0.0-beta04\META-INF\com\android\build\gradle\aar-metadata.properties.
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.window:window:1.0.0-beta04.
AAR metadata file: C:\Users\ashra.gradle\caches\transforms-2\files-2.1\3f788c64cd9fb84deaf5d81b1bbcf4d4\jetified-window-1.0.0-beta04\META-INF\com\android\build\gradle\aar-metadata.properties.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 11s
Exception: Gradle task assembleDebug failed with exit code 1
Following steps fixed the same issue which I was facing on flutter/vscode.
1/..android\app\build.gradle: change 'compileSdkVersion' and 'targetSdkVersion' to 31 (from 30)
2/ above change gave new error ==> ....
build\app\intermediates\packaged_manifests\debug\AndroidManifest.xml:2: AAPT: error: attribute 'package' in tag is not a valid Android package name: 'com.ulusoyapps.sharewhatyouknow.002-navigator2'.
3/ as per https://developer.android.com/guide/topics/manifest/manifest-element.html#package, packagge name was incorrect. I changed it to 'com.ulusoyapps.sharewhatyouknow.a002_navigator2' ,
"package" ==> build\app\intermediates\packaged_manifests\debug\AndroidManifest.xml
"applicationId" ==> android\app\build.gradle
4/ above change gave following error...
BUILD FAILED in 11s
┌─ Flutter Fix ────────────────────────────────────────────────────────────────────────────────────┐
│ [!] Your project requires a newer version of the Kotlin Gradle plugin. │
│ Find the latest version on https://kotlinlang.org/docs/gradle.html#plugin-and-versions, then │
│ update D:\adnan\flutter\ex\Flutter-ShareWhatYouKnow-develop\002-navigator2\android\build.gradle: │
│ ext.kotlin_version = '' │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘
5/ changed ext.kotlin_version = '1.3.50' in ... android\build.gradle to 1.6.10

-->>Exception: Gradle task assembleDebug failed with exit code 1

FAILURE: Build failed with an exception.
Where:
Build file 'C:\Users\romit\Desktop\FlutterSoft\projects\basic_app\android\build.gradle' line: 26
What went wrong:
A problem occurred evaluating root project 'android'.
A problem occurred configuring project ':app'.
Could not open proj generic class cache for build file 'C:\Users\romit\Desktop\FlutterSoft\projects\basic_app\android\app\build.gradle' (C:\Users\romit.gradle\caches\6.7.1\scripts\4hhqko2lgng4etjv4i11vmj58).
> BUG! exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 60
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 1s
Exception: Gradle task assembleDebug failed with exit code 1
NOTE: I have already updated the gradle. Also tried solving it by using gradlew clean and gradlew build.
DOES ANYONE HAVE SOLUTION FOR THIS?
///build.gradle snippets
Code LINE -1-27
Remaining Lines
Major Version 60 is for Java 16 - see https://en.wikipedia.org/wiki/Java_class_file#General_layout.
As far as I know Android does not support this java version at all. Also it seems Android Studio does only support Java 7 (full) and Java 8 (partial) - see https://developer.android.com/studio/write/java8-support.
Android Gradle plugin 3.0.0 and later support all Java 7 language
features and a subset of Java 8 language features that vary by
platform version. When building your app using Android Gradle plugin
4.0.0 and higher, you can use a number of Java 8 language APIs without requiring a minimum API level for your app.
I am using Eclipse most time, but I think the settings can be done as described at
https://developer.android.com/studio/intro/studio-config#jdk

How do I fix "A problem occurred evaluating project ':CordovaLib'." when running 'cordova run android'

I am trying to build my android app and am getting an error about the version of Gradle that is being used. When I make the change that is suggested and run the command again the change gets changed back causing it to fail again.
I have tried replacing all references to gradle-4.1-all.zip with gradle-4.10.1-all.zip and for some reason it keeps getting changed back at this location /gradle/wrapper/gradle-wrapper.properties to gradle-4.10.1-all.zip
Android Studio project detected
ANDROID_HOME=/Users/user.account/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home
studio
Subproject Path: CordovaLib
Subproject Path: app
FAILURE: Build failed with an exception.
Where:
Build file '/Users/user.account/cordovaProjects/hybrid-base/platforms/android/CordovaLib/build.gradle' line: 41
What went wrong:
A problem occurred evaluating project ':CordovaLib'.
Failed to apply plugin [id 'com.android.library']
Minimum supported Gradle version is 4.10.1. Current version is 4.1. If using the gradle wrapper, try editing the distributionUrl in /Users/user.account/cordovaProjects/hybrid-base/gradle/wrapper/gradle-wrapper.properties to gradle-4.10.1-all.zip
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org
BUILD FAILED in 0s
/Users/user.account/cordovaProjects/hybrid-base/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
Where:
Build file '/Users/user.account/cordovaProjects/hybrid-base/platforms/android/CordovaLib/build.gradle' line: 41
What went wrong:
A problem occurred evaluating project ':CordovaLib'.
Failed to apply plugin [id 'com.android.library']
Minimum supported Gradle version is 4.10.1. Current version is 4.1. If using the gradle wrapper, try editing the distributionUrl in /Users/user.account/cordovaProjects/hybrid-base/gradle/wrapper/gradle-wrapper.properties to gradle-4.10.1-all.zip
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org
BUILD FAILED in 0s
I am able to get a build to work if I do a cordova platform remove android and then immediately cordova platform add android but as soon as I try to build a second time it fails
If for any reason you need a different version of gradle there is no need to edit any file, just set the CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL env var with value the url where to fin the gradle zip, for example
http://services.gradle.org/distributions/gradle-4.1-all.zip
I do not have any problem with version 4.1 ( win10, android platform 7.1.4 ).
After you set your desired gradle version, reset your project ( remove all plugin and all platforms and manual edits then reinstall ) and then try to build.
If the problem persist, to help you better, post the error and please specify which OS, cordova version and android platform version you are using.
As a rule of thumb, from my experience with cordova, when you think that the only way to set a certain configuration is to edit platform files, there is probably a proper way to do so ( for example to automatically sign the apk when build )

Categories

Resources