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 failure with latest version of flutter #91

Closed
wutsi opened this issue Oct 6, 2022 · 12 comments
Closed

build failure with latest version of flutter #91

wutsi opened this issue Oct 6, 2022 · 12 comments
Assignees
Labels
bug Something isn't working

Comments

@wutsi
Copy link

wutsi commented Oct 6, 2022

I've just upgraded flutter, and I received the following error

The Android Gradle plugin supports only Kotlin Gradle plugin version 1.5.20 and higher.
The following dependencies do not satisfy the required version:
project ':search_choices' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50

Can you update the kotlin plugin version from 1.3.50 to 1.5.20?
Thanks

@lcuis
Copy link
Owner

lcuis commented Oct 6, 2022

Hello @wutsi , thanks a lot for letting me know.

I will reproduce the issue, update the code for correction, run the automated testing and publish the changes as soon as possible.

@lcuis lcuis self-assigned this Oct 6, 2022
@lcuis lcuis added the bug Something isn't working label Oct 6, 2022
@lcuis
Copy link
Owner

lcuis commented Oct 6, 2022

Hi again @wutsi ,

I was not able to reproduce this issue yet with the latest version of Flutter.

Here is the output of flutter doctor -v:

[✓] Flutter (Channel stable, 3.3.4, on Ubuntu 22.04.1 LTS 5.15.0-47-generic, locale en_US.UTF-8)
    • Flutter version 3.3.4 on channel stable at /X/flutter/common/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision eb6d86ee27 (2 days ago), 2022-10-04 22:31:45 -0700
    • Engine revision c08d7d5efc
    • Dart version 2.18.2
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /X/Android/Sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /X/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
    • cmake version 3.10.2
    • ninja version 1.8.2
    • pkg-config version 0.29.1

[✓] Android Studio (version 2021.2)
    • Android Studio at /X/android-studio
    • Flutter plugin version 69.0.2
    • Dart plugin version 212.5744
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] VS Code
    • VS Code at /snap/code/current
    • Flutter extension version 3.44.0

[✓] Connected device (3 available)
    • SM A037F (mobile) • R9ZRC075ZAN • android-arm64  • Android 12 (API 31)
    • Linux (desktop)   • linux       • linux-x64      • Ubuntu 22.04.1 LTS 5.15.0-47-generic
    • Chrome (web)      • chrome      • web-javascript • Google Chrome 105.0.5195.125

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

I updated the kotlin version numbers anyway from 1.3.50 to 1.7.20 with version 2.1.4 of the search_choices plugin. Waiting for the Flutster automated testing to complete successfully before publishing to pub.dev .

@lcuis
Copy link
Owner

lcuis commented Oct 7, 2022

Release 2.1.14 of search_choices was successfully automatically tested with this video and thus released to pub.dev . Thanks @wutsi for bringing this issue to my attention!
You can close this issue if you consider everything is fine. Otherwise, I will probably close it myself in a few days.

@wutsi
Copy link
Author

wutsi commented Oct 7, 2022

I start having this issue since I've added flutter_chat_ui into my project. Let me check and re-confirm

@wutsi
Copy link
Author

wutsi commented Oct 7, 2022

confirmed - everything is fined
Thanks

@wutsi wutsi closed this as completed Oct 7, 2022
@lcuis
Copy link
Owner

lcuis commented Oct 7, 2022

Thank you very much @wutsi for the explanation and confirmation!

@samumzizi
Copy link

I'm having issues building for Android as well after upgrading to the latest flutter stable AND search_choices: ^2.1.4
My flutter doctor output:
[[✓] Flutter (Channel stable, 3.3.4, on macOS 12.6 21G115 darwin-arm, locale en-US)
• Flutter version 3.3.4 on channel stable at /Users/Developer/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision eb6d86ee27 (4 days ago), 2022-10-04 22:31:45 -0700
• Engine revision c08d7d5efc
• Dart version 2.18.2
• DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/Library/Android/sdk
• Platform android-33, build-tools 31.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.0)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14A309
• CocoaPods version 1.11.3

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
• Android Studio at /Applications/Android Studio.app/Contents
• 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 11.0.12+0-b1504.28-7817840)

[✓] VS Code (version 1.72.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.50.0

[✓] Connected device (3 available)
• sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 12 (API 32) (emulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 12.6 21G115 darwin-arm
• Chrome (web) • chrome • web-javascript • Google Chrome 105.0.5195.125

[✓] HTTP Host Availability
• All required HTTP hosts are available

• No issues found!
]

My android/build.gradle is:
`buildscript {
ext.kotlin_version = '1.6.20'
repositories {
google()
jcenter()
}

dependencies {
    classpath 'com.android.tools.build:gradle:4.1.3'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'com.google.gms:google-services:4.3.5'
}

}

allprojects {
repositories {
google()
jcenter()
}
}

rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
delete rootProject.buildDir
}`

and my android/app/build.gradle is:

`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 GradleException("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'
}

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

android {

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

compileSdkVersion 33

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

lintOptions {
    disable 'InvalidPackage'
}

defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "redacted.coolapp"
    minSdkVersion 26
    targetSdkVersion 33
    multiDexEnabled true
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
}

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

buildTypes {
    release {
        // TODO: Add your own signing config for the release build.
        // Signing with the debug keys for now, so ``flutter` run --release` works.
        signingConfig signingConfigs.release
    }
}

}

flutter {
source '../..'
}

apply plugin: 'com.google.gms.google-services'
dependencies {
implementation platform('com.google.firebase:firebase-bom:26.8.0')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-analytics'
}`

And the error when building is:
`💪 Building with sound null safety 💪

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring project ':search_choices'.

Could not resolve all artifacts for configuration ':search_choices:classpath'.
Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20.
Required by:
project :search_choices
> The consumer was configured to find a runtime of a component compatible with Java 11, packaged as a jar, and its dependencies declared externally. However we cannot choose between the following variants of org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20:
- gradle70JavadocElements
- gradle70RuntimeElements
- gradle70SourcesElements
- gradle71JavadocElements
- gradle71RuntimeElements
- gradle71SourcesElements
- javadocElements
- runtimeElementsWithFixedAttribute
- sourcesElements
All of them match the consumer attributes:
- Variant 'gradle70JavadocElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20 declares a runtime of a component, and its dependencies declared externally:
- Unmatched attributes:
- Provides documentation but the consumer didn't ask for it
- Provides javadocs but the consumer didn't ask for it
- Doesn't say anything about its target Java version (required compatibility with Java 11)
- Doesn't say anything about its elements (required them packaged as a jar)
- Provides attribute 'org.gradle.plugin.api-version' with value '7.0' but the consumer didn't ask for it
- Provides release status but the consumer didn't ask for it
- Variant 'gradle70RuntimeElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20 declares a runtime of a component compatible with Java 8, packaged as a jar, and its dependencies declared externally:
- Unmatched attributes:
- Provides a library but the consumer didn't ask for it
- Provides attribute 'org.gradle.jvm.environment' with value 'standard-jvm' but the consumer didn't ask for it
- Provides attribute 'org.gradle.plugin.api-version' with value '7.0' but the consumer didn't ask for it
- Provides release status but the consumer didn't ask for it
- Variant 'gradle70SourcesElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20 declares a runtime of a component, and its dependencies declared externally:
- Unmatched attributes:
- Provides documentation but the consumer didn't ask for it
- Provides sources but the consumer didn't ask for it
- Doesn't say anything about its target Java version (required compatibility with Java 11)
- Doesn't say anything about its elements (required them packaged as a jar)
- Provides attribute 'org.gradle.plugin.api-version' with value '7.0' but the consumer didn't ask for it
- Provides release status but the consumer didn't ask for it
- Variant 'gradle71JavadocElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20 declares a runtime of a component, and its dependencies declared externally:
- Unmatched attributes:
- Provides documentation but the consumer didn't ask for it
- Provides javadocs but the consumer didn't ask for it
- Doesn't say anything about its target Java version (required compatibility with Java 11)
- Doesn't say anything about its elements (required them packaged as a jar)
- Provides attribute 'org.gradle.plugin.api-version' with value '7.1' but the consumer didn't ask for it
- Provides release status but the consumer didn't ask for it
- Variant 'gradle71RuntimeElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20 declares a runtime of a component compatible with Java 8, packaged as a jar, and its dependencies declared externally:
- Unmatched attributes:
- Provides a library but the consumer didn't ask for it
- Provides attribute 'org.gradle.jvm.environment' with value 'standard-jvm' but the consumer didn't ask for it
- Provides attribute 'org.gradle.plugin.api-version' with value '7.1' but the consumer didn't ask for it
- Provides release status but the consumer didn't ask for it
- Variant 'gradle71SourcesElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20 declares a runtime of a component, and its dependencies declared externally:
- Unmatched attributes:
- Provides documentation but the consumer didn't ask for it
- Provides sources but the consumer didn't ask for it
- Doesn't say anything about its target Java version (required compatibility with Java 11)
- Doesn't say anything about its elements (required them packaged as a jar)
- Provides attribute 'org.gradle.plugin.api-version' with value '7.1' but the consumer didn't ask for it
- Provides release status but the consumer didn't ask for it
- Variant 'javadocElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20 declares a runtime of a component, and its dependencies declared externally:
- Unmatched attributes:
- Provides documentation but the consumer didn't ask for it
- Provides javadocs but the consumer didn't ask for it
- Doesn't say anything about its target Java version (required compatibility with Java 11)
- Doesn't say anything about its elements (required them packaged as a jar)
- Provides release status but the consumer didn't ask for it
- Variant 'runtimeElementsWithFixedAttribute' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20 declares a runtime of a component compatible with Java 8, packaged as a jar, and its dependencies declared externally:
- Unmatched attributes:
- Provides a library but the consumer didn't ask for it
- Provides attribute 'org.gradle.jvm.environment' with value 'standard-jvm' but the consumer didn't ask for it
- Provides release status but the consumer didn't ask for it
- Variant 'sourcesElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20 declares a runtime of a component, and its dependencies declared externally:
- Unmatched attributes:
- Provides documentation but the consumer didn't ask for it
- Provides sources but the consumer didn't ask for it
- Doesn't say anything about its target Java version (required compatibility with Java 11)
- Doesn't say anything about its elements (required them packaged as a jar)
- Provides release status but the consumer didn't ask for it
The following variants were also considered but didn't match the requested attributes:
- Variant 'apiElementsWithFixedAttribute' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20 declares a component compatible with Java 8, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares an API of a component and the consumer needed a runtime of a component
- Variant 'gradle70ApiElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20 declares a component compatible with Java 8, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares an API of a component and the consumer needed a runtime of a component
- Variant 'gradle71ApiElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20 declares a component compatible with Java 8, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares an API of a component and the consumer needed a runtime of a component
Failed to notify project evaluation listener.
Could not get unknown property 'android' for project ':search_choices' of type org.gradle.api.Project.
Could not get unknown property 'android' for project ':search_choices' 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 1s
Running Gradle task 'bundleRelease'... 2,600ms
Gradle task bundleRelease failed with exit code 1
`

@lcuis
Copy link
Owner

lcuis commented Oct 9, 2022

Hello @samumzizi ,

Thanks for reaching out on this.

I would try to follow the recommendation on this StackOverflow answer.
Try replacing Jcenter() by mavenCentral() in the android/build.gradle.

I hope this will solve your issue.

@samumzizi
Copy link

samumzizi commented Oct 9, 2022

Hi @lcuis,
I tried the solution on stack overflow and I still have the same problem.

my android/build.gradle now looks like this per the stack overflow solution:

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

dependencies {
    classpath 'com.android.tools.build:gradle:4.1.3'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'com.google.gms:google-services:4.3.5'
}

}

allprojects {
repositories {
google()
mavenCentral()
}
}

rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
delete rootProject.buildDir
}

and the last part of the error I get still looks like this:
`> Failed to notify project evaluation listener.

Could not get unknown property 'android' for project ':search_choices' of type org.gradle.api.Project.
Could not get unknown property 'android' for project ':search_choices' of type org.gradle.api.Project.
`

@lcuis
Copy link
Owner

lcuis commented Oct 9, 2022

Hi @samumzizi ,

Sorry for the inconvenience.

Maybe this StackoverFlow answer would be a better solution then?

In your android/build.gradle, try replacing the gradle dependency classpath by this:

classpath 'com.android.tools.build:gradle:7.0.0'

In your android/gradle/wrapper/gradle-wrapper.properties, try replacing the distribution url as follows:

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

@samumzizi
Copy link

Hi @samumzizi ,

Sorry for the inconvenience.

Maybe this StackoverFlow answer would be a better solution then?

In your android/build.gradle, try replacing the gradle dependency classpath by this:

classpath 'com.android.tools.build:gradle:7.0.0'

In your android/gradle/wrapper/gradle-wrapper.properties, try replacing the distribution url as follows:

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

Thanks for your help. I tried that and it still didn't work in the sense that it gave me more errors. So I researched the new errors and found the new solution here: flutter/flutter#73852 (comment).

@lcuis
Copy link
Owner

lcuis commented Oct 10, 2022

Great if it worked at the end. Thanks for letting me know @samumzizi !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants