i'm new to flutter and wants to integrate my app with firebase. I copy the code from this site (https://www.developerlibs.com/2018/11/flutter-firebase-realtime-database-crud.html). And here is my code's link, link of Git. https://github.com/hannan228/flutter-with-firebase.git
pubspec.yaml code is here pubspec.yaml code name: databaseinflutter description: A new Flutter application.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3
firebase_database: ^1.0.5
http: "^0.11.3+17"
firebase_auth: 0.16.1
#firebase_auth: 0.6.2+1
google_sign_in: ^3.2.1
fluttertoast: ^2.0.7
flutter_svg: ^0.6.1+1
dev_dependencies:
flutter_test:
sdk: flutter
# The following section is specific to Flutter.
flutter:
uses-material-design: true
app/build.gradle is same as
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.google.gms.google-services'
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.yovin.databaseinflutter"
minSdkVersion 23
targetSdkVersion 28
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 '../..'
}
dependencies {
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.android.support:multidex:1.0.3' //for multidex
implementation 'com.google.firebase:firebase-analytics:17.4.3'
implementation 'com.google.firebase:firebase-auth:19.3.1'
implementation 'com.google.firebase:firebase-firestore:21.4.3'
}
android/build.gradle is as
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
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
}
apply plugin: 'com.google.gms.google-services'
here is GeneratedPluginRegistrant.java file
here is screenshot of some error
Following is complete errors that are showing in Console
Running Gradle task 'assembleDebug'... C:\flutter\flutter_windows_1.17.4-stable\flutter.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.6.2+1\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:8: error: package android.support.annotation does not exist import android.support.annotation.NonNull; ^ C:\flutter\flutter_windows_1.17.4-stable\flutter.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.6.2+1\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:538: error: cannot find symbol public void onComplete(@NonNull Task task) { ^ symbol: class NonNull location: class FirebaseAuthPlugin.SignInCompleteListener C:\flutter\flutter_windows_1.17.4-stable\flutter.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.6.2+1\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:558: error: cannot find symbol public void onComplete(@NonNull Task task) { ^ symbol: class NonNull location: class FirebaseAuthPlugin.TaskVoidCompleteListener C:\flutter\flutter_windows_1.17.4-stable\flutter.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.6.2+1\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:576: error: cannot find symbol public void onComplete(@NonNull Task task) { ^ symbol: class NonNull location: class FirebaseAuthPlugin.ProvidersCompleteListener C:\flutter\flutter_windows_1.17.4-stable\flutter.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.6.2+1\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:175: error: cannot find symbol public void onComplete(@NonNull Task task) { ^ symbol: class NonNull C:\flutter\flutter_windows_1.17.4-stable\flutter.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.6.2+1\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:270: error: cannot find symbol public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { ^ symbol: class NonNull C:\flutter\flutter_windows_1.17.4-stable\flutter.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.6.2+1\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:435: error: cannot find symbol public void onComplete(@NonNull Task task) { ^ symbol: class NonNull C:\flutter\flutter_windows_1.17.4-stable\flutter.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.6.2+1\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:487: error: cannot find symbol public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { ^ symbol: class NonNull Note: C:\flutter\flutter_windows_1.17.4-stable\flutter.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.6.2+1\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. 8 errors
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':firebase_auth:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
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 1m 14s The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility. Building plugin firebase_auth... Running Gradle task 'assembleAarRelease'... √ Built build\app\outputs\repo. Building plugin firebase_core... Running Gradle task 'assembleAarRelease'... √ Built build\app\outputs\repo. Building plugin firebase_database... Running Gradle task 'assembleAarRelease'... √ Built build\app\outputs\repo. Building plugin fluttertoast... Running Gradle task 'assembleAarRelease'... √ Built build\app\outputs\repo. Building plugin google_sign_in... Running Gradle task 'assembleAarRelease'... √ Built build\app\outputs\repo. Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':app:checkDebugDuplicateClasses'.
1 exception was raised by workers: java.lang.RuntimeException: Duplicate class com.google.android.gms.internal.measurement.zzu found in modules jetified-firebase-analytics-impl-16.2.2-runtime.jar (com.google.firebase:firebase-analytics-impl:16.2.2) and jetified-play-services-measurement-base-17.4.3-runtime.jar (com.google.android.gms:play-services-measurement-base:17.4.3)
BUILD FAILED in 3m 49s Exception: Gradle task assembleDebug failed with exit code 1