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

[bug]: App does not run after configuration using flutterfire #307

Open
1 task done
muezz opened this issue Jun 2, 2024 · 9 comments
Open
1 task done

[bug]: App does not run after configuration using flutterfire #307

muezz opened this issue Jun 2, 2024 · 9 comments
Labels
bug Something isn't working Needs Attention OP created or responded to issue and it needs attention. question Further information is requested triage

Comments

@muezz
Copy link

muezz commented Jun 2, 2024

Is there an existing issue for this?

  • I have searched the existing issues.

CLI Version

1.0.0

Firebase Tools version

13.10.2

Flutter Doctor Output

[!] Flutter (Channel stable, 3.22.0, on macOS 14.4.1 23E224 darwin-arm64, locale en-PK)
    ! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart/3.5.0-155.0.dev/libexec/bin/dart, which is not
      inside your current Flutter SDK checkout at /Users/abdulmuezz/Documents/flutter. Consider adding
      /Users/abdulmuezz/Documents/flutter/bin to the front of your path.
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.3)
[✓] VS Code (version 1.89.1)
[✓] Connected device (5 available)
[✓] Network resources

! Doctor found issues in 1 category.

Description

After configuring my app with firebase using flutterfire, I get an error in my app/build.gradle file

Steps to reproduce

  1. Run flutterfire configure --project=my-project
  2. Run flutter run
  3. See error:
FAILURE: Build failed with an exception.

* Where:
Build file '/Users/abdulmuezz/Documents/Projects/iuhabit/android/app/build.gradle' line: 4

* What went wrong:
Plugin [id: 'com.google.gms.google-services'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Included Builds (None of the included builds contain this plugin)
- Plugin Repositories (plugin dependency must include a version number for this source)

* 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 690ms
Running Gradle task 'assembleDebug'...                           1,156ms
Error: Gradle task assembleDebug failed with exit code 1

Expected behavior

The app should run fine as it does if I revert the changes made by the configure command.

Screenshots

This was added by the flutterfire extension:

image

Additional context and comments

No response

@muezz muezz added bug Something isn't working triage labels Jun 2, 2024
@muezz muezz changed the title [bug]: [bug]: App does not run after configuration using flutterfire Jun 2, 2024
@russellwheatley
Copy link
Member

Please post both build.gradle files. android/build.gradle and android/app/build.gradle. Thanks 👍

@russellwheatley russellwheatley added question Further information is requested triage and removed triage labels Jun 3, 2024
@muezz
Copy link
Author

muezz commented Jun 3, 2024

Hey @russellwheatley,
Here is my project level build.gradle:

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

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

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

This is my app level build.gradle:

plugins {
    id "com.android.application"
    // START: FlutterFire Configuration
    id 'com.google.gms.google-services'
    id 'com.google.firebase.crashlytics'
    // END: FlutterFire Configuration
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
}

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

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

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


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


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

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
        coreLibraryDesugaringEnabled true
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

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

    defaultConfig {
        applicationId "app.iuhabit"
        minSdkVersion 24
        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.
            signingConfig signingConfigs.release
            ndk {
                debugSymbolLevel 'FULL'
                abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86_64'
            }
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.2'
}

@muezz
Copy link
Author

muezz commented Jun 6, 2024

@russellwheatley Did you get a chance to take a look at this?

@russellwheatley
Copy link
Member

Hey @muezz, could you also post your settings.gradle file as well, please? I should've said that in the original post, sorry 😓

@russellwheatley russellwheatley added question Further information is requested and removed question Further information is requested labels Jun 7, 2024
@muezz
Copy link
Author

muezz commented Jun 7, 2024

@russellwheatley Here it is:

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()
        gradlePluginPortal()
    }
}

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version '7.3.0' apply false
    id "org.jetbrains.kotlin.android" version "1.7.10" apply false
}

include ":app"

@hussain-mustafa990
Copy link

hussain-mustafa990 commented Jun 23, 2024

I was also facing this issue. I fixed the issue by adding.

id "com.google.gms.google-services" version "4.4.0" apply false
id "com.google.firebase.firebase-perf" version "1.4.2" apply false
id "com.google.firebase.crashlytics" version "2.9.9" apply false

To the plugins section in my settings.gradle file.

The complete settings.gradle file is as follows:

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 '8.2.2' apply false
    id "org.jetbrains.kotlin.android" version "2.0.0" apply false
    // START: FlutterFire Configuration
    id "com.google.gms.google-services" version "4.4.0" apply false
    id "com.google.firebase.firebase-perf" version "1.4.2" apply false
    id "com.google.firebase.crashlytics" version "2.9.9" apply false
    // END: FlutterFire Configuration
}

include ":app"

Although I expected the flutterfire confiure command to do this for me.

@muezz
Copy link
Author

muezz commented Jun 23, 2024

@hussain-mustafa990 I fixed this by creating a new project and adding all of my dependencies and then running the flutterfire CLI command along with pod install.

@SelaseKay SelaseKay added the Needs Attention OP created or responded to issue and it needs attention. label Sep 19, 2024
Copy link

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

@github-actions github-actions bot added the Stale label Oct 17, 2024
@zeezooz
Copy link

zeezooz commented Oct 20, 2024

    id "com.android.application" version '7.3.0' apply false

I had the same issue. flutterfire doesn't support single quotes in version. They probably appeared after upgrading AGP in Android Studio.

@github-actions github-actions bot removed the Stale label Oct 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Needs Attention OP created or responded to issue and it needs attention. question Further information is requested triage
Projects
None yet
Development

No branches or pull requests

5 participants