1

I have a flutter app created with flutter version 2.2 and I'm trying to build it for android 13 (targetSdkVersion 33) and I get one of two build errors:

First (when gradle version is below 7):

Could not open proj generic class cache for build file 'path/to/app/android/app/build.gradle' (/Users/user/.gradle/caches/6.5/scripts/5d4nrc28gkbak7ua19lfgqqhx/proj9e897448d2c85f064c8b54ac35428928). BUG! exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 62

Second (when gradle version is above 7):

In plugin 'com.android.build.gradle.api.AndroidBasePlugin' type 'com.android.build.gradle.tasks.RenderscriptCompile' method 'useAndroidX()' should not be annotated with: @Input. Reason: Input/Output annotations are ignored if they are placed on something else than a getter.

the only thing I changed in my app to produce this error is in the build.gradle file in complileSdkVersion and targetSdkVersion and I changed it from 30 to 33:

android {
    compileSdkVersion 33

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

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        applicationId "com.name.app"
        minSdkVersion 23
        targetSdkVersion 33
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }
}

I've tried different versions of java and grade in all sorts of combinations and I keep getting one of those errors. It builds fine if the targetSdkVersion is 30. Could this be because of an old version of flutter?

  • It is recommended to upgrade your flutter and migrate your project to a newer project. Se this for more help in upgrading to newer version. https://stackoverflow.com/a/68334274/15119028 – Junaid Khalid Apr 01 '23 at 06:38

1 Answers1

1

I ran into similar issues after setting up a new Mac with JDK19.

I was able to solve this issue by upgrading the version of gradle in project_root/android/gradle/gradle-wrapper.properties to gradle-7.6-all.

Just exchange the line with distributionUrl like this:

distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip

After this change I was able to build the app with a newer JDK. Not sure about Flutter 2.2 since I am using 3.7 at the moment.

Tim Brückner
  • 1,928
  • 2
  • 16
  • 27