Flutter New Project Build Error mergeDebugResources - flutter

I have created a new flutter project and out of nowhere it gives me the following errors when I run the default application (no edits made).
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Multiple task action failures occurred:
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
C:\Users\bvenh\Documents\flutter\flutter_app_5\build\app\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml: AAPT: error: file failed to compile.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
C:\Users\bvenh\Documents\flutter\flutter_app_5\build\app\intermediates\incremental\mergeDebugResources\merged.dir\values-hi\values-hi.xml: AAPT: error: file failed to compile.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
C:\Users\bvenh\Documents\flutter\flutter_app_5\build\app\intermediates\incremental\mergeDebugResources\merged.dir\values-de\values-de.xml: AAPT: error: file failed to compile.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
C:\Users\bvenh\Documents\flutter\flutter_app_5\build\app\intermediates\incremental\mergeDebugResources\merged.dir\values-lo\values-lo.xml: AAPT: error: file failed to compile.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
C:\Users\bvenh\Documents\flutter\flutter_app_5\build\app\intermediates\incremental\mergeDebugResources\merged.dir\values-pt\values-pt.xml: AAPT: error: file failed to compile.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
C:\Users\bvenh\Documents\flutter\flutter_app_5\build\app\intermediates\incremental\mergeDebugResources\merged.dir\values-lt\values-lt.xml: AAPT: error: file failed to compile.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
C:\Users\bvenh\Documents\flutter\flutter_app_5\build\app\intermediates\incremental\mergeDebugResources\merged.dir\values-hr\values-hr.xml: AAPT: error: file failed to compile.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
C:\Users\bvenh\Documents\flutter\flutter_app_5\build\app\intermediates\incremental\mergeDebugResources\merged.dir\values-lv\values-lv.xml: AAPT: error: file failed to compile.
* 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 12s
Exception: Gradle task assembleDebug failed with exit code 1
I have tried everything!
I installed a new version of visual c++ as someone gave that as a solution to a question that was similar to mine on stack overflow.
I installed a new version of flutter
I installed a new version of Java JDK 1.8
I changed my user variables for JAVA_HOME & ANDROID_HOME
And it still does not work.
This is what flutter doctor outputs:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 1.22.2, on Microsoft Windows [Version 10.0.18362.1139], locale en-NL)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[√] Android Studio (version 4.0)
[√] VS Code (version 1.50.1)
[√] Connected device (1 available)
• No issues found!
I use windows.
Old projects do work
So in short, what is the issue?
When I create a new project the default project (and all edits made after that) will result in a mergeDebugResources error, even without making any changes.
Does anyone know how to solve this?
Your help would be of major support!

It seems it is a Gradle issue. From this thread: https://github.com/flutter/flutter/issues/51690 There is this possible fix posted (updating Gradle version).
In gradle/wrapper/gradle-wrapper.properties try changing:
https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
to
https\://services.gradle.org/distributions/gradle-5.6.3-all.zip
There is also a stack overflow answer here:
https://stackoverflow.com/a/61156603/13714686
Which goes into detail about fixing this issue by changing Gradle settings.

I had same issue with my project and searched for an answer for hours. The solution was actually quite unexpected...
In Windows 10 "Security Options," I turned off the option of ransomware and tried to run the project and it worked. I don't know if this will solve the issue, but consider this as one option if same problem is encountered in future.

Related

> Android resource linking failed ERROR:: AAPT: error: failed to open APK: Invalid file

i am trying to run my new flutter project in visual studio code, but i am getting this kind of problem in my debug console, is there any way to solve it?
I am getting this while trying to run build in debug mode
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
> Android resource linking failed
ERROR:: AAPT: error: failed to open APK: Invalid file.

i have just started to learn android studio, , i was learning to change appicon and this error pops up and now even hello world wont run

FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:processDebugResources'.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Android resource linking failed
C:\Users\collc\StudioProjects\untitled111\build\app\intermediates\packaged_manifests\debug\AndroidManifest.xml:16: AAPT: error: resource mipmap/ic_launcher (aka com.example.untitled111:mipmap/ic_launcher) not found.
Try Changing your emulator and make sure your android studio is up to date.

Flutter cannot get resource X86-64-debug

I am just new to Flutter and I am trying to create the web according to my colleague's code but I engage the error below:
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
Could not resolve all artifacts for configuration ':app:debugCompileClasspath'.
Could not download x86_64_debug.jar (io.flutter:x86_64_debug:1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32)
Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_64_debug/1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32/x86_64_debug-1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32.jar'.
Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_64_debug/1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32/x86_64_debug-1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32.jar'.
Connect to storage.googleapis.com:443 [storage.googleapis.com/172.217.160.80] failed: Connection timed out: connect
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 36s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
flutter version
Flutter 1.17.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f7a6a7906b (4 days ago) • 2020-05-12 18:39:00 -0700
Engine • revision 6bc433c6b6
Tools • Dart 2.8.2
enviroment variables
FLUTTER_STORAGE_BASE_URL is https://storage.flutter-io.cn,
PUB_HOSTED_URL is https://pub.flutter-io.cn
May I have your help for the issue, it looks like a connection problem but I can get the X86_Debug download in the brower while I can't determine where to place the file. Maybe the directory where the file placed could be helpful too.
Using a VPN worked for me. I am using protonVPN.

I am trying to build apk of my Flutter project but an error occurs and it fails to build

Microsoft Windows [Version 10.0.18363.778]
(c) 2019 Microsoft Corporation. All rights reserved.
F:\flutter_projects\i_am_rich>flutter build apk
You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK
size.
To generate an app bundle, run:
flutter build appbundle --target-platform android-arm,android-arm64,android-x64
Learn more on: https://developer.android.com/guide/app-bundle
To split the APKs per ABI, run:
flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
Learn more on: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
Running Gradle task 'assembleRelease'...
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:mergeReleaseResources'.
Multiple task action failures occurred:
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Android resource compilation failed
F:\flutter_projects\i_am_rich\android\app\src\main\res\mipmap-xhdpi\ic_launcher.png: AAPT: error: failed to read PNG signature: file does not start with PNG signature.
F:\flutter_projects\i_am_rich\android\app\src\main\res\mipmap-xhdpi\ic_launcher.png: AAPT: error: file failed to compile.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Android resource compilation failed
F:\flutter_projects\i_am_rich\android\app\src\main\res\mipmap-mdpi\ic_launcher.png: AAPT: error: failed to read PNG signature: file does not start with PNG signature.
F:\flutter_projects\i_am_rich\android\app\src\main\res\mipmap-mdpi\ic_launcher.png: AAPT: error: file failed to compile.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Android resource compilation failed
F:\flutter_projects\i_am_rich\android\app\src\main\res\mipmap-xxxhdpi\ic_launcher.png: AAPT: error: failed to read PNG signature: file does not start with PNG signature.
F:\flutter_projects\i_am_rich\android\app\src\main\res\mipmap-xxxhdpi\ic_launcher.png: AAPT: error: file failed to compile.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Android resource compilation failed
F:\flutter_projects\i_am_rich\android\app\src\main\res\mipmap-xxhdpi\ic_launcher.png: AAPT: error: failed to read PNG signature: file does not start with PNG signature.
F:\flutter_projects\i_am_rich\android\app\src\main\res\mipmap-xxhdpi\ic_launcher.png: AAPT: error: file failed to compile.
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 2m 29s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 152.6s (!)
Gradle task assembleRelease failed with exit code 1
F:\flutter_projects\i_am_rich>
I think you messed up with the icon files of your app. Try to replace the icon files.
If you use the https://appicon.co/ website to create the application icon, you must choose an image of png

Flutter Project is not running when using indian domain

I created a project using following command on windows environment
flutter create --org in.myorg helloworld
Project is created successfully
Flutter version is as below
Flutter 1.9.1+hotfix.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 1aedbb1835 (3 weeks ago) • 2019-10-17 08:37:27 -0700
Engine • revision b863200c37
Tools • Dart 2.5.0
When I run the code I get following error
e: D:\Project\test\helloworld\android\app\src\main\kotlin\in\myorg\helloworld\MainActivity.kt: (1, 9): Package name must be a '.'-separated identifier list
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Compilation error. See log for more 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 12s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 13.5s
Gradle task assembleDebug failed with exit code 1
.in domains are not allowed in flutter? using an incorrect domain will face issue while publishing app?
Yes, because in is one of Kotlin reserved keywords: keyword-reference
You can fix it by set Java as your Android platform language and not Kotlin.
Also, I think that this word is also reserved for Swift language.
I'm not sure if you can switch it on the fly but you can recreate your project with:
flutter create -i objc -a java command