3

I have a project with Flutter 3.10.3, and when trying to migrate to the latest version, 3.22, I was able to run everything correctly on iOS, but for Android, it shows an error. I followed the Gradle migration according to the documentation --> https://docs.flutter.dev/release/breaking-changes/flutter-gradle-plugin-apply

However, it is showing the following error:

Plugin project :file_selector_linux listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :file_selector_macos listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :file_selector_windows listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :firebase_core_web listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :geocoding listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :geocoding_ios listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :geolocator listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :geolocator_apple listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :geolocator_web listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :geolocator_windows listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :image_cropper_for_web listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :image_picker listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :image_picker_for_web listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :image_picker_ios listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :image_picker_linux listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :image_picker_macos listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :image_picker_windows listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :path_provider_linux listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :path_provider_windows listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :shared_preferences listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :shared_preferences_foundation listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :shared_preferences_linux listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :shared_preferences_web listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :shared_preferences_windows listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :url_launcher listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :url_launcher_ios listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :url_launcher_linux listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :url_launcher_macos listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :url_launcher_web listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :url_launcher_windows listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :video_player listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :video_player_avfoundation listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :video_player_web listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :webview_flutter listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
Plugin project :webview_flutter_wkwebview listed, but not found. Please fix your settings.gradle/settings.gradle.kts.
../../../.pub-cache/hosted/pub.dev/oktoast-3.3.1/lib/src/widget/oktoast.dart:101:26: Error: The getter 'bodyText2' isn't defined for the class 'TextTheme'.
 - 'TextTheme' is from 'package:flutter/src/material/text_theme.dart' ('../../../development/flutter/packages/flutter/lib/src/material/text_theme.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'bodyText2'.
        defaultTextTheme.bodyText2?.copyWith(
                         ^^^^^^^^^
../../../.pub-cache/hosted/pub.dev/get-4.6.5/lib/get_navigation/src/extension_navigation.dart:222:62: Error: The getter 'backgroundColor' isn't defined for the class 'ThemeData'.
 - 'ThemeData' is from 'package:flutter/src/material/theme_data.dart' ('../../../development/flutter/packages/flutter/lib/src/material/theme_data.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'backgroundColor'.
                  TextStyle(color: confirmTextColor ?? theme.backgroundColor),
                                                             ^^^^^^^^^^^^^^^
Target kernel_snapshot failed: Exception


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '/Users/cristianobonetti/development/flutter/bin/flutter'' finished with non-zero exit value 1

* 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 7s

As mentioned above, I used the documentation from https://docs.flutter.dev/release/breaking-changes/flutter-gradle-plugin-apply as a reference. However, I don't know what I'm doing wrong. Here is the code from my

android/settings.gradle:

// include ':app'

// def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
// def properties = new Properties()

// assert localPropertiesFile.exists()
// localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }

// def flutterSdkPath = properties.getProperty("flutter.sdk")
// assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
// apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"

// def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()

// def plugins = new Properties()
// def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
// if (pluginsFile.exists()) {
//     pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
// }

// plugins.each { name, path ->
//     def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
//     include ":$name"
//     project(":$name").projectDir = pluginDirectory
// }

pluginManagement {
    def flutterSdkPath = {
        def properties = new Properties()
        file("local.properties").withInputStream { properties.load(it) }
        def flutterSdkPath = properties.getProperty("flutter.sdk")
        assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
        return flutterSdkPath
    }()

    includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version "7.4.2" apply false
    id "org.jetbrains.kotlin.android" version "1.8.10" apply false
    id "com.google.gms.google-services" version "4.4.0" apply false
    id "com.google.firebase.crashlytics" version "2.9.9" apply false
}

include ":app"

Also, here is my android/build.gradle:

// buildscript {
//     ext.kotlin_version = '1.8.10'
//     repositories {
//         google()
//         jcenter()
//     }

//     dependencies {
//         classpath 'com.android.tools.build:gradle:7.4.2'
//         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10"
//         classpath 'com.google.gms:google-services:4.3.15'
//         classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.5'
        
//     }
// }

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

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

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

And my android/app/build.gradle:

// buildscript {
//     repositories {
//         maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
//     }
//     dependencies {
//         classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.10, 0.99.99]'
//     }
// }

plugins {
    id "com.android.application"
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
    id "com.google.gms.google-services"
    id "com.google.firebase.crashlytics"
}

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  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 = '10'
}

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

// apply plugin: 'com.android.application'
// apply plugin: 'kotlin-android'
// apply plugin: 'com.google.gms.google-services'
// apply plugin: 'com.google.firebase.crashlytics'

// apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

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

android {
    namespace "app.myapp.client"
    compileSdkVersion 34
    ndkVersion "23.0.7599858"

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

    lintOptions {
        disable 'InvalidPackage'
        checkReleaseBuilds false
    }

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

    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.
            profile {
                matchingFallbacks = ['debug', 'release']
            }
            minifyEnabled true
            shrinkResources false

            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            
            signingConfig signingConfigs.release
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    // implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.10"
    implementation platform('com.google.firebase:firebase-bom:32.1.0')
    implementation 'com.google.firebase:firebase-analytics-ktx'
    implementation 'com.google.firebase:firebase-messaging-ktx'
    implementation 'com.google.firebase:firebase-dynamic-links'
    implementation 'com.google.android.gms:play-services-base:18.2.0'
}




5
  • You changed the versions of crashlytics and google-services. What happens when you use those versions? Commented May 20, 2024 at 6:00
  • I did not change the versions, I am using these: firebase_core: ^2.3.0 firebase_crashlytics: ^3.0.6 Commented May 20, 2024 at 12:03
  • You did. In the commented code you have: classpath 'com.google.gms:google-services:4.3.15' // classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.5' Commented May 20, 2024 at 12:07
  • Yes, but according to the documentation docs.flutter.dev/release/breaking-changes/… this code was supposed to be removed Commented May 20, 2024 at 13:16
  • 1
    any correct answers? I don't wanna try everything and mess things out, please help Commented Jun 16, 2024 at 9:59

3 Answers 3

4

Try breaking the string .flutter-plugins in settings.gradle.

...Flutter will detect that, even if it's been commented out: https://github.com/flutter/flutter/blob/557a959547258f6edb912fae552d606c93ac8052/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy#L682-L684

Sign up to request clarification or add additional context in comments.

2 Comments

Yes, the problem is that it is detected even if it has been commented on!
Yes. To get around this, you should not include any '.flutter-plugins' string in your settings.gradle file even in comment block. I've posted a related issue on github.com/flutter/flutter/issues/155484
0

Try to open Android project in Android Studio. Go to:

settings.gradle and change com.android.application version to 8.4.0

plugins {
    ....
    id "com.android.application" version "8.4.0" apply false
    ...
}

Do a sync.

Go to gradle-wrapper.properties

change with gradle-8.6-bin.zip:

distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip

Do a sync. It will be built successfully.

Comments

0

The latest flutter now uses the material3 theme which has now different getters/setters to define the typography.

Here are the details of new attributes to use for typography. If you're upgrading your Flutter version then you also need to make changed in your theme to fix the errors.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.