Flutter Execution failed for task ':app:mergeReleaseResources' - java

Multiple task action failures occurred:
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
AAPT: D:\Flutter Projects\Areading-master\android\app\src\main\res\mipmap-hdpi\ic_launcher.png: error: failed to read PNG signature: file does not start with PNG signature.
D:\Flutter Projects\Areading-master\android\app\src\main\res\mipmap-hdpi\ic_launcher.png: error: file failed to compile.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
AAPT: D:\Flutter Projects\Areading-master\android\app\src\main\res\mipmap-xhdpi\ic_launcher.png: error: failed to read PNG signature: file does not start with PNG signature.
D:\Flutter Projects\Areading-master\android\app\src\main\res\mipmap-xhdpi\ic_launcher.png: error: file failed to compile.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
AAPT: D:\Flutter Projects\Areading-master\android\app\src\main\res\mipmap-xxhdpi\ic_launcher.png: error: failed to read PNG signature: file does not start with PNG signature.
D:\Flutter Projects\Areading-master\android\app\src\main\res\mipmap-xxhdpi\ic_launcher.png: error: file failed to compile.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
AAPT: D:\Flutter Projects\Areading-master\android\app\src\main\res\mipmap-xxxhdpi\ic_launcher.png: error: failed to read PNG signature: file does not start with PNG signature.
D:\Flutter Projects\Areading-master\android\app\src\main\res\mipmap-xxxhdpi\ic_launcher.png: error: file failed to compile.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
AAPT: D:\Flutter Projects\Areading-master\android\app\src\main\res\mipmap-mdpi\ic_launcher.png: error: failed to read PNG signature: file does not start with PNG signature.
D:\Flutter Projects\Areading-master\android\app\src\main\res\mipmap-mdpi\ic_launcher.png: error: file failed to compile.
This Error Happened when I try to build the project by this command flutter build apk --split-per-abi I don't know what is that about? please Help.

The builder optimizes the images in your app, in this case the png images. This is to reduce the size of the apk. It is unable to do so in your case. To run without optimization you can put the following in your build.gradle
android {
buildTypes {
release {
crunchPngs false // or true
}
}
}

I changed the .png file to .jpg in res/drawable and it worked for me

Related

Android resource linking failed

I need to generate app bundle, but the error say :
Execution failed for task ':app:processReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
> Android resource linking failed
C:\Users\fajri\AndroidStudioProjects\Assessment\app\build\intermediates\packaged_manifests\release\AndroidManifest.xml:36: error: resource mipmap/ic_launcher (aka com.si20b.assessment:mipmap/ic_launcher) not found.
C:\Users\fajri\AndroidStudioProjects\Assessment\app\build\intermediates\packaged_manifests\release\AndroidManifest.xml:36: error: resource mipmap/ic_launcher_round (aka com.si20b.assessment:mipmap/ic_launcher_round) not found.
error: failed processing manifest.
i already put my icon in my android project
when you create your image assets make sure you choose main mode.

Can not extract resource from com.android.aaptcompiler.ParsedResource#1c9d41e0

This is the other problem:
Execution failed for task ':app:mergeDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.ResourceCompilerRunnable
> Resource compilation failed (Failed to compile values resource file /Users/bungaallysah/AndroidStudioProjects/splashscreen/app/build/intermediates/incremental/debug/mergeDebugResources/merged.dir/values/values.xml. Cause: java.lang.IllegalStateException: Can not extract resource from com.android.aaptcompiler.ParsedResource#1c9d41e0.,Can not extract resource from com.android.aaptcompiler.ParsedResource#23f7a22d.). Check logs for more details.
I've tried to setup the gradle, but there's no problem with that.

Android Studio - AAPT: error: file failed to compile with PNG images

I was working on Ubuntu linux and recently i pulled my project and started working on Win10.
From now on i cannot Build/Run my app. There must be a problem with those PNG files in the resources folder.
That is the Error output while trying to build the app :
Executing tasks: [:app:assembleDebug] in project C:\Users\Psz\Documents\Android-ChatRoom-Client
> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :app:compileDebugAidl NO-SOURCE
> Task :app:generateDebugBuildConfig UP-TO-DATE
> Task :app:compileDebugRenderscript NO-SOURCE
> Task :app:javaPreCompileDebug UP-TO-DATE
> Task :app:generateDebugResValues UP-TO-DATE
> Task :app:generateDebugResources UP-TO-DATE
> Task :app:createDebugCompatibleScreenManifests UP-TO-DATE
> Task :app:extractDeepLinksDebug UP-TO-DATE
> Task :app:processDebugManifest UP-TO-DATE
> Task :app:mergeDebugShaders UP-TO-DATE
> Task :app:compileDebugShaders NO-SOURCE
> Task :app:generateDebugAssets UP-TO-DATE
> Task :app:mergeDebugAssets UP-TO-DATE
> Task :app:processDebugJavaRes NO-SOURCE
> Task :app:mergeDebugResources FAILED
AGPBI: {"kind":"error","text":"Android resource compilation failed","sources":[{"file":"C:\\Users\\Psz\\Documents\\Android-ChatRoom-Client\\app\\build\\generated\\res\\pngs\\debug\\drawable-ldpi\\ic_launcher_background.png"}],"original":"C:\\Users\\Psz\\Documents\\Android-ChatRoom-Client\\app\\build\\generated\\res\\pngs\\debug\\drawable-ldpi\\ic_launcher_background.png: AAPT: error: file failed to compile.\n ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource compilation failed","sources":[{"file":"C:\\Users\\Psz\\Documents\\Android-ChatRoom-Client\\app\\build\\generated\\res\\pngs\\debug\\drawable-xhdpi\\ic_greensky_background.png"}],"original":"C:\\Users\\Psz\\Documents\\Android-ChatRoom-Client\\app\\build\\generated\\res\\pngs\\debug\\drawable-xhdpi\\ic_greensky_background.png: AAPT: error: file failed to compile.\n ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource compilation failed","sources":[{"file":"C:\\Users\\Psz\\Documents\\Android-ChatRoom-Client\\app\\build\\generated\\res\\pngs\\debug\\drawable-hdpi\\ic_launcher_background.png"}],"original":"C:\\Users\\Psz\\Documents\\Android-ChatRoom-Client\\app\\build\\generated\\res\\pngs\\debug\\drawable-hdpi\\ic_launcher_background.png: AAPT: error: file failed to compile.\n ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource compilation failed","sources":[{"file":"C:\\Users\\Psz\\Documents\\Android-ChatRoom-Client\\app\\build\\generated\\res\\pngs\\debug\\drawable-mdpi\\ic_greensky_background.png"}],"original":"C:\\Users\\Psz\\Documents\\Android-ChatRoom-Client\\app\\build\\generated\\res\\pngs\\debug\\drawable-mdpi\\ic_greensky_background.png: AAPT: error: file failed to compile.\n ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource compilation failed","sources":[{"file":"C:\\Users\\Psz\\Documents\\Android-ChatRoom-Client\\app\\build\\generated\\res\\pngs\\debug\\drawable-mdpi\\ic_launcher_background.png"}],"original":"C:\\Users\\Psz\\Documents\\Android-ChatRoom-Client\\app\\build\\generated\\res\\pngs\\debug\\drawable-mdpi\\ic_launcher_background.png: AAPT: error: file failed to compile.\n ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource compilation failed","sources":[{"file":"C:\\Users\\Psz\\Documents\\Android-ChatRoom-Client\\app\\build\\generated\\res\\pngs\\debug\\drawable-xxhdpi\\ic_greensky_background.png"}],"original":"C:\\Users\\Psz\\Documents\\Android-ChatRoom-Client\\app\\build\\generated\\res\\pngs\\debug\\drawable-xxhdpi\\ic_greensky_background.png: AAPT: error: file failed to compile.\n ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource compilation failed","sources":[{"file":"C:\\Users\\Psz\\Documents\\Android-ChatRoom-Client\\app\\build\\generated\\res\\pngs\\debug\\drawable-hdpi\\ic_greensky_background.png"}],"original":"C:\\Users\\Psz\\Documents\\Android-ChatRoom-Client\\app\\build\\generated\\res\\pngs\\debug\\drawable-hdpi\\ic_greensky_background.png: AAPT: error: file failed to compile.\n ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource compilation failed","sources":[{"file":"C:\\Users\\Psz\\Documents\\Android-ChatRoom-Client\\app\\build\\generated\\res\\pngs\\debug\\drawable-ldpi\\ic_greensky_background.png"}],"original":"C:\\Users\\Psz\\Documents\\Android-ChatRoom-Client\\app\\build\\generated\\res\\pngs\\debug\\drawable-ldpi\\ic_greensky_background.png: AAPT: error: file failed to compile.\n ","tool":"AAPT"}
> Task :app:mergeDebugJavaResource
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\Psz\Documents\Android-ChatRoom-Client\app\build\generated\res\pngs\debug\drawable-ldpi\ic_greensky_background.png: 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\Psz\Documents\Android-ChatRoom-Client\app\build\generated\res\pngs\debug\drawable-mdpi\ic_greensky_background.png: 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\Psz\Documents\Android-ChatRoom-Client\app\build\generated\res\pngs\debug\drawable-ldpi\ic_launcher_background.png: 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\Psz\Documents\Android-ChatRoom-Client\app\build\generated\res\pngs\debug\drawable-hdpi\ic_greensky_background.png: 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\Psz\Documents\Android-ChatRoom-Client\app\build\generated\res\pngs\debug\drawable-mdpi\ic_launcher_background.png: 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\Psz\Documents\Android-ChatRoom-Client\app\build\generated\res\pngs\debug\drawable-xhdpi\ic_greensky_background.png: 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\Psz\Documents\Android-ChatRoom-Client\app\build\generated\res\pngs\debug\drawable-hdpi\ic_launcher_background.png: 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\Psz\Documents\Android-ChatRoom-Client\app\build\generated\res\pngs\debug\drawable-xxhdpi\ic_greensky_background.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 1s
10 actionable tasks: 2 executed, 8 up-to-date
build.gradle(:app) file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 30
configurations.all {
resolutionStrategy.eachDependency{
DependencyResolveDetails details ->
def requested = details.requested
if (requested.group=="com.android.support"){
if (!requested.name.startsWith("multidex")){
details.useVersion("26.+")
}
}
}
}
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.myname.greenskychatroom"
minSdkVersion 16
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
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation files('libs/json-simple-1.1.jar')
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
I don't know what is causing it. I cleaned cache, delete and pull project again. Also i couldn't find a solution online.
Update
Found out that Android Studio on Linux(Ubuntu) works just fine and as a matter of fact this error occurs only on Windows' Android Studio..
If some files have been encrypted, AAPT may not work properly. Please check whether the files related to the compilation error are encrypted. In your case, these are PNG files.
I had exactly the same error. Tried everything including pulling my own hear out, but nothing worked. Then someone mentioned running Android Studio as admin would solve the problem... So it has something to do with write access problems. Bingo! Try this:
In windows go to Ransomware protection and disable it!
Then try building again. If that works then use Allow an app through Controlled folder access to give gradle the right access rights. And then enable your Ransomware protection again.
I encountered a similar problem to this, and the root cause was that a JPEG file was named with a PNG file extension. Once I fixed the file extension AAPT was happy.
In Windows, try to keep your project in a drive apart from windows (C drive). You can use D drive and try keeping the path short (eg. D:\Projects\XyzProject). This might resolve your issue.
i face same problem ,and solved .this error is due to windows security , select the file properties which causing issue and unblock it.
im my case i tried to use some png images that i downloaded from whatsapp and they were encrypted.
to fix it follow this steps:
1-open paint
2-open your images
3-save them
and you are ready to go!

Trying to use a JAR created with Clojure in Android

I want to use Clojure to create a library that I'll use in an Android project.
Experimenting with this, I've made an Uberjar from a test library in Leiningen.
Then I import it into my Android project.
But I'm getting this error :
AGPBI: {"kind":"error","text":"MethodHandle.invoke and MethodHandle.invokeExact are only supported starting with Android O (--min-api 26)","sources":[{}],"tool":"D8"}
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeExtDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform file 'mylib.jar' to match attributes {artifactType=android-dex, dexing-enable-desugaring=false, dexing-is-debuggable=true, dexing-min-sdk=23, org.gradle.usage=java-runtime-jars}
> Execution failed for DexingNoClasspathTransform: /media/phil/54AE4F563BCE86E8/DATA/new_dev_tree/small_experiments/clj-jar-for-android/TestAJar/app/libs/mylib.jar.
> Error while dexing.
> Failed to transform file 'mylib.jar' to match attributes {artifactType=android-dex, dexing-enable-desugaring=false, dexing-is-debuggable=true, dexing-min-sdk=23, org.gradle.usage=java-runtime-jars}
> Execution failed for DexingNoClasspathTransform: /media/phil/54AE4F563BCE86E8/DATA/new_dev_tree/small_experiments/clj-jar-for-android/TestAJar/app/libs/mylib.jar.
> Error while dexing.
What exactly is going wrong here? Is it about the Android version? Or the file path? Or something completely different?

Cordova project Build time show Error -- Build Failed

When try to build cordova project in cmd with
android 6.4.0 also try android 7.1.0 but still showing build failed
Below Error Show after build cordova project
cordova build android
ANDROID_HOME=G:\shripati\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x
86_64-20140702\sdk JAVA_HOME=C:\Program Files\Java\jdk1.8.0_172
Subproject Path: CordovaLib Observed package id 'build-tools;20.0.0'
in inconsistent location 'G:\shripati\a
dt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\build-t
ools\android-4.4W' (Expected
'G:\shripati\adt-bundle-windows-x86_64-20140702\adt
-bundle-windows-x86_64-20140702\sdk\build-tools\20.0.0')
FAILED BUILD FAILED Total time: 50.818 secs FAILURE: Build failed with
an exception. * What went wrong: Execution failed for task
':processDebugResources'.
com.android.ide.common.process.ProcessException: Failed to execute
aapt * Try: Run with --stacktrace option to get the stack trace. Run
with --info or --debug option to get more log output. (node:6448)
UnhandledPromiseRejectionWarning: Error: cmd: Command failed with ex
it code 1 Error output: Note: Some input files use or override a
deprecated API. Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API. Note:
Recompile with -Xlint:deprecation for details. ERROR: In
FontFamilyFont, unable to find attribute android:f ont ERROR: In
FontFamilyFont, unable to find attribute android:f ontStyle ERROR: In
FontFamilyFont, unable to find attribute android:f
ontVariationSettings ERROR: In FontFamilyFont, unable to find
attribute android:f ontWeight ERROR: In FontFamilyFont, unable to find
attribute android:t tcIndex FAILURE: Build failed with an exception. *
What went wrong: Execution failed for task ':processDebugResources'.
com.android.ide.common.process.ProcessException: Failed to execute
aapt * Try: Run with --stacktrace option to get the stack trace. Run
with --info or --debug option to get more log output. at
ChildProcess.whenDone
(D:\shri\convertVisualStudio\shri\LBSCRM\platforms\
android\cordova\node_modules\cordova-common\src\superspawn.js:169:23)
at ChildProcess.emit (events.js:182:13) at maybeClose
(internal/child_process.js:957:16) at
Process.ChildProcess._handle.onexit (internal/child_process.js:246:5)
(node:6448) UnhandledPromiseRejectionWarning: Unhandled promise
rejection. This error originated either by throwing inside of an async
function without a catch block, or by rejecting a promise which was
not handled with .catch(). (rejection id: 1) (node:6448) [DEP0018]
DeprecationWarning: Unhandled promise rejections are depre cated. In
the future, promise rejections that are not handled will terminate the
Node.js process with a non-zero exit code.
These resources were only added in the android-P preview, so if you want to use a library that references them you need to update your compile sdk to android-P preview, you can follow this guide.

Categories