Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failed when updating to latest version #729

Closed
mhd-ghaith-abtah opened this issue Aug 11, 2023 · 40 comments
Closed

Build failed when updating to latest version #729

mhd-ghaith-abtah opened this issue Aug 11, 2023 · 40 comments
Assignees

Comments

@mhd-ghaith-abtah
Copy link

mhd-ghaith-abtah commented Aug 11, 2023

when I updated to latest version "mobile_scanner 3.4.1" I got this error when trying to run my project:
ERROR:D8: com.android.tools.r8.kotlin.H

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:mergeExtDexDebug'.

Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Failed to transform kotlin-stdlib-1.9.0.jar (org.jetbrains.kotlin:kotlin-stdlib:1.9.0) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Execution failed for DexingWithClasspathTransform: /Users/ghaithabtah/.gradle/caches/transforms-3/a0583c7606e960d1c6435c51b205f3f3/transformed/jetified-kotlin-stdlib-1.9.0.jar.
> Error while dexing.

  • 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.

BUILD FAILED in 27s

┌─ Flutter Fix ──────────────────────────────────────────────────────────────┐
│ [!] The shrinker may have failed to optimize the Java bytecode. │
│ To disable the shrinker, pass the --no-shrink flag to this command. │
│ To learn more, see: https://developer.android.com/studio/build/shrink-code
└────────────────────────────────────────────────────────────────────────────┘
Exception: Gradle task assembleDebug failed with exit code 1

I have seen your build.gradle file and you are using ext.kotlin_version = '1.9.0' which is not widely supported yet.
could please downgrade to 1.8.0 at least

this is my build.gradle file:
buildscript {
ext.kotlin_version = '1.8.0'
repositories {
google()
mavenCentral()
}

dependencies {
    classpath 'com.android.tools.build:gradle:7.4.2'
    // START: FlutterFire Configuration
    classpath 'com.google.gms:google-services:4.3.15'
    // END: FlutterFire Configuration
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}

}

@jgarciamccausland
Copy link

Any updates or workarounds?

@kgadva
Copy link

kgadva commented Aug 16, 2023

For me it worked to update the Kotlin version in the build.gradle file to 1.9.0
ext.kotlin_version = '1.9.0'

@jgarciamccausland
Copy link

Yep, that worked in our environment as well. Thanks!

@hatch01
Copy link

hatch01 commented Aug 17, 2023

It work, but many other packages are incompatible with this Kotlin version, so I can't use it in my project.
And I get some warning using it :

e: /var/home/eymeric/tmp/flutter_test/scan/build/mobile_scanner/.transforms/d8c2b2ffdd2df0218a0d2aa7e5cd360e/transformed/out/jars/classes.jar!/META-INF/mobile_scanner_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.6.0.
e: /var/home/eymeric/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.9.0/8ee15ef0c67dc83d874f412d84378d7f0eb50b63/kotlin-stdlib-1.9.0.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.6.0.
e: /var/home/eymeric/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.9.0/8ee15ef0c67dc83d874f412d84378d7f0eb50b63/kotlin-stdlib-1.9.0.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.9.0, expected version is 1.6.0.
e: /var/home/eymeric/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.9.0/8ee15ef0c67dc83d874f412d84378d7f0eb50b63/kotlin-stdlib-1.9.0.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.9.0, expected version is 1.6.0.
e: /var/home/eymeric/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.9.0/cd65c21cfd1eec4d44ef09f9f52b6d9f8a720636/kotlin-stdlib-common-1.9.0.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.9.0, expected version is 1.6.0.

@hatch01
Copy link

hatch01 commented Aug 28, 2023

Any other workarounds?

@sharsad
Copy link

sharsad commented Sep 8, 2023

A problem occurred evaluating project ':app'.

Could not initialize class org.jetbrains.kotlin.gradle.plugin.KotlinGradleBuildServices

@mazud21
Copy link

mazud21 commented Oct 3, 2023

when I updated to latest version "mobile_scanner 3.4.1" I got this error when trying to run my project: ERROR:D8: com.android.tools.r8.kotlin.H

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:mergeExtDexDebug'.

Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Failed to transform kotlin-stdlib-1.9.0.jar (org.jetbrains.kotlin:kotlin-stdlib:1.9.0) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.

Execution failed for DexingWithClasspathTransform: /Users/ghaithabtah/.gradle/caches/transforms-3/a0583c7606e960d1c6435c51b205f3f3/transformed/jetified-kotlin-stdlib-1.9.0.jar.
Error while dexing.

  • 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.

BUILD FAILED in 27s

┌─ Flutter Fix ──────────────────────────────────────────────────────────────┐ │ [!] The shrinker may have failed to optimize the Java bytecode. │ │ To disable the shrinker, pass the --no-shrink flag to this command. │ │ To learn more, see: https://developer.android.com/studio/build/shrink-code │ └────────────────────────────────────────────────────────────────────────────┘ Exception: Gradle task assembleDebug failed with exit code 1

I have seen your build.gradle file and you are using ext.kotlin_version = '1.9.0' which is not widely supported yet. could please downgrade to 1.8.0 at least

this is my build.gradle file: buildscript { ext.kotlin_version = '1.8.0' repositories { google() mavenCentral() }

dependencies {
    classpath 'com.android.tools.build:gradle:7.4.2'
    // START: FlutterFire Configuration
    classpath 'com.google.gms:google-services:4.3.15'
    // END: FlutterFire Configuration
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}

}

save my day, thanks

@thamaraSenanayake
Copy link

try to update the minSdkVersion

@vbuberen
Copy link
Contributor

It seems to me that the issue is in fact that to use Kotlin 1.9.x project needs to already be on Android Gradle Plugin 8. I have already discovered it in Plus Plugins and this is the reason why I am reverting Kotlin version back to 1.7.22 till AGP 8 is more adopted among Flutter projects.

Error comes from R8 in AGP older than 8.x not supporting Kotlin 1.9.x as it can be seen here: https://developer.android.com/build/kotlin-support

@juliansteenbakker
Copy link
Owner

Hi all, i'm testing if downgrading the version won't break anything. If not, then ill release a new version with downgraded kotlin version.

@KolyaParadiuk
Copy link

KolyaParadiuk commented Oct 18, 2023

Hi! I had the same problem, but managed to run app.
I added jcenter() in android/build.gradle in allprojects

allprojects {
    repositories {
        google()
        mavenCentral()
        jcenter()

    }
}

use ext.kotlin_version = '1.9.0'
and classpath 'com.android.tools.build:gradle:7.2.2'

with this configuration app runs without errors

@donjordano
Copy link

donjordano commented Oct 22, 2023

the only thing that worked for me was adding this to app/build.gradle

configurations.all { resolutionStrategy { eachDependency { if ((requested.group == "org.jetbrains.kotlin") && (requested.name.startsWith("kotlin-stdlib"))) { useVersion("1.7.10") } } } }

@navaronbracke
Copy link
Collaborator

@mhd-ghaith-abtah Are you still having this issue when using version 3.5.1? We recently did a downgrade to Kotlin 1.7.x due to an issue with Kotlin 1.9.x

@thiagosoaress2
Copy link

Hi! I had the same problem, but managed to run app. I added jcenter() in android/build.gradle in allprojects

allprojects {
    repositories {
        google()
        mavenCentral()
        jcenter()

    }
}

use ext.kotlin_version = '1.9.0' and classpath 'com.android.tools.build:gradle:7.2.2'

with this configuration app runs without errors

This worked for me. I was previosloy using classpath 'com.android.tools.build:gradle:7.4.2'

@navaronbracke
Copy link
Collaborator

@thiagosoaress2 I advise not using jcenter, as is was sunset a while ago: https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/

Is there a specific reason why you need Kotlin version 1.9.0 ? The plugin was downgraded back to Kotlin 1.7.x due to complaints from other users.

There shouldn't be an issue with the com.android.tools.build:gradle version. The plugin itself is using Gradle 8 even, which works fine on the example app.

@Jacqqq
Copy link

Jacqqq commented Nov 6, 2023

After long fight with gradle,
eventually ended up with setup

kotlin 1.8.0
classpath 'com.android.tools.build:gradle:7.2.2'
classpath 'com.google.gms:google-services:4.3.15' !

@IwanPWK
Copy link

IwanPWK commented Nov 8, 2023

delete folder .gradle, go to inside build, delete all folders, or just delete folder build, then setup like this
kotlin 1.8.0, 1.9.0 whatever
classpath 'com.android.tools.build:gradle:7.2.2'
classpath 'com.google.gms:google-services:4.3.15'

just in case (optional)
maybe you have to set up
Future main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(const MyApp());

@alexandrim0
Copy link

deleting of .grade and build solve problem even with kotlin 1.9.0 and gradle 8.1.0

@adrianvintu
Copy link

adrianvintu commented Dec 29, 2023

The following configuration worked for me when migrating to AGP8:

build.gradle

buildscript {
    ext.kotlin_version = '1.9.0'
    repositories {
        google()
        jcenter()
        maven { url 'https://developer.huawei.com/repo/' }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:8.1.1'
        classpath 'com.google.gms:google-services:4.3.15'
        classpath 'com.google.firebase:perf-plugin:1.4.2'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.6'
        classpath 'com.huawei.agconnect:agcp:1.5.2.300'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
...

app\build.gradle

...
apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.firebase-perf'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
//apply plugin: 'com.huawei.agconnect'

android {
    // Conditional for compatibility with AGP <4.2.
    if (project.android.hasProperty("namespace")) {
      namespace 'my_namespace'
    }

    compileSdkVersion 34
...		  

gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
#https://developer.android.com/studio/releases/gradle-plugin
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip

Forks (if required):
https://github.com/adrianvintu/file_saver
https://github.com/adrianvintu/flutter_statusbarcolor
https://github.com/adrianvintu/hms-flutter-plugin

@LuqmaanMohammed
Copy link

Launching lib/main.dart on sdk gphone64 x86 64 in debug mode...
Running Gradle task 'assembleDebug'...
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
ERROR:D8: com.android.tools.r8.kotlin.H

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:mergeExtDexDebug'.

Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Failed to transform kotlin-stdlib-1.9.0.jar (org.jetbrains.kotlin:kotlin-stdlib:1.9.0) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Execution failed for DexingWithClasspathTransform: /home/abdul-luqmaan-mohammed/.gradle/caches/transforms-3/8f02b104beefc3f04668ea04ea792135/transformed/jetified-kotlin-stdlib-1.9.0.jar.
> Error while dexing.

  • 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.

BUILD FAILED in 38s

┌─ Flutter Fix ──────────────────────────────────────────────────────────────┐
│ [!] The shrinker may have failed to optimize the Java bytecode. │
│ To disable the shrinker, pass the --no-shrink flag to this command. │
│ To learn more, see: https://developer.android.com/studio/build/shrink-code
└────────────────────────────────────────────────────────────────────────────┘
Exception: Gradle task assembleDebug failed with exit code 1

this is the error
and this is the build.gradle file
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

buildscript {
repositories {
google()
jcenter()
}

dependencies {
    classpath 'com.android.tools.build:gradle:8.2.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0"
}

}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
compileSdkVersion 34
compileSdk flutter.compileSdkVersion
ndkVersion '25.1.8937393'

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
    jvmTarget = '1.8'
}

sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
    applicationId "com.pavlenko.Habo"
    minSdkVersion 21
    compileSdk 34
    targetSdkVersion 34
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    multiDexEnabled true
    ndk { abiFilters "arm64-v8a", "armeabi-v7a", "x86_64" }
}

signingConfigs {
    release {
        keyAlias keystoreProperties['keyAlias']
        keyPassword keystoreProperties['keyPassword']
        storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
        storePassword keystoreProperties['storePassword']
    }
}

buildTypes {
    release {
        signingConfig signingConfigs.release
    }
}

}

flutter {
source '../..'
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.9.0"
// ... other dependencies ...
}

@LuqmaanMohammed
Copy link

please help

@navaronbracke
Copy link
Collaborator

The mobile_scanner example application runs fine with Kotlin 1.9.x, however, your combination of dependencies might not be compatible with Kotlin 1.9.x

Does it work if you switch to Kotlin 1.8.x ?

@LuqmaanMohammed
Copy link

No it doesn't work

@navaronbracke
Copy link
Collaborator

navaronbracke commented Jan 1, 2024

We are going to need the full gradle build log to see what the actual issue is. Could you open the native Android project and run a Gradle build with the --stacktrace and --info options? (--stacktrace and --debug might help too)

I also noticed, you are running Gradle 8, with Java 8. Could you ty to upgrade Java to Java 17? (see the example app for the Java 17 configuration)

@LuqmaanMohammed
Copy link

java.lang.RuntimeException: Cannot find service com.android.tools.idea.explainer.IssueExplainer (classloader=PluginClassLoader(plugin=PluginDescriptor(name=Android, id=org.jetbrains.android, descriptorPath=plugin.xml, path=/snap/android-studio/140/plugins/android, version=231.9392.1.2311.11076708, package=null, isBundled=true), packagePrefix=null, instanceId=117, state=active), client=null)
at com.android.tools.idea.gradle.actions.ExplainSyncOrBuildOutput.(ExplainSyncOrBuildOutput.kt:71)
at com.android.tools.idea.gradle.project.build.invoker.GradleBuildInvokerImpl$MyListener$onStart$buildDescriptor$1.apply(GradleBuildInvokerImpl.kt:431)
at com.android.tools.idea.gradle.project.build.invoker.GradleBuildInvokerImpl$MyListener$onStart$buildDescriptor$1.apply(GradleBuildInvokerImpl.kt:429)
at com.intellij.build.DefaultBuildDescriptor.lambda$getContextActions$0(DefaultBuildDescriptor.java:147)
at com.intellij.util.containers.ContainerUtil.map(ContainerUtil.java:1951)
at com.intellij.build.DefaultBuildDescriptor.getContextActions(DefaultBuildDescriptor.java:147)
at com.intellij.build.BuildTreeConsoleView$1.invokePopup(BuildTreeConsoleView.java:228)
at com.intellij.ui.PopupHandler.mousePressed(PopupHandler.java:47)
at java.desktop/java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:288)
at java.desktop/java.awt.Component.processMouseEvent(Component.java:6654)
at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3385)
at com.intellij.ui.treeStructure.Tree.processMouseEvent(Tree.java:424)
at java.desktop/java.awt.Component.processEvent(Component.java:6422)
at java.desktop/java.awt.Container.processEvent(Container.java:2266)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5027)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4855)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4954)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4578)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4522)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)
at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2808)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4855)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:791)
at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:740)
at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:734)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:764)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:762)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:761)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:667)
at com.intellij.ide.IdeEventQueue.dispatchMouseEvent(IdeEventQueue.kt:615)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:570)
at com.intellij.ide.IdeEventQueue.access$_dispatchEvent(IdeEventQueue.kt:68)
at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:349)
at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:348)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:787)
at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:348)
at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:343)
at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:995)
at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:113)
at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:995)
at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$4(IdeEventQueue.kt:343)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:829)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:385)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)

@navaronbracke
Copy link
Collaborator

The service com.android.tools.idea.explainer.IssueExplainer seems to be IntelliJ related?

Could you run Gradle directly, through Android Studio?

@LuqmaanMohammed
Copy link

Sir could you please run the repo on your pc and check it i am will be very grateful to you please i am a beginner so am not able to understand the errors and what to do please could you check it and see

@navaronbracke navaronbracke self-assigned this Jan 2, 2024
@navaronbracke
Copy link
Collaborator

I will have a look at the Gradle error with the mobile_scanner example app.

@endruuu
Copy link

endruuu commented Jan 30, 2024

Might not be a good idea to everyone, but try to increase the minSdkVersion to 24 - that's all.
No need to change the gradle or kotlin version.

@Crucialjun
Copy link

Might not be a good idea to everyone, but try to increase the minSdkVersion to 24 - that's all. No need to change the gradle or kotlin version.

This worked for me

@ps9310
Copy link

ps9310 commented Feb 19, 2024

Might not be a good idea to everyone, but try to increase the minSdkVersion to 24 - that's all. No need to change the gradle or kotlin version.

This worked for me

me too!

@KallewMachado
Copy link

KallewMachado commented Feb 20, 2024

Pode não ser uma boa ideia para todos, mas tente aumentar minSdkVersionpara 24 – isso é tudo. Não há necessidade de alterar a versão Gradle ou Kotlin.

This worked for me too

@ziqq
Copy link

ziqq commented Feb 22, 2024

This case work for me

minSdkVersion 23
plugins {
  id "dev.flutter.flutter-plugin-loader" version "1.0.0"
  id "com.android.application" version "7.2.2" apply false
  id "org.jetbrains.kotlin.android" version "1.9.22" apply false
  id "com.google.gms.google-services" version "4.3.15" apply false
}

@saty-a
Copy link

saty-a commented Feb 22, 2024

Might not be a good idea to everyone, but try to increase the minSdkVersion to 24 - that's all. No need to change the gradle or kotlin version.

Just updating the minSdkVersion from 21 to 23 worked for me. Thanks @endruuu.

@MrCyjaneK
Copy link

@saty-a's suggestion is great but in my case it increased app size by 3x (from 90mb to 280mb) which is somewhat unacceptable, but it did compile and run without problems.

@yelyseiruban
Copy link

yelyseiruban commented Feb 24, 2024

inside android/build.gradle

buildscript {
ext.kotlin_version = '1.9.22'
repositories {
google()
mavenCentral()
}

dependencies {
    classpath 'com.android.tools.build:gradle:7.2.2'
    // START: FlutterFire Configuration
    classpath 'com.google.gms:google-services:4.3.15'
    // END: FlutterFire Configuration
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}

}

worked for me

@navaronbracke
Copy link
Collaborator

Since this issue seems to be resolved by updating the min SDK and or Kotlin version of the Android project, I'm going to close this issue.

@aymendn
Copy link

aymendn commented Mar 18, 2024

I had a similar problem with Flutter 3.19 and solved it with these versions:

  • android/build.gradle
buildscript {
    ext.kotlin_version = '1.9.0' // upgraded to kotlin 1.9
    repositories {
        google()
        mavenCentral()
        jcenter() // added this
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.2.2' // using 7.2.2
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.15'
  • 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-7.6-all.zip # <== 7.6

Don't forget to run this command after changes

cd android
./gradlew clean build --no-build-cache

@notandyvee
Copy link

In case someone else runs into this issue, don't bump the minSdk to 24. That's likely wrong. Odds are you are running into this because you create a project prior to flutter 3.16. If thats the case, you need to update your build.gradle files using the new declerative plugins {} block. This must be updated manually. The link steps you through the process for the updates. Additionally, you will need to update AGP to at least 8.0+. That part I am not too confident in, but it's what was needed for my build to pass without changing the minSdk version.

@sreeramsunkaraa
Copy link

Updating minSDK to 24 works for me but I am wondering what changed between 23 and 24 that fixes this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests