Dear Flutter community,
I am banging my head on a seemingly simple task.
I want to add firebase authentication to my app. It worked on iOS but as I tried to implement it for android, I systematically get the error :
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle... Resolving dependencies... Running 'gradlew
assembleDebug'... Configuration 'compile' in project ':app' is
deprecated. Use 'implementation' instead. registerResGeneratingTask is
deprecated, use registerGeneratedFolders(FileCollection)
registerResGeneratingTask is deprecated, use
registerGeneratedFolders(FileCollection) registerResGeneratingTask is
deprecated, use registerGeneratedFolders(FileCollection) Configuration
'compile' in project ':google_sign_in' is deprecated. Use
'implementation' instead.
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge
dex
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org
BUILD FAILED in 34s Finished with error: Gradle build failed: 1
I reproduced the error using 'flutter create' then adding Firebase capabilities following the codelab
https://codelabs.developers.google.com/codelabs/flutter-firebase/#4
Here is the only modification to pubspec.yaml
dependencies:
flutter:
sdk: flutter
google_sign_in: 0.3.1 # ONLY MODIFICATION
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.0
general build.gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.1.0' #ONLY MODIF
}
}
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 build.gradle :
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withInputStream { stream ->
localProperties.load(stream)
}
}
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.")
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 26
buildToolsVersion '26.0.3'
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.mycompany.test"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
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.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
apply plugin: 'com.google.gms.google-services'
here is the flutter doctor output :
[✓] Flutter (on Mac OS X 10.13.2 17C88, locale fr-BE, channel master)
• Flutter at /Users/sergebesnard/flutter
• Framework revision 4d2c2aaaa1 (6 days ago), 2017-12-27 07:30:31 -0800
• Engine revision 7c126001d8
• Tools Dart version 1.25.0-dev.11.0
• Engine Dart version 2.0.0-edge.9e8a3e2d31621c1bdf6139d068e7898a2ac2ab5a
[✓] Android toolchain - develop for Android devices (Android SDK
27.0.2)
• Android SDK at /Users/sergebesnard/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-27, build-tools 27.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b08)
[✓] iOS toolchain - develop for iOS devices (Xcode 9.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 9.2, Build version 9C40b
• ios-deploy 1.9.2
• CocoaPods version 1.3.1
[✓] Android Studio (version 3.0)
• Android Studio at /Applications/Android Studio.app/Contents
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b08)
[✓] IntelliJ IDEA Community Edition (version 2017.2.5)
• Flutter plugin version 18.0
• Dart plugin version 172.4155.35
[✓] Connected devices
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 8.0.0 (API 26) (emulator)
I am obviously new to Android development, and would prefer not to have to become expert to get the tutorial working. Every solution I found required tinkering with the .gradle files and only apply to react-native.
Thank you for your help !
I also had the same issue and I read that you had to include multiDexEnabled true in the app\build.gradle defaultConfig section. This worked for me.
This error means that some of your dependencies use a different version of the google play services.
You'd have to downgrade/upgrade plugins to unify the version used
Change minSdkVersion in android/app/build.gradle from 16 to 21
Final Versions
pubspec.yaml
cloud_firestore: ^0.8.2+3
android/build.gradle
classpath 'com.google.gms:google-services:3.2.1' // Google Services plugin
android/app/build.gradle
targetSdkVersion 27
minSdkVersion 21
Solved : incompatible versions used between plugin and framework.
Google SignIn plugin 0.4.0 and above should be used with new projects created with flutter create in its latest version.
The codelab is no longer valid and should be updated.
This link solved the same issue for me.
First I set dependencies in my pubspec.yaml to
dependencies:
flutter:
sdk: flutter
cloud_firestore: ^0.8.2
and ran flutter packages get in my IDE's terminal.
Also I had to change the minimum target SDK version:
Open android/app/build.gradle, then find the line that says
minSdkVersion 16.
Change that line to minSdkVersion 21.
Save the file.
This alone may fix your problem; however I had to also do the following because some of my dependency versions were mismatched.
I had to open android/app/build.gradle, then add the following line as the last line in the file:
apply plugin: 'com.google.gms.google-services'
Next, I had to open android/build.gradle, then inside the buildscript tag, add a new dependency:
buildscript {
repositories {
// ...
}
dependencies {
// ...
classpath 'com.google.gms:google-services:3.2.1' // new
}
}
After this my app finally ran on the android emulator.
The link has a more complete walkthrough if you get stuck.
Also, to note, I did not have to set multiDexEnabled to true.
The problem here may be that the plugins you are depending on have conflicting gradle dependencies.
This SO answer here https://stackoverflow.com/a/49901209/90918 provides a description of how to solve this problem by finding the conflicting dependencies and overriding them.
Quoting the original answer:
Your two packages seem to disagree on their transitive dependencies.
One wants 11.6.+, the other wants 11.+ of some play-services
dependencies. Since both 11.6.2 and 11.8.0 are out there, this is
going to end up with a conflict.
If you run ./gradlew androidDependencies in your android/ folder,
you get a listing of the result of dependency resolution, containing,
among others, the following:
+--- :flutter_google_place_picker (variant: release)
+--- com.google.android.gms:play-services-location:11.8.0#aar
+--- com.google.android.gms:play-services-places:11.6.2#aar
+--- com.google.android.gms:play-services-maps:11.6.2#aar
+--- com.google.android.gms:play-services-base:11.8.0#aar
+--- com.google.android.gms:play-services-tasks:11.8.0#aar
+--- com.google.android.gms:play-services-basement:11.8.0#aar
These 11.6.2 and 11.8.0 packages are not going to work together. To
resolve this, you need to patch your dependencies to be consistent
with each other, or add a dependency override to the top level of your
android/app/build.gradle file and hope for the best:
configurations.all {
resolutionStrategy {
force 'com.google.android.gms:play-services-places:11.8.0'
force 'com.google.android.gms:play-services-location:11.8.0'
}
}
I had the same problem
I ve added on my App/build.gradle on android/defaultConfig the line :
multiDexEnabled true
and on dependencies
implementation 'androidx.multidex:multidex:2.0.1'
App/build.gradle look like this:
def localProperties = new Properties()
...
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
....
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
.....
implementation 'androidx.multidex:multidex:2.0.1'
}
it works for me
The reason is you are using the different version of dependencies. To fix this go to your project/App/src/ and open Build.gradle. Then Add multiDexEnabled true Line inside the default config section.
Ex:Like this
defaultConfig {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
I had added admob_flutter: ^0.3.4 in my flutter app but didn't used anywhere. Removing from pubspec.yaml file works for me.
Related
I am trying to implement JetPack Compose using Canary 8 but getting this error every time I try to sync gradle
An exception occurred applying plugin request [id: 'com.android.application']
My app\build.gradle file is below
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.0"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '11'
useIR = true
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion compose_version
kotlinCompilerVersion '1.4.30'
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.0-alpha06'
implementation 'androidx.activity:activity-compose:1.3.0-alpha02'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
My build.gradle file is below
buildscript {
ext {
compose_version = '1.0.0-beta01'
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.0-alpha08'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.30"
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and this is my gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-all.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Android Gradle Plugin 7 requires Java 11.
Go to File > Project Structure and change JDK location to Embedded JDK.
For Android Studio Artic Fox (2020.3.1), you can find the JDK settings here:
Preferences -> Build, Execution, Deployment -> Build Tools -> Gradle -> Gradle JDK
Then change the setting to "Embedded JDK"
For Android Studio Artic Fox (2020.3.1) Android Gradle Plugin 7 requires Java 11.
use short key Ctr+Alt+Shift+S or
Go to File > Project Structure and change JDK location to Embedded JDK. Same Answer #Mariusz
Check the following picture to re-direct the JDK source:
Step 1.
Step 2.
Step 3.
And you should be good to go.
I have issue with build cache and the error:
An exception occurred applying plugin request [id: 'com.android.application']
> Failed to apply plugin 'com.android.internal.application'.
> The option 'android.enableBuildCache' is deprecated.
The current default is 'false'.
It was removed in version 7.0 of the Android Gradle plugin.
Removing org.gradle.caching=true from root gradle properties file solved the issue.
According to documentation, AGP 7.x.x requires Gradle 7. As seen in you're gradle-wrapper, you're using Gradle 6.8.2. Try updating the project to use Gradle 7 (The current latest version is 7.0-milestone-2). You can do so manually or simply through File > Project Structure.
File -> Project Structure -> Module
Preferences -> Build, Execution, Deploment -> Build Tools -> Gradle
Worked for me
I think all you need to do is first go to the:
Android Studio menu -> Preferences -> Build, Execution, Deployment
In the gradle projects section, select: Gradle JDK version drop down menu
It will show all the JDKs you have installed on your device // See attached image bottom right drop down menu.
Select JDK 11.
Done, now you should be able to build without issues.
Or if you are using CLI to build, then change the ~/.zshrc ( or bash equivalent file for Ubuntu, I am using MacOS 11 so it is Zsh here, you should be having Bash on your device) to JDK11. After your change to the Zsh/Bash resource file, save it and then execute command:
$ source ~/.zshrc // to update change
$ java -version // to check java version
Sample output java version:
openjdk version "11.0.8" 2020-07-14 LTS
OpenJDK Runtime Environment Corretto-11.0.8.10.1 (build 11.0.8+10-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.8.10.1 (build 11.0.8+10-LTS, mixed mode)
Note:
I am using MacOS 11.2.1, Android Studio Artic Fox, 2020.3.1, Gradle Version 7.0.2
Update your plugins to minimal 1.7.0
plugins {
...
id 'org.jetbrains.kotlin.android' version '1.7.0' apply false
}
I'm using flutter to build an app for IOS and Android. Just added Firebase_Auth functionality which works perfectly on IOS. However, when I try to run the app on an Android emulator I get the following error:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':firebase_core:compileDebugAidl'.
> Could not resolve all task dependencies for configuration ':firebase_core:debugCompileClasspath'.
> Could not find com.google.firebase:firebase-common:.
Required by:
project :firebase_core
* 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 3s
Exception: Gradle task assembleDebug failed with exit code 1
android/app/build.gradle file:
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: 'com.google.gms.google-services'
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.example.testing"
minSdkVersion 21
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.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"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
rootProject.ext {
set('FlutterFire', [
FirebaseSDKVersion: '25.12.0'
])
}
android/build.gradle file:
buildscript {
ext.kotlin_version = '1.3.71'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.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
}
pubspec.yaml dependencies:
dependencies:
flutter:
sdk: flutter
google_maps_flutter: ^1.0.6
firebase_core: "^0.7.0"
firebase_analytics: ^7.0.1
firebase_auth: ^0.20.0+1
firebase_dynamic_links: ^0.7.0+1
cloud_firestore: ^0.16.0
google_sign_in: ^4.5.9
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter doctor -v output:
[✓] Flutter (Channel beta, 1.25.0-8.3.pre, on macOS 11.1 20C69 darwin-x64, locale en-NZ)
• Flutter version 1.25.0-8.3.pre at /Users/.../Developer/flutter
• Framework revision 5d36f2e7f5 (9 days ago), 2021-01-14 15:57:49 -0800
• Engine revision 7a8f8ca02c
• Dart version 2.12.0 (build 2.12.0-133.7.beta)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Users/.../Library/Android/sdk
• Platform android-29, build-tools 29.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.3, Build version 12C33
• CocoaPods version 1.10.0
[✓] Android Studio (version 3.6)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 45.1.1
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
[✓] VS Code (version 1.52.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.18.1
[✓] Connected device (1 available)
• sdk gphone x86 (mobile) • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)
• No issues found!
I have spent so much time trying to fix this, please help!
This GitHub Issue showed the solution.
Updating the Firebase SDK in android/app/build.gradle worked for me:
rootProject.ext {
set('FlutterFire', [
FirebaseSDKVersion: '26.3.0'
])
}
I am trying to implement push notification with firebase_messaging: ^6.0.13,
Flutter: Build errors for firebase_messaging”
I have looked through all similar cases, Migrated my project to AndroidX but I still cannot resolve my Android build errors:
Followed procedures.
Flutter clean
flutter packages pub cache repair
Restart Android
Remake emulator nothing is working
Migrated project to AndroidX
Tried downgrading the plugin versions
Exception:
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... 0.6s
Resolving dependencies... 2.5s
/home/rajeshpatil/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.13/android/src/main/java/io/flutter/plugins/firebasemessaging/FirebaseMessagingPlugin.java:80: error: cannot find symbol
onAttachedToEngine(binding.getApplicationContext(), binding.getBinaryMessenger());
^
symbol: method getBinaryMessenger()
location: variable binding of type FlutterPluginBinding
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':firebase_messaging: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 2s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 3.3s
Gradle task assembleDebug failed with exit code 1
project-level/build.gradle:
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.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
}
app-level/build.gradle:
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.")
}
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.example.helloworld"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.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 {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
implementation 'com.google.firebase:firebase-analytics:17.2.2'
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
gradle.properties:
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true
Flutter Doctor:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v1.10.7, on Linux, locale en_IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.43.0)
[✓] Connected device (1 available)
• No issues found!
It looks like you are working on an older flutter project, try a few things and see if these help.
1) Update your flutter SDK. You are currently using a pretty old version of flutter, and a beta build that was never a stable release. Even if this doesnt solve your problem it would be wise to upgrade. You can do so by running flutter upgrade in your terminal.
2) You may be trying to use an older version of certain firebase packages, including messaging. Try changing classpath 'com.google.gms:google-services:4.3.0'
in your project gradle.build to classpath 'com.google.gms:google-services:3.2.1'. Do this only if updating your flutter SDK doesnt fix the issue, and if this doesnt help change it back.
3) Try increasing your minSDKVersion for the project in the app-level/build.gradle, in the past when I have had similar issues this fixed my problems around sdk version 21.
after i connect flutter with firebase and get firebase packages the app run stuck at
Launching lib\main.dart on SM J600F in debug mode...
Running Gradle task 'assembleDebug'...
√ Built build\app\outputs\apk\debug\app-debug.apk.
Installing build\app\outputs\apk\app.apk...
i have tried to delete the app and install it again i cleared the cash data also nothing happen, also i upgraded the futter to the last upgrade nothing happen
this is my pubspec.ymal file
name: finalp
description: A new Flutter project.
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: ">=2.1.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.2
flutter_screenutil: ^0.4.2
firebase_auth:
firebase_core:
firebase_database:
firebase_crashlytics:
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
and this is the android build.gradle file
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.google.gms:google-services:4.3.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
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
}
and this is the app build.gradle file
edef 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.finalp"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
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"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.google.firebase:firebase-analytics:17.2.2'
}
apply plugin: 'com.google.gms.google-services'
and this the flutter doctor
[√] Flutter (Channel stable, v1.12.13+hotfix.8, on Microsoft Windows [Version 10.0.17763.1098], locale en-GB)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[√] Android Studio (version 3.4)
[√] IntelliJ IDEA Community Edition (version 2019.1)
[√] VS Code (version 1.43.2)
[√] Connected device (2 available)
! Doctor found issues in 1 category.
please help me :(
Upgrade:
minSdkVersion 16
into this:
minSdkVersion 21
By default, Flutter supports Android SDK v16 (Jelly Bean, released 2012), but multidex doesn't really work with Jelly Bean (though, it's possible). Configuring Jelly Bean to work is beyond the scope of this codelab, so we'll change the minimum target SDK version from v16 to v21 (Lollipop, released 2014).
https://codelabs.developers.google.com/codelabs/flutter-firebase/#3
I'm developing a flutter app with most of it done except for the push notification. When adding the firebase_messaging plugin in the pubspec.yaml and follow the setup process for android, the app stops launching with out giving any error. Just keeps on waiting to finish installation.
App migrated to android x from the start of development and other firebase plugins in use and working fine.Tested on different physical devices and emulator all with same issue. flutter clean run every time before build.
I'm sure there is something wrong with the setup or a conflict with another plugin but no error is being given.
pubspec.yaml
environment:
sdk: ">=2.2.2 <3.0.0"
dependencies:
flutter:
sdk: flutter
flutter_localizations:
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.2
http: ^0.12.0+1
#shared_preferences: ^0.5.1+1
rxdart: ^0.21.0
carousel_slider: ^1.1.0
google_maps_flutter: ^0.4.0
url_launcher: ^5.0.2
firebase_core: ^0.3.1+1
firebase_auth: ^0.8.3
firebase_dynamic_links: ^0.2.1
flutter_secure_storage: ^3.2.1+1
corsac_jwt: ^0.1.2
intl_translation: ^0.17.4
connectivity: ^0.4.3+1
flutter_svg: ^0.13.0+2
#flutter_statusbarcolor: ^0.1.0
google_sign_in: ^4.0.1+3
flutter_facebook_login: ^2.0.0
country_code_picker: ^1.1.5
webview_flutter: ^0.3.7+1
#permission_handler: '^3.1.0'
#notification_permissions: ^0.3.1
auto_size_text: ^1.1.2
launch_review: ^1.0.1
qr_flutter: ^2.0.0
geolocator: '^5.0.0'
flare_flutter: ^1.5.2
package_info: ^0.4.0+4
pin_code_text_field: ^1.3.6
meta: ^1.1.6
platform: ^2.2.0
firebase_messaging: ^5.1.0
dev_dependencies:
flutter_launcher_icons: 0.6.1
flutter_test:
sdk: flutter
/android/build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.google.gms:google-services:4.2.0'
// classpath 'com.google.gms:google-services:4.2.0'
}
}
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 = '19'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '2.0.17'
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "app.flutter.test"
minSdkVersion 18
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
//// for relases
//release {
// signingConfig signingConfigs.release
// minifyEnabled true
// useProguard true
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
//}
//// for debugging
release{
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
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'
// implementation 'com.google.firebase:firebase-messaging:18.0.0'
}
apply plugin: 'com.google.gms.google-services' // Google Play services Gradle plugin
terminal output
Launching lib/main.dart on ONE A2001 in debug mode...
Initializing gradle... 0.6s
Resolving dependencies... 3.5s
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 20.2s
Built android\build\app\outputs\apk\debug\app-debug.apk.
Installing android\build\app\outputs\apk\app.apk... 28.7s
flutter doctor -v (the only issue of android license it never and it shouldn't effect)
[√] Flutter (Channel stable, v1.7.8+hotfix.3, on Microsoft Windows [Version 10.0.17763.557], locale en-GB)
• Flutter version 1.7.8+hotfix.3 at C:\Users\ricardo\flutter
• Framework revision b712a172f9 (2 days ago), 2019-07-09 13:14:38 -0700
• Engine revision 54ad777fd2
• Dart version 2.4.0
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at C:\Users\ricardo\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• Java binary at: C:\Program Files\Android\Android Studio1\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
X Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit https://flutter.dev/setup/#android-setup for detailed instructions.
[√] Android Studio (version 3.4)
• Android Studio at C:\Program Files\Android\Android Studio1
• Flutter plugin version 37.0.1
• Dart plugin version 183.6270
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
[√] VS Code (version 1.35.1)
• VS Code at C:\Users\ricardo\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.2.0
[√] Connected device (1 available)
• ONE A2001 • 47fc4070 • android-arm64 • Android 6.0.1 (API 23)
! Doctor found issues in 1 category.
You try
run flutter doctor - android-licenses to make an android license. There is one problem there.
Lastest version firebase_messaging 5.1.0
Firebase Messaging Example this is an example of implementation if there is an error in your code
I hope this helps