android:onClickListener not found - android

I'm reading the next book "Exploring Android" Version 0.7 https://commonsware.com/AndExplore/
and its Android sample project uses Data Binding library
So there is one layout and it contains line android:onClickListener="#{(v) -> holder.onRowClick.invoke(model)}">:
<androidx.constraintlayout.widget.ConstraintLayout
android:onClickListener="#{(v) -> holder.onRowClick.invoke(model)"
android:layout_width="match_parent"
android:layout_height="wrap_content">
But it won't compile.
* 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
res\layout\todo_row.xml:13: AAPT: error: attribute android:onClickListener not found.
But some of such listeners works, e.g. android:onCheckedChanged, though Android Studio shows a warning:
I don't really like all this (lambdas, functions in xml) but it seems Android allows some of that and it can be used for writing MVVM based app
So why does android:onCheckedChanged work and for android:onClickListener I get "not found" error?

you miss } in the end.
should be
android:onClickListener="#{(v) -> holder.onRowClick.invoke(model)}"

You should try android:onClick="#{(v) -> holder.onRowClick.invoke(model)" instead of android:onClickListener="#{(v) -> holder.onRowClick.invoke(model)"

Related

Message: Attribute "xmlns:android" was already specified for element "LinearLayout"

After trying many solution on web I didn't find solution to this problem.
> Task :app:mergeDebugResources FAILED
Execution failed for task ':app:mergeDebugResources'.
> A failure occurred while executing
com.android.build.gradle.internal.res.ResourceCompilerRunnable
> Resource compilation failed. Check logs for details.
ParseError at [row,col]:[13,192]
Message: Attribute "xmlns:android" was already specified for element "LinearLayout".
My xml Linearlayout is not having "xmlns:android" attributes. Still it keep asking for the same.
Thanks in advance!
"xmlns:android" You have this line added twice in your code in LinearLayout. Also, Try Invalidate & Cache Restart and then run the code.

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.

Error implementing react-native-story-share

I'm trying to share imagens from my react native app which is running at v 0.61.5 to instagram stories. To do so I'm using react-native-story-share library at version ^0.4.0.
I have done the whole implementation of the library, which is showing me some erros. I thought at first that the errors where related to the implementation of the lib it self, but when I delete the implementations and execute react-native run-android it shows following error:
Could not determine the dependencies of task ':app:preDebugBuild'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
> Could not find com.snapchat.kit.sdk:creative:1.1.4.
If I dont delete the implementation process, following error appears:
Execution failed for task ':app:generateDebugBuildConfig'.
> org.xml.sax.SAXParseException; systemId: file:/C:/Users/.../android/app/src/main/AndroidManifest.xml; lineNumber: 17; columnNumber: 11; O atributo "name" vinculado ao namespace "http://schemas.android.com/apk/res/android" j� foi especificado para o elemento "meta-data".
That may occur because I already use metadata name for facebook, when not using the suggested metadata from the lib, following error occurs:
What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [com.snapchat.kit.sdk:creative:1.1.4]
Im dealing with these 3 erros but im clueless when dealing with it. I tried opening snapchat documentation, but couldnt find anything there related to this problem aswell. There is also nothing related to this kind of problem at the documentation of the lib

Nativescript build failed

I'm trying to get my app on an android device. When I run
tns run android
I get this error :
/Users/coreelements/Projects/nativescript/myapp/platforms/android/app/build/intermediates/manifests/full/debug/AndroidManifest.xml:32: AAPT: error: resource
drawable/icon (aka nl.coreelements.myapp:drawable/icon) not found.FAILURE: Build failed with an exception.* What went wrong:
Execution failed for task ':app:processDebugResources'.
Failed to process resources, see aapt output above for details.
I've already tried regenerating the app and splashes :
tns resources generate icons src/images/appicon.png
tns resources generate splashes src/images/appicon.png
What am I missing? I've also tried to buid/run in App Studio.
Just wrapping up the answer from #fransyozef:
App_Resources/Android/src/main/AndroidManifest.xml should point to the right drawable, in this case replacing android:icon="#drawable/icon" with android:icon="#drawable/appicon" solved the issue.
The solution above did not work for me, what did work is change
android:icon="#drawable/icon" to android:icon="#drawable/fileName", so replace /icon with /fileName of the image that is stored there.

Android studio has stopped my project with an error execution failed for task ':app:buildInfoDebugLoader'

I run my android project, everything is correct and an error comes to say execution failed for task as shown on details.
Details :
Error:Execution failed for task ':app:buildInfoDebugLoader'. > Exception while doing past iteration backup : Source C:\Users\Abdulwahid\AndroidStudioProjects\More1Activity\app\build\intermediates\builds\debug\13727462725703\classes.dex and destination C:\Users\Abdulwahid\AndroidStudioProjects\More1Activity\app\build\intermediates\builds\debug\13727462725703\classes.dex must be different
It just need to rebuild the project.

Categories

Resources