Sunday, April 7, 2019

flutter Android dependency 'androidx.core:core' has different version for the compile (1.0.0) and runtime (1.0.1) classpath

In the android/build.gradle file set the gradle version to 3.3.2 as follows:

dependencies {
    classpath 'com.android.tools.build:gradle:3.3.2'
}


Reference: https://github.com/flutter/flutter/issues/27254

flutter "detected problems with api compatibility"

In the android/app/build.gradle file change the targetSdkVersion from 27 to 28.

Reference: https://stackoverflow.com/questions/49957255/espresso-test-on-android-p-preview-detected-problems-with-api-compatibility-err

Friday, April 5, 2019

flutter "unable to start activity" "ensureInitializationComplete must be called after startInitialization"

Flutter app fails to launch with the following error:


 Caused by: java.lang.IllegalStateException: ensureInitializationComplete must be called after startInitialization  
     at io.flutter.view.FlutterMain.ensureInitializationComplete(FlutterMain.java:190)  
     at io.flutter.app.FlutterActivityDelegate.onCreate(FlutterActivityDelegate.java:156)  
     at io.flutter.app.FlutterActivity.onCreate(FlutterActivity.java:89)  
     at net.pawpalflutter.MainActivity.onCreate(MainActivity.java:10)  
     at android.app.Activity.performCreate(Activity.java:6672)  
     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1140)  
     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2612)  
     ... 9 more  


This error occurred when loading app from Android Studio to a mobile phone. It seems the transfer of the app may have been interrupted abruptly and didn't close properly, causing all subsequent transfers to fail.

The Solution

Power off and on the phone

Reference: https://github.com/flutter/flutter/issues/14513