Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter android app crashes upon startup if I include a certain package

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...

like image 843
t0rus Avatar asked May 21 '18 18:05

t0rus


3 Answers

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.

like image 99
Alexandre Leite Avatar answered Oct 16 '22 17:10

Alexandre Leite


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

like image 1
CheeseNPort Avatar answered Oct 16 '22 19:10

CheeseNPort


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.

like image 1
pushkardk Avatar answered Oct 16 '22 17:10

pushkardk