wu9007 / qrcode_scanner

🛠 Flutter QR code scanner plugin.
MIT License
357 stars 186 forks source link

Conflict with Firebase #20

Open flavio-amadio opened 5 years ago

flavio-amadio commented 5 years ago

Good afternoon

I installed firebase and QR_scan and by themselves they work very well, however when I put in the same application I get the error "Finished with error: Gradle task assembleDebug failed with exit code 1"

I already restarted the IDE and used Flutter Clean but the error persists can you help me?

Follow the data

PUBSPEC dependencies: flutter: sdk: flutter cupertino_icons: ^0.1.2 cloud_firestore: ^0.12.5 qrscan: ^0.2.17

ANDROID/build.gradle

buildscript { ext.kotlin_version = '1.3.41' repositories { google() jcenter() }

dependencies {
    classpath 'com.android.tools.build:gradle:3.5.1'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'com.google.gms:google-services:4.3.2'
}

}

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 }

ANDROID/APP/build.gradle 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 28

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.example.flutter_app_firebase"
    minSdkVersion 16  //23
    targetSdkVersion 28
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
}

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 { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'com.google.firebase:firebase-analytics:17.2.0'

testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

}

apply plugin: 'com.google.gms.google-services'

gradle.properties

org.gradle.jvmargs=-Xmx1536M

gradle-wrapper.properties

Fri Jun 23 08:50:38 CEST 2017

distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

APLICATION DART

import 'package:flutter/material.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'dart:async'; import 'package:qrscan/qrscan.dart' as scanner;

class Page_qrscan extends StatefulWidget { @override _Page_qrscanState createState() => _Page_qrscanState(); }

class _Page_qrscanState extends State { String barcode = 'empty';

@override initState() { super.initState(); }

@override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: Text('Qrcode Scanner Example'), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.center, children: [ SizedBox( width: 200, //300 height: 200, //300 child: Text('aqui tinha uma imagem'), // Image.memory(bytes), ), Text('RESULT $barcode'), RaisedButton(onPressed: _scan, child: Text("Scan")), ], ), ), ), ); }

Future _scan() async { String barcode = await scanner.scan(); setState(() => this.barcode = barcode); _salva_firestore; } void _salva_firestore() async { var myDatabase = Firestore.instance;

myDatabase.collection('base_qrcode').add({
  'qr_datacaptura': DateTime.now(),
  'qr_deviceid': 'deviceid',
  'qr_idusuario': 'userid',
  'qr_textoqr': barcode
});
print('item recorded');

} }

RobertoLayna commented 4 years ago

maybe this can help https://github.com/leyan95/qrcode_scanner/issues/42