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

Task :stripe_android:compileDebugJavaWithJavac FAILED #1513

Closed
VB10 opened this issue Nov 29, 2023 · 19 comments
Closed

Task :stripe_android:compileDebugJavaWithJavac FAILED #1513

VB10 opened this issue Nov 29, 2023 · 19 comments
Labels
needs triage Needs triage

Comments

@VB10
Copy link

VB10 commented Nov 29, 2023

Describe the bug
When i update to new version(9.6.0) our project does not compile but when i downgrade to older version it work as expected (9.5.0+1)

Additional context

Task :stripe_android:compileDebugJavaWithJavac FAILED
Execution failed for task ':stripe_android:compileDebugJavaWithJavac'.
error: invalid source release: 17

  • Flutter (Channel stable, 3.16.0, on macOS 14.1.1 23B81 darwin-arm64, locale
    en-TR)

I've looked example with this pr and try to same configuration but not working.

#1492

@VB10 VB10 added the needs triage Needs triage label Nov 29, 2023
@salmanclustox
Copy link

Any update on this i am having the same issue i am using flutter_stripe: ^9.4.0 stuck from hours now :/

@jonasbark
Copy link
Member

@ynmain
Copy link

ynmain commented Nov 29, 2023

I'm also having the same problem.
flutter_stripe: ^9.5.0+1
😢😢😢😢
by github actions

@remonh87
Copy link
Member

remonh87 commented Nov 29, 2023

You need to update android studio and update the sdk to the latest stable release (giraffe). Also upgrade to android gradle plugin 8

@salmanclustox
Copy link

Its failing on Codemagic CI as well !

@ynmain
Copy link

ynmain commented Nov 29, 2023

@remonh87

I tried tracing the PR.
It seems that CI is emitting errors from around this point.

https://github.com/flutter-stripe/flutter_stripe/pull/1479/files#diff-39ab2ed24002fb8e39b9db8ebac35907f77395dbc3c2faf95e6e6b6805e0b9ceR33

Isn't this related to this issue?

@salmanclustox
Copy link

salmanclustox commented Nov 29, 2023

I am still stuck with version flutter_stripe: ^9.5.0+1 its not working on Codemagic Ci and on my Android studio local build as well.

I have updated android studio to Giraffe too still no luck

@charlesverge
Copy link

This appears to be related to #1481
I've attempted to upgrade to gradle 8.1.3 as given in the example given in the README. This resolves the error: invalid source release: 17 but causes issues with another plugin which does not support the upgrade.

> Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl.
   > Namespace not specified. Specify a namespace in the module's build file. See https://d.android.com/r/tools/upgrade-assistant/set-namespace for information about setting the namespace.

     If you've specified the package attribute in the source AndroidManifest.xml, you can use the AGP Upgrade Assistant to migrate to the namespace value in the build file. Refer to https://d.android.com/r/tools/upgrade-assistant/agp-upgrade-assistant for general information about using the AGP Upgrade Assistant.

@remonh87
Copy link
Member

@charlesverge you need to make sure to add a namespace:

namespace 'com.flutter.stripe.example'

It can also be that some of your other plugins do not have specified a namespace

@charlesverge
Copy link

@remonh87 In my case the plugins don't have a namespace specifically https://github.com/trycourier/courier-flutter/

@remonh87
Copy link
Member

@charlesverge this is outside our library. In order to compile for latest android java 17 is required and gradle plugin 8 see https://developer.android.com/build/jdks.

@remonh87
Copy link
Member

I will update the readme file to put android gradle plugin 8 as requirement to make it clear. Closing it for now

@yosuke-nakayama
Copy link

yosuke-nakayama commented Nov 30, 2023

@charlesverge
It seems difficult to require gradle plugin 8. Many pubs are not compatible and the scope of impact is too large.

  • badges
  • app_review
    .. and more
    All of these pubs are not namespaced.

I'm sure many people are having the same problem.
#1513 (comment)

This issue should not be closed.

@remonh87
Copy link
Member

remonh87 commented Nov 30, 2023

@yosuke-nakayama Android gradle plugin 8 is required for people who want to compile on sdk 34 see: https://developer.android.com/build/releases/gradle-plugin#api-level-support . The fact that others do not update their plugins is not something we can cater for. For example app_review is not updated in 16 months

That said people can still use version 9.5.0 use dependency overrides to fix the versions for this like:

dependency_overrides:
  flutter_stripe: "9.5.1"
  stripe_android: "9.5.1"
  stripe_ios: "9.5.1"
  stripe_platform_interface:  "9.5.1"

@yosuke-nakayama
Copy link

Thank you!
I was just dealing with that.
But flutter_stripe: "9.5.1"
There is a dependency relationship even though it is fixed with
stripe_platform_interface, stripe_ios, stripe_android
This is the difficult problem of this time.

In reality, many pubs are gradleversion8.x
is not supported.

Many developers will be troubled.

I was able to use this suggestion as a temporary fix.

@charlesverge
Copy link

I agree with @remonh87 that this should be closed as it's external to stripe. API 34 based on my understanding of the google policy will be required for new apps on Aug 31 2024. This update is required.

Google play's target policy. https://support.google.com/googleplay/android-developer/answer/11917020?hl=en

New apps and app updates MUST target an Android API level within one year of the latest major Android version release. New apps and app updates that fail to meet this requirement will be prevented from app submission in Play Console.

https://support.google.com/googleplay/android-developer/answer/11926878?hl=en

As for handling upgrade errors errors I encountered in upgrade have falling into one of four categories

Outdated or miss aligned java version
I used github actions to rotate should a matrix of distributions and versions for zulu, temurin, oracle. Settled on temurin 17 for building.

  1. usually java 11 or lower zulu 11 error: invalid source release: 17
  2. zulu, temurin, oracle versions 20, 21 - ```* What went wrong:
    Could not open cp_settings generic class cache for settings file '/home/runner/work/Flutter-App/Flutter-App/android/settings.gradle' (/home/runner/.gradle/caches/8.0/scripts/9xi5mzwa1cc5h53hio032xejd).

BUG! exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 64```

Outdated gradle

  1. Minimum supported Gradle version is 8.0. Current version is 7.5. If using the gradle wrapper, try editing the distributionUrl in /home/runner/work/Flutter-App/Flutter-App/android/gradle/wrapper/gradle-wrapper.properties to gradle-8.0-all.zip
  2. Outdates gradle scripts or interference from custom modifications, I started a new flutter app and added plugins one by one and found could remove old customizations

Namespace missing errors

  1. This could be an outdated gradle issue
  2. Sometimes fixing could be done in the plugin with https://github.com/getsentry/sentry-dart/blob/main/flutter/android/build.gradle#L27

Version miss match errors with plugins

For one plugin I ended up overriding the jvmTarget, sourceCompatibility and targetCompatibility in android/build.gradle. Not recommended but a temporary fix.

allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
    afterEvaluate { project ->
        // google_api_headers is included by flutter_google_places_hoc081098
        // and is compiled with older versions of kotlin, this overrides until
        // the plugin is updated
        if (project.name == 'google_api_headers') {
            project.android {
                kotlinOptions {
                    jvmTarget = '17'
                }
                compileOptions {
                    sourceCompatibility JavaVersion.VERSION_17
                    targetCompatibility JavaVersion.VERSION_17
                }
            }
        }
        // Print kotlin and jvmtargets
        if (project.plugins.hasPlugin('kotlin-android')) {
            def kotlinVersion = project.kotlin_version ?: 'Not explicitly set'
            def jvmTarget = project.android.kotlinOptions.jvmTarget ?: 'Not explicitly set'

            println "Project: ${project.name}, Kotlin Version: $kotlinVersion, JVM Target: $jvmTarget"
        }
    }
}

Other notes
In android/app/build.gradle I've set jvmTarget to 17 and android sdk to 34 and ensured there is a namespace an not an applicationid

android {
    namespace "...."
    compileSdk 34
    ndkVersion flutter.ndkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = '17'
    }

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

    defaultConfig {
        minSdkVersion 23
        targetSdkVersion 34
        compileSdk 34
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }
}

There is other errors which can happen with Kotlin 1.5 which I did not address

Hopefully this feeds the AI machine and saves some folks some time

@Rushi-Gandhi
Copy link

I've successfully resolved the "Task :stripe_android:compileDebugJavaWithJavac FAILED" error by adding the following dependency override in my project:

dependency_overrides:
  stripe_android: "9.5.0+1"

This adjustment worked for me. Feel free to give it a try and let me know if it resolves the issue on your end as well.

@mrruby
Copy link

mrruby commented Dec 7, 2023

I've successfully resolved the "Task :stripe_android:compileDebugJavaWithJavac FAILED" error by adding the following dependency override in my project:

dependency_overrides:
  stripe_android: "9.5.0+1"

This adjustment worked for me. Feel free to give it a try and let me know if it resolves the issue on your end as well.

Thank you, its working!

@dickermoshe
Copy link

@remonh87

The fact that others do not update their plugins is not something we can cater for.

Perfection is the enemy of good.
Google may have recommendations, but most current apps will never be able to update past 9.5.X.

@flutter-stripe flutter-stripe locked as resolved and limited conversation to collaborators Dec 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs triage Needs triage
Projects
None yet
Development

No branches or pull requests

10 participants