Execution failed for task ':app:mergeDebugJavaResource'. - Gradle Task assemble - firebase

so I was trying to run my flutter project and then I got this error :
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugJavaResource'.
> java.nio.file.FileSystemException: C:\Users\ASUS\Desktop\Programmin\Flutter\app_with_firebase\build\app\intermediates\merged_java_res\debug\out.jar: The process cannot access the file because it is being used by another process.
* 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
I tried to do : File > Invalidate Chaches/Restart in Android studio, but it won't solve the problem. I also tried to do flutter clean, then flutter run, but It still shows me the same error.
I have no idea what to do now, any help is appreciated.
Thank you !

I did a bit more digging with SysInternals and jps and it turns out that the Kotlin Language Server wasn't releasing the lock on the build folder. For me, uninstalling the VS Code fwcd Kotlin extension (and replacing with a different Kotlin language extension, if required) was enough to fix the issue.
On Android Studio, all I can suggest is disabling/uninstalling the Kotlin plugin and seeing if that fixes it for you.

Related

Unable to build apk after adding firebase-analytics[Ionic, Cordova]

I am getting error when I try to build apk after adding firebase-analytics. It is showing error in console is
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\sampleproject\platforms\android\app\build.gradle' line: 428
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.google.gms.google-services']
> Cannot add extension with name 'googleServices', as there is an extension already registered with that name.
* 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 6s
Command failed with exit code 1: D:\sampleproject\platforms\android\gradlew cdvBuildDebug -b D:\sampleproject\platforms\android\build.gradle
[ERROR] An error occurred while running subprocess cordova.
cordova.cmd build android exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
The file googleservices is already present in my project before. As I am using Firebase authentication before in my project. Now the issue is, I can't edit the Gradle file as I am using Cordova to build the Apk.
I also gone through other stackoverflow question and answers, I commented out
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
in gradle but this is not the proper way to solve this problem.
Below this I am mentioning all the extensions I had in my project.
"#ionic-native/firebase-analytics": "^5.36.0",
"#ionic-native/google-plus": "^5.28.0",
"firebase": "^7.19.1",
"google-auth-library": "^6.0.6",
"cordova-plugin-firebase-analytics": "^6.1.0",
"cordova-plugin-firebase-lib": "^5.1.1",
For more clarification I attached the screenshot.
Thank you in advance.

Flutter: Execution failed for task ':firebase_core:compileDebugJavaWithJavac'

I would like to ask some help regarding flutter.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':firebase_core:compileDebugJavaWithJavac'.
> Could not create service of type DefaultGeneralCompileCaches using GradleScopeCompileServices.createGeneralCompileCaches().
> Unexpected lock protocol found in lock file. Expected 3, found 0.
* 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
This is the error I am getting , I've never seen anything like this before. Other apps runs perfectly fine so there's no value in adding flutter doctor if you want to see some other code lemme know down in the comment.
It seems like you are facing this issue when the android gradle build is running. As per the error output, this might get you back on track.
Try deleting the gradle cache located under
Windows:
C:\Users\user\.gradle
Mac/Linux:
/Users/prabhath/.gradle
folder and rerun the build.
Hope this will solve your problem.

flutter firebase facebook login not working on android due to a build.gradle problem

it is working fine on iOS but facing this issue on android
Launching lib/main.dart on sdk gphone x86 arm in debug mode...
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':firebase_auth:generateDebugRFile'.
Could not resolve all files for configuration ':firebase_auth:debugCompileClasspath'.
Could not find com.facebook.android:facebook-login:[8.1).
Required by:
project :firebase_auth
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 20s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
The version given by the facebook documentation doesn't work for me either.
That's the version i am actually using:
implementation 'com.facebook.android:facebook-login:[8,9)'
Anyway, if it doesn't solve your problem, try to give more information like, the plugin you are using for the facebook authentication, its version, and the firebase_auth and firebase_core version of the plugin you are using
It just worked with me when i switched to windows (don't know how ) and the error still show on Mac OS after trying all available solutions

Getting error with firebase_messaging plugin

I'm adding firebase_messaging plugin to my project, the previous version had firebase_messaging and was working fine. I'm shifting my project from using flutter_webview_plugin to using webview_flutter, so I changed my code accordingly but I started getting errors. I created new project and the same error is thrown, but when I removed firebase_messaging it started working.
This is the error:-
D8: Program type already present: android.support.v4.app.INotificationSideChannel
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/2.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/3.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/4.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/5.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/6.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/7.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/8.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/9.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/10.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/11.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/12.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/13.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/14.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/15.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/34.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/37.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/40.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/43.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/46.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/49.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/52.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/55.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/58.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/61.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/64.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/67.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/70.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/73.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/76.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/79.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/82.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/85.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/88.jar, /Users/KiranMenon/Desktop/tydy_mobile/build/app/intermediates/transforms/dexBuilder/debug/91.jar
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: android.support.v4.app.INotificationSideChannel
* 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 11s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See **************** for more information on the problem and how to fix it.
*******************************************************************************************
Finished with error: Gradle task assembleDebug failed with exit code 1
Check this issue on github about that. Also, if you are using the latest plugins you should migrate your project to be compatible with AndroidX. And make sure your compileSdkVersion is compatible with those plugins. ps: flutter clean it after you try those things.

Execution failed for task ':firebase_auth:compileDebugJavaWithJavac'

After upgrading firebase_auth from earlier version to ^0.8.0+1 generates error for me.
Here is error
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 2s
Finished with error: Gradle task assembleDebug failed with exit code 1
According to the Changelog, you have to perform a migration in the Android project to AndroidX.
The details of the changes required are here.
See CHANGELOG:
0.8.0
Breaking change. Migrate from the deprecated original Android Support Library to AndroidX. This shouldn't result in any functional changes, but it requires any Android apps using this plugin to also migrate if they're using the original support library.
Firstly set the compileSdkVersion to 28 in the android/app/build.gradle file.
Secondly add the following to your android/gradle.properties file:
android.useAndroidX=true
android.enableJetifier=true

Resources