Closed
Description
Steps to reproduce
There is an existing issue #130412 for this, which has been closed. I wasn't able to make the suggested fix work for me.
To reproduce:
- Create a minimal flutter project, importing url_launcher: ^6.2.5. (Code example below)
- Set the kotlin version and gradle version according to the fix suggested in the existing issue Module was compiled with an incompatible version of Kotlin #130412
flutter clean
flutter pub get
flutter build apk
Expected results
I expect the app to be built without any errors.
Actual results
During the build process where it says Running Gradle task 'assembleRelease'...
there is an error: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.
Code sample
pubspec.yaml
name: url_launcher_example
description: "A new Flutter project."
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: '>=3.3.1 <4.0.0'
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.6
url_launcher: ^6.2.5
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^3.0.0
flutter:
uses-material-design: true
android/build.gradle
buildscript {
ext.kotlin_version = '1.8.22'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
android/gradle/wrapper/gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip
main.dart
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('URL Launcher Example'),
),
body: const Center(
child: ElevatedButton(
onPressed: _launchURL,
child: Text('Launch URL'),
),
),
),
);
}
static void _launchURL() async {
final Uri url = Uri.parse('https://flutter.dev');
if (await canLaunchUrl(url)) {
await launchUrl(url);
} else {
throw 'Could not launch $url';
}
}
}
Screenshots or Video
No response
Logs
Logs
e: C:/Users/me/.gradle/caches/transforms-3/087801ec877798ebe030b5b8595f25c8/transformed/core-1.10.1/jars/classes.jar!/META-INF/core_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.
e: C:/Users/me/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.8.22/636bf8b320e7627482771bbac9ed7246773c02bd/kotlin-stdlib-1.8.22.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.
e: C:/Users/me/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.8.22/636bf8b320e7627482771bbac9ed7246773c02bd/kotlin-stdlib-1.8.22.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.
e: C:/Users/me/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.8.22/636bf8b320e7627482771bbac9ed7246773c02bd/kotlin-stdlib-1.8.22.jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.
e: C:/Users/me/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.8.22/1a8e3601703ae14bb58757ea6b2d8e8e5935a586/kotlin-stdlib-common-1.8.22.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.
Flutter Doctor output
Doctor output
[√] Flutter (Channel stable, 3.19.3, on Microsoft Windows [Version 10.0.19045.4170], locale en-GB)
• Flutter version 3.19.3 on channel stable at D:\Software\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ba39319843 (10 days ago), 2024-03-07 15:22:21 -0600
• Engine revision 2e4ba9c6fb
• Dart version 3.3.1
• DevTools version 2.31.1
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at D:\Software\Android\SDK
• Platform android-34, build-tools 34.0.0
• ANDROID_HOME = D:\Software\Android\SDK
• ANDROID_SDK_ROOT = D:\Software\Android\SDK
• Java binary at: D:\Software\Android\Studio\jbr\bin\java
• Java version OpenJDK Runtime Environment (build 17.0.9+0--11185874)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 2023.2)
• Android Studio at D:\Software\Android\Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.9+0--11185874)
[√] VS Code, 64-bit edition (version unknown)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension version 3.84.0
X Unable to determine VS Code version.
[√] Connected device (3 available)
• moto g32 (mobile) • ZY22G3SNF8 • android-arm64 • Android 13 (API 33)
• Chrome (web) • chrome • web-javascript • Google Chrome 122.0.6261.129
• Edge (web) • edge • web-javascript • Microsoft Edge 121.0.2277.112
[√] Network resources
• All expected network resources are available.
Activity
AbdeMohlbi commentedon Mar 17, 2024
your may need this first :
https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration
try updating android>settings.gradle file by replacing this line
id "org.jetbrains.kotlin.android" version "{kotlin.version_1}" apply false
with :
id "org.jetbrains.kotlin.android" version "{kotlin.version_2}" apply false
try this by making the kotlin compiler and api version and language version in setting>kotlin compiler inside android studio that could help as i have the same issue
oldmankit commentedon Mar 18, 2024
@AbdeMohlbi Thanks for the suggestion. I actually don't have anything that looks like that in my
settings.gradle
file. But your hint got me looking in the right place, and I found that by upgrading the Android Gradle Plugin using Android Studio's "AGP upgrade assistant", this actually fixed the problem I was having. After running the upgrade assistant, the following line was changed withinsettings.gradle
:became
And after that I could build the project successfully.
AbdeMohlbi commentedon Mar 18, 2024
@oldmankit Exactly brother what i was trying to say is that you can do that from settings also and it will configure the files by itself .
I think someone may find this issue in the near future helpfull .
AbdeMohlbi commentedon Mar 30, 2024
i know this issue has been closed but for anyone in the near future who had stuck to open the AGP assistant like my case try this :
https://stackoverflow.com/questions/70880154/agp-upgrade-assistant-window-not-opening-in-android-studio
github-actions commentedon Apr 13, 2024
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -v
and a minimal reproduction of the issue.