Reputation: 1657
I was trying to upgrade my project to some of the latest versions, I'm unable to get to null-safety since some of the dependencies in the project haven't been updated.
I've resorted to sdk version 2.10, along with that I updated all core packages with resolved all the breaking changes. Some of the deprecated changes (i.e FlatButton to TextButton, hasn't been resolved yet).
I ran into a couple problems building the solution, and after consulting some old Stack posts I've cobbled together gradle file updates, upgrade to Android Studio etc...
However, I'm receiving warnings when I build the solution as uses or overrides a deprecated API and when it installs on the virtual device it fails launch without providing an error.
I'm wondering whether my hacks on the gradle files are the cause - I wanted to get a confirmation whether these gradle updates are correct (specifically the versions that are in use).
App > Android > build.gradle
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.3'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App > Android > App > build.grade
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 29
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.<appname>.app"
minSdkVersion 23
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
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.debug
}
}
}
flutter {
source '../..'
}
apply plugin: 'com.android.application'
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-analytics:17.2.2'
}
apply plugin: 'com.google.gms.google-services'
app > android > wrapper > gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
pubspec.yaml package versions :
cloud_firestore: ^2.2.1
firebase_auth: ^1.2.0
firebase_core: ^1.2.0
firebase_analytics: ^8.1.0
cloud_functions: ^1.1.0
firebase_storage: ^8.1.0
firebase_messaging: ^10.0.0
google_sign_in: ^5.0.4
devicelocale: ^0.3.2
image_cropper: ^1.4.0
local_auth: ^1.1.6
pubspec.yaml SDK Version
environment:
sdk: ">=2.10.0 <3.0.0"
Debug console warnings/note :
Running "flutter pub get" in app... Warning: You are using these overridden dependencies: ! font_awesome_flutter 8.8.1 from path /Users/prad/Development/packages/font_awesome Launching lib/main.dart on Android SDK built for x86 in debug mode... Note: /Users/prad/.pub-cache/hosted/pub.dartlang.org/devicelocale-0.3.2/android/src/main/java/com/example/devicelocale/DevicelocalePlugin.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: /Users/prad/.pub-cache/hosted/pub.dartlang.org/firebase_core-1.2.1/android/src/main/java/io/flutter/plugins/firebase/core/FlutterFirebaseCorePlugin.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: /Users/prad/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-2.2.1/android/src/main/java/io/flutter/plugins/firebase/firestore/FlutterFirebaseFirestorePlugin.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: /Users/prad/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-2.2.1/android/src/main/java/io/flutter/plugins/firebase/firestore/streamhandler/TransactionStreamHandler.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details. Note: /Users/prad/.pub-cache/hosted/pub.dartlang.org/firebase_analytics-8.1.0/android/src/main/java/io/flutter/plugins/firebaseanalytics/FirebaseAnalyticsPlugin.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: /Users/prad/.pub-cache/hosted/pub.dartlang.org/firebase_analytics-8.1.0/android/src/main/java/io/flutter/plugins/firebaseanalytics/FirebaseAnalyticsPlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details. Note: /Users/prad/.pub-cache/hosted/pub.dartlang.org/cloud_functions-1.1.0/android/src/main/java/io/flutter/plugins/firebase/functions/FlutterFirebaseFunctionsPlugin.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: /Users/prad/.pub-cache/hosted/pub.dartlang.org/firebase_auth-1.2.0/android/src/main/java/io/flutter/plugins/firebase/auth/FlutterFirebaseAuthPlugin.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. /Users/prad/.pub-cache/hosted/pub.dartlang.org/firebase_storage-8.1.0/android/src/main/java/io/flutter/plugins/firebase/storage/FlutterFirebaseStoragePlugin.java:38: warning: [deprecation] Registrar in PluginRegistry has been deprecated public static void registerWith(PluginRegistry.Registrar registrar) { ^ 1 warning Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: /Users/prad/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-4.2.0/android/src/main/java/com/it_nomads/fluttersecurestorage/FlutterSecureStoragePlugin.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: /Users/prad/.pub-cache/hosted/pub.dartlang.org/google_sign_in-5.0.4/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: /Users/prad/.pub-cache/hosted/pub.dartlang.org/image_cropper-1.4.0/android/src/main/java/vn/hunghd/flutter/plugins/imagecropper/ImageCropperPlugin.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: /Users/prad/.pub-cache/hosted/pub.dartlang.org/local_auth-1.1.6/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. ✓ Built build/app/outputs/flutter-apk/app-debug.apk. Lost connection to device.
The Virtual Device I'm using is Pixel 3a API version 29.
Upvotes: 1
Views: 2810
Reputation: 10529
If some of the plugins you're using has yet to have support for Flutter null safety, you can add --no-sound-null-safety
argument on your build as mentioned on this guide. This argument should let you build the Flutter project even if some of the plugins used doesn't have support for null safety.
Upvotes: 0