I have a specific flutter project that has error on some packages i added like the following:
on image_picker package issue - when running ImagePicker.pickImage:
Unhandled Exception: MissingPluginException(No implementation found for method pickImage on channel plugins.flutter.io/image_picker)
on url_launcher package issue - when running canLaunch(url):
Unhandled Exception: MissingPluginException(No implementation found for method canLaunch on channel plugins.flutter.io/url_launcher)
on plaid package issue:
Unhandled Exception: PlatformException(error, java.lang.IllegalStateException: Trying to create a platform view of unregistered type: plugins.flutter.io/webview
Note:
I have tried to import those packages on my previous projects on the same machine, and it works just fine.
Tested this project to build iOS and it works fine so the problem most likely is on android build.
Done flutter clean, flutter upgrade, uninstall/reinstall app on device, tested on other android device/emulator but doesn't solved the problem.
Tried to run both on Android Studio and VS Code, but still gives the same error.
changed to flutter stable channel, and Still got no luck.
flutter doctor -v
[√] Flutter (Channel master, v1.16.4-pre.69, on Microsoft Windows [Version 10.0.18362.720], locale en-US)
• Flutter version 1.16.4-pre.69 at C:\Flutter\flutter
• Framework revision 19e7db585d (5 days ago), 2020-04-01 11:16:01 -0700
• Engine revision c9506cb8e9
• Dart version 2.8.0 (build 2.8.0-dev.18.0 eea9717938)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at C:\Users\mikay\AppData\Local\Android\sdk
• Platform android-29, build-tools 29.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
• All Android licenses accepted.
[√] Android Studio (version 3.6)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 44.0.2
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
[√] VS Code (version 1.43.2)
• VS Code at C:\Users\mikay\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.8.1
[√] Connected device (1 available)
• Samsung Galaxy S8 • 192.168.175.101:5555 • android-x86 • Android 9 (API 28)
• No issues found!
pubspec.yaml
version: 1.0.0+1
environment:
sdk: '>=2.6.0 <3.0.0'
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.3
relative_scale: ^1.0.5
rxdart: ^0.23.1
flutter_signin_button: ^1.0.0
dio: ^3.0.9
pretty_dio_logger: ^1.1.1
firebase_core: ^0.4.4+3
firebase_auth: ^0.15.5+3
cloud_firestore: ^0.13.4+2
firebase_messaging: ^6.0.13
flutter_facebook_login: ^3.0.0
shared_preferences: ^0.5.6+3
flushbar: ^1.10.0
url_launcher: ^5.4.2
intl: ^0.16.1
flutter_advanced_networkimage: ^0.7.0
image_picker: ^0.6.4
decimal: ^0.3.0
plaid: ^1.0.2
webview_flutter: ^0.3.19+9
dev_dependencies:
flutter_test:
sdk: flutter
build.gradle(app)
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"
apply plugin: 'com.google.gms.google-services'
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.app.example"
minSdkVersion 20
targetSdkVersion 28
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"
implementation 'com.google.firebase:firebase-analytics:17.2.3'
implementation 'com.android.support:multidex:1.0.3'
}
build.gradle (project-level)
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
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
}
Found the solution. The reason is that I added the flutter_facebook_login and did not do its additonal setup which is to add this code on AndroidManifest.xml:
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id"/>
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="#string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
thus, It mess up all packages that initiate an external views like camera, file manager, web view, etc..
Related
could someone help me because I have already registered all the way through the registrar but unfortunately it still doesn't work
Errors
Note: /Users/nagysebestyen/development/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-1.7.0/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/nagysebestyen/development/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-2.5.3/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/nagysebestyen/development/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-2.5.3/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/nagysebestyen/development/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-3.1.3/android/src/main/java/io/flutter/plugins/firebase/auth/FlutterFirebaseAuthPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
/build.gradle
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
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.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 30
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.crud_firebase"
minSdkVersion 24
targetSdkVersion 28
multiDexEnabled true
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 {
implementation platform('com.google.firebase:firebase-bom:28.4.2')
implementation "androidx.multidex:multidex:2.0.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
Version:
firebase_core: ^1.7.0
firebase_auth: ^3.1.3
cloud_firestore: ^2.5.3
[✓] Flutter (Channel stable, 2.5.3, on macOS 11.6 20G165 darwin-x64, locale hu-HU)
• Flutter version 2.5.3 at /Users/nagysebestyen/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 18116933e7 (10 days ago), 2021-10-15 10:46:35 -0700
• Engine revision d3ea636dc5
• Dart version 2.14.4
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/nagysebestyen/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 13.0, Build version 13A233
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
[✓] VS Code (version 1.61.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.27.0
[✓] Connected device (2 available)
• sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 12 (API 31) (emulator)
• Chrome (web)
Try to update your packages in your pubspec.yaml file. The latest versions as of now are:
firebase_core: ^1.8.0
cloud_firestore: ^2.5.4
firebase_auth: ^3.1.4
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 build my app as a "release" build (with signing and all) to publish it to PlayStore. I get a lot of crash reports from the "Pre-launch report" within PlayStore which all look like this:
Crash java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.domain/com.domain.MainActivity}: java.lang.ClassNotFoundException: Didn't find
class "com.domain.MainActivity" on path: DexPathList[[zip file "/data/app/com.domain-1/base.apk", zip
file "/data/app/com.domain-1/split_config.arm64_v8a.apk", zip file "/data/app/com.domain-
1/split_config.xxhdpi.apk"],nativeLibraryDirectories=[/data/app/com.domain-1/lib/arm64,
/data/app/com.domain-1/base.apk!/lib/arm64-v8a, /data/app/com.domain-
1/split_config.arm64_v8a.apk!/lib/arm64-v8a, /data/app/com.domain-
1/split_config.xxhdpi.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
The build process, however, worked as expected without any failure. Also, the debug build and split-by-abi build is working without any problems or crashes.
This is the folder structure of the Android app (Originally I used another folder structure "app/main/kotlin/com/domain/MainActivity.kt" but with the same result):
This is the gradle.build which is on the androids folder level:
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')
logger.info("DEBUG - FLUTTER ROOT: " + flutterRoot)
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 from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
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
}
*/
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 28
packagingOptions {
exclude ("META-INF/shared_core_release.kotlin_module")
}
defaultConfig {
applicationId "com.domain"
minSdkVersion 25
targetSdkVersion 28
compileSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
minifyEnabled true
signingConfig signingConfigs.release
sourceSets {
main {
manifest.srcFile 'app/src/main/AndroidManifest.xml'
res.srcDirs = ['app/src/main/res']
}
}
}
}
}
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'
}
And this is the referenced AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.domain">
<application
android:name="io.flutter.app.FlutterApplication"
android:label="App"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
<!-- omitted -->
</manifest>
This is the content of app/src/main/kotlin/com.domain/MainActivity.kt:
package com.domain
import androidx.annotation.NonNull;
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugins.GeneratedPluginRegistrant
class MainActivity: FlutterActivity() {
override fun configureFlutterEngine(#NonNull flutterEngine: FlutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine);
}
}
This is the excerpt from flutter doctor:
[√] Flutter (Channel stable, v1.17.5, on Microsoft Windows [Version 10.0.18362.900], locale de-DE)
• Flutter version 1.17.5 at C:\flutter
• Framework revision 8af6b2f038 (9 days ago), 2020-06-30 12:53:55 -0700
• Engine revision ee76268252
• Dart version 2.8.4
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at C:\Users\xxx\AppData\Local\Android\Sdk
• Platform android-29, build-tools 29.0.3
• ANDROID_HOME = C:\Users\xxx\AppData\Local\Android\Sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
X Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit visit
https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions.
[√] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 46.0.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] IntelliJ IDEA Ultimate Edition (version 2019.3)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.4
• Flutter plugin version 44.0.3
• Dart plugin version 193.6911.31
[√] Connected device (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)
Any help would be highly welcome to resolve this problem.
EDIT #1:
After turning off modification, it seems that the com.domain.MainActivity is not present in the dex.
But I don't understand why it's not included.
I was finally able to resolve the problem to some extend.
After trying all the solutions offered as comments (non of them working) I created a brand new project and copied over the parts that I assumed might cause the problem to try to replicate the problem.
After nothing worked (nothing broke the build or the app for the new project) I copied over everything and just adapt the newly created project. From what I can see, there are no changes and even GIT does not find any remarkable changes.
It's now working even if the solution for this is far behind what I'd hoped for. As there are also no remarkable changes in the project, I can not contribute with deeper insights or what might have caused the problem.
I am failing to implement Firebase to my Flutter Android app.
I created a default Flutter app on Android Studio and it is running on both emulator and physical device.
I created a Firebase app and added all the plugins and the dependencies on android/build.gradle and app/build.gradle. The google-services.json file is placed in the android/app folder.
However I got the following message:
E/FirebaseInstanceId( 3662): binding to the service failed
Can anyone help?
android/build.gradle
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
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/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: '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.israelzadeh.firebasetest"
minSdkVersion 16
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
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 'com.google.firebase:firebase-analytics:17.2.2'
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'
}
flutter doctor -v output
[√] Flutter (Channel stable, v1.12.13+hotfix.9, on Microsoft Windows [Version 10.0.18363.778], locale en-GB)
• Flutter version 1.12.13+hotfix.9 at E:\flutter
• Framework revision f139b11009 (3 weeks ago), 2020-03-30 13:57:30 -0700
• Engine revision af51afceb8
• Dart version 2.7.2
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at C:\Users\comfe\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.3
• Java binary at: E:\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
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.6)
• Android Studio at E:\Android\Android Studio
• Flutter plugin version 45.1.1
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
[!] IntelliJ IDEA Community Edition (version 2019.3)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.2.4
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• For information about installing plugins, see
https://flutter.dev/intellij-setup/#installing-the-plugins
[√] VS Code (version 1.44.2)
• VS Code at C:\Users\comfe\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.9.1
[√] Connected device (1 available)
• ONEPLUS A6013 • 9e2734d0 • android-arm64 • Android 9 (API 28)
! Doctor found issues in 2 categories.
I just ignored the error and Restarted the app again.
And ran the test function that I had implemented to check if its working or not, and it did.
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed: () {
Firestore.instance
.collection("...") // Location in your database
.snapshots().listen((data) {
print(data);
});
},
),
I implemented it in the code and also I had an entry in the database.
In debug console I get output as:
I/flutter (22372): Instance of 'QuerySnapshot'
This means it works.
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