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

Deprecated imperative apply of Flutter's Gradle plugins #378

Open
adrianvintu opened this issue Jun 12, 2024 · 1 comment
Open

Deprecated imperative apply of Flutter's Gradle plugins #378

adrianvintu opened this issue Jun 12, 2024 · 1 comment

Comments

@adrianvintu
Copy link

adrianvintu commented Jun 12, 2024

Gradle has deprecated the apply plugin method.

The transitions is done here: Deprecated imperative apply of Flutter's Gradle plugins https://docs.flutter.dev/release/breaking-changes/flutter-gradle-plugin-apply

For Huawei, the settings.gradle looks like below. Notice the useModule("com.huawei.agconnect:agcp:1.9.1.303")

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
    }
    settings.ext.flutterSdkPath = flutterSdkPath()

    includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")

    repositories {
        google()
        mavenCentral()
        maven { url 'https://developer.huawei.com/repo/' }
        gradlePluginPortal()
    }

    resolutionStrategy {
        eachPlugin {
            if (requested.id.id == "com.huawei.agconnect") {
                //https://flutter.dev/go/flutter-gradle-plugin-apply
                //https://forums.developer.huawei.com/forumPortal/en/topic/0201148914110187023
                //https://stackoverflow.com/questions/78339717/huawei-agcp-plugin-cannot-be-applied
                useModule("com.huawei.agconnect:agcp:1.9.1.303")
            }
        }
    }
}

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version "8.1.1" apply false
    id "org.jetbrains.kotlin.android" version "1.9.0" 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
    id 'com.google.firebase.firebase-perf' version '1.4.2' apply false
    id "com.huawei.agconnect" version "1.9.1.303" apply false
}

include ":app"

App\build.gradle looks like

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"
    id "com.huawei.agconnect"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}
...

It would be great if Huawei would document this.

Related #341

@sswedan
Copy link

sswedan commented Nov 26, 2024

I tried this but I'm getting the following error:

An exception occurred applying plugin request [id: 'com.huawei.agconnect', artifact: 'com.huawei.agconnect:agcp:1.9.1.303']
> Failed to apply plugin 'com.huawei.agconnect'.
   > com.android.tools.build:gradle is no set in the build.gradle file

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

2 participants