How to identify errors in android data binding? [AGP 4.0 +] - android

Recently I noticed that errors from data binding are not descriptive at all. Does anybody know how to find real error message instead of "follow-up" error message?
For example I'm getting errors like this:
...\build\generated\source\kapt\debug\com\company\example\DataBinderMapperImpl.java:18: error: cannot find symbol
import com.company.example.databinding.FragmentApplicationDetailsBindingImpl;
^
symbol: class FragmentApplicationDetailsBindingImpl
* What went wrong:
Execution failed for task ':app:kaptDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
> java.lang.reflect.InvocationTargetException (no error message)
Only information I got from this is that error is in FragmentApplicationDetailsBinding or in fragment_application_details.xml layout file respectively.
Error caused the binding file to fail to generate so it's missing obviously. But no information what exactly went wrong during generation of FragmentApplicationDetailsBinding. :(

Try to clean and rebuild the project if its not work go to File->Invalidate caches / restart.

Related

Error showing while I did nothing : Execution failed for task ':app:mergeDebugResources'. ; Caused by: java.lang.NullPointerException

I'm currently creating an application with Android Studio and Kotlin.
This morning, when I tried to run the app on the emulator and my phone, I got an error but what I don't understand it's I barely change the code : I just added a textview (tried to delete it but I still got the error. I tried to investigate and do think but none of them worked. I still don't really understand the error, could you help me fix it ?
Here the error :
Caused by: org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing com.android.build.gradle.internal.res.ResourceCompilerRunnable
Caused by: com.android.aaptcompiler.ResourceCompilationException: Resource compilation failed. Check logs for details.
at com.android.aaptcompiler.ResourceCompiler.compileResource(ResourceCompiler.kt:126)
at com.android.build.gradle.internal.res.ResourceCompilerRunnable$Companion.compileSingleResource(ResourceCompilerRunnable.kt:34)
at com.android.build.gradle.internal.res.ResourceCompilerRunnable.run(ResourceCompilerRunnable.kt:15)
at com.android.build.gradle.internal.profile.ProfileAwareWorkAction.execute(ProfileAwareWorkAction.kt:74)
... 3 more
Caused by: java.lang.NullPointerException
at com.android.aaptcompiler.TableExtractor.flattenXmlSubTree(TableExtractor.kt:851)
at com.android.aaptcompiler.TableExtractor.parseXml(TableExtractor.kt:516)
at com.android.aaptcompiler.TableExtractor.parseArrayImpl(TableExtractor.kt:1300)
at com.android.aaptcompiler.TableExtractor.parseStringArray(TableExtractor.kt:1243)
at com.android.aaptcompiler.TableExtractor.access$parseStringArray(TableExtractor.kt:146)
at com.android.aaptcompiler.TableExtractor$extractResource$parseBagMethod$13.invoke(TableExtractor.kt:437)
at com.android.aaptcompiler.TableExtractor$extractResource$parseBagMethod$13.invoke(TableExtractor.kt:437)
at com.android.aaptcompiler.TableExtractor.extractResource(TableExtractor.kt:458)
at com.android.aaptcompiler.TableExtractor.extractResourceValues(TableExtractor.kt:267)
at com.android.aaptcompiler.TableExtractor.extract(TableExtractor.kt:182)
at com.android.aaptcompiler.ResourceCompiler.compileTable(ResourceCompiler.kt:186)
at com.android.aaptcompiler.ResourceCompiler.access$compileTable(ResourceCompiler.kt:1)
at com.android.aaptcompiler.ResourceCompiler$getCompileMethod$1.invoke(ResourceCompiler.kt:137)
at com.android.aaptcompiler.ResourceCompiler$getCompileMethod$1.invoke(ResourceCompiler.kt:137)
at com.android.aaptcompiler.ResourceCompiler.compileResource(ResourceCompiler.kt:123)
... 29 more
Thanks a lot
EDIT :
So, I've searched a lot, tried many things but none of them worked. Because my project is still small, I created a new project and copy/paste all my code and I this new project everything work and I don't have any error anymore.
Good luck if you encounter the same error.
Just had this error myself and after awhile managed to find the issue, I had strings within array-lists located in my strings.xml, some of my strings included apostrophes, for instance in don't won't can't.
Removing these allowed me to build my project again.
The solution that worked for me is locate the String.xml file. Delete the unused Strings I meant the strings that didnt had any reference in arrayList file.
Make sure gradle offline mode is not enabled.
Then do file->invalidate
then click invalidate and restart.
This should solve the issue

Jenkins - Execution failed for task ':app:mergeDebugResources'

I am trying to work with Jenkins however I cannot build the apk with it as I am having issue with AAPT2 and Gradle.
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.res.Aapt2CompileRunnable
> Android resource compilation failed
ERROR:C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-3\b478eb984dbbd1317dab9bfd9689b3aa\transformed\appcompat-1.3.0\res\drawable-hdpi-v4\abc_list_divider_mtrl_alpha.9.png: AAPT: error: file not found.
> A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
> Android resource compilation failed
ERROR:C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-3\b478eb984dbbd1317dab9bfd9689b3aa\transformed\appcompat-1.3.0\res\drawable-xhdpi-v4\abc_list_divider_mtrl_alpha.9.png: AAPT: error: file not found.
> A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
> Android resource compilation failed
ERROR:C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-3\b478eb984dbbd1317dab9bfd9689b3aa\transformed\appcompat-1.3.0\res\drawable-mdpi-v4\abc_list_divider_mtrl_alpha.9.png: AAPT: error: file not found.
I already read tons of SO question that may share same issue to my case saying that it has something to do with the file path being too long but I still cannot find any solution.
UPDATE
I tried to change Android Studio Gradle home similar to what Jenkins is using and received similar error which indicates that it may really have something to do with long file path.
I think the final question will be how to change Jenkins Gradle Home?
You need to replace \ with \\ if you are giving path with jenkins in Windows.
May be if file path is too huge or that is the root cause you can try mounting the directory to a short path
EDIT : Based on your modified question :
Open Jenkins dashboard. Navigate to Manage Jenkins-> Configure System. Under the Global properties section add another environment variable named GRADLE_USER_HOME as shown below.
I ran into this exact issue, but unfortunately changing the GRADLE_USER_HOME environment variable did not help, as aapt2 appeared to ignore the change and still used Windows/system32/... for the cache location.
The problem was how I was running Jenkins as a service. In the service.msc settings, it was set to Log On as a Local System account, which set the USER_HOME variables to C:\Windows\System32. Because of this, the reason the error said that the file did not exist was because Jenkins/gradle did not have access to the System32 folder.
My fix was to change the log on method to 'This account', then enter a user account so Jenkins wasn't logged on as system anymore.

How to fix Unable to read serialised file fingerprint. Unrecognized value found in the data stream

After my PC went off while I was building the project, I keep having this error Unable to read serialized file fingerprint. Unrecognized value found in the data stream.
When I checked the exception, I saw this
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Could not read entry ':app:mergeDebugResources' from cache executionHistory.bin (/Users/euniceb/my_project/location/.gradle/6.1.1/executionHistory/executionHistory.bin).
While trying to fix this, I saw this question Unable to read serialized file fingerprint. Unrecognized value found in the data stream and tried the solution, but it didn't work for me.
I've tried deleting my cache and .gradle file. I've changed the location of my android project but it still gives the same error.
Please how can I fix this?

Android Studio Issue- Build Failed with an Exception

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
AAPT2 aapt2-3.6.2-6040484-windows Daemon #12: Compile 'C:\Users\Abh\AndroidStudioProjects\MyApplication\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-th\values-th.xml' timed out, attempting to stop daemon.
This should not happen under normal circumstances, please file an issue if it does.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
AAPT2 aapt2-3.6.2-6040484-windows Daemon #9: Compile 'C:\Users\Abh\AndroidStudioProjects\MyApplication\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-en-rAU\values-en-rAU.xml' timed out, attempting to stop daemon.
This should not happen under normal circumstances, please file an issue if it does.
This is the issue, I keep getting whenever I try to run flutter.
Could anyone provide a solution to this...please?
Without seeing the whole picture it is really hard to say, though, according to official documentation About AAPT issue seems to be related to your resource bundle. Check if you are using everything correct links to your resources. I believe issue have occurred in your .xml files values-th and values-en-rAU. It is a good idea if there are some strings marked as translatable check if there are corresponding values in those file

Maximo Anywhere WorkManager build failed

I am try to build android apps but while creating apps my build failed with following errors.
D:\ibm\AnywhereWorkManager\build.xml:87: The following error occurred
while executing this line:
D:\ibm\AnywhereWorkManager\anywhere-apps-builder.xml:720: The
following error occurred while executing this line:
D:\ibm\AnywhereWorkManager\anywhere-apps-builder.xml:716: Failed
building application:
com.worklight.builder.exception.WorklightBuildException:
java.io.IOException: Unable to delete directory
D:\ibm\AnywhereWorkManager\apps\WorkApproval\android\native\assets\www\default\dojo\cldr\nls\zh-hans-mo.
at
org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:551)
I know this answer might seem obvious, but if you have any of the files mentioned in the failure (D:\ibm\AnywhereWorkManager\apps\WorkApproval\android\native\assets\www\default\dojo\cldr\nls\zh-hans-mo)
open ( commandline, eclipse, other editor), this will cause the issue.

Categories

Resources