5

A problem has suddenly recently arisen such that simply by including the dependency in 'location' in pubspec.yaml like e.g.

dependencies:
  flutter:
    sdk: flutter

  location: ^1.2.0  <------------------------ culprit
  firebase_auth: ^0.5.10  
  cloud_firestore: ^0.7.2   

the app crashes immediately upon startup.

The 'location' package itself works when alone in an example app. I am not currently importing i.e. using any of the functionality contained within the location package, yet when I remove the entry, all is well.

No clues from watching flutter log unfortunately...

t0rus
  • 197
  • 1
  • 3
  • 9

5 Answers5

7

I was facing the same issue. What I did was insert the line multiDexEnabled true in my build.gradle of app. Like this:

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        multiDexEnabled true //Insert this line
    }

Try this and run the commands flutter clean, flutter build apk and flutter run. It must solve your problem.

Alexandre Leite
  • 1,353
  • 1
  • 9
  • 10
  • 1
    Thank you so much.. I got the same kind of problem. with "shared_preferences" package.. and your solution was a life saver – Divakar Rajesh Dec 31 '18 at 13:49
  • 1
    Official docs ask us to also change manifest with `android:name="android.support.multidex.MultiDexApplication" >`, however that causes my application to crash on start. Simply changing the flag like in this answer is all that's needed to fix it. – DjH Jul 19 '19 at 18:38
1

I have a similar issue, for me its a different package though.

stripe_payment: "^0.0.6"

I can't see anything in the logs which are as follows:

Using hardware rendering with device Android SDK built for x86. If you get graphics artifacts, consider enabling software rendering with "--enable-software-rendering".

Launching lib/main.dart on Android SDK built for x86 in debug mode... Initializing gradle... 3.2s Resolving dependencies... 17.4s Running 'gradlew assembleDebug'... 48.1s Built build\app\outputs\apk\debug\app-debug.apk. Installing build\app\outputs\apk\app.apk... 2.4s

  • I am facing the same when I add firebase_auth library. It works fin when it's in other project but not in this one. – goops17 Jul 27 '18 at 20:17
  • i have the same problem when i added firebase crashlytics library – alireza easazade Dec 25 '19 at 06:17
  • @A.easazadeh make sure that you include the "fabric.io" maven and plugin repository in your android's Gradle settings as mentioned in the plugin page. Otherwise, your app stops immediately after starting. – Sasan Rose Jul 10 '20 at 07:20
1

I had the same issue with physical android device as well as the emulator. I am not entirely sure how I resolved this but here are the steps:

  • Use a lower version of the same package (cached_network_image in my case) in pubspec.yaml.
  • If app still crashes, run flutter upgrade and flutter packages get again.
  • Completely stop and restart your app (No reloading). It must not crash now.

Point to note is that my app didn't crash even after changing the package version back to the latest in the pubspec.yaml after performing the above 3 steps.

pushkardk
  • 43
  • 1
  • 4
1

no need to change anything, a simple flutter build apk will solve the problem (if all the packages in pubspec.yaml are updated and error free)

this happens quite often when switching to a branch that has a completely different list of packages, flutter needs to build...

Edoardo
  • 4,485
  • 1
  • 27
  • 31
0

I had similar issues, and after spending a few good hours on it, to find out the problem is Kotlin, that I created the project without Kotlin and Swift support. The Dart part of the code works fine, but the Android app would crash on launch with Kotlin code but works fine with Java.

To create Flutter project with Kotlin/Swift support from command:

flutter create --org co.uk.sample -i swift -a kotlin --description 'Your Project Description' sample_app

Where --org defines the project path, -i enables Swift, -a enables Kotlin, followed by your app name at the end.

Teresa
  • 373
  • 2
  • 8