Hello everyone,
I’m trying to add an icon to my GeoQuiz app like it described in Chapter 2, “Adding an Icon”. But when I’m trying to run my app it fails with error:
It seems that the issue is that I am trying to add attribute iconGravity on Button which doesn’t support it . iconGravity is supported by com.google.android.material.button.MaterialButton so if I want to use iconGravity , I have to use MaterialButton, right?
You do not need to use MaterialButton directly in order to get the functionality of it in your app. I think your problem might be that you do not have the old Material design library in your dependencies. I think you used a different project template than the book when creating your app. Follow the directions here: Material Design
I was using Ladybug 2.1 and the 5th edition of the book. I had this very same iconGravity issue exactly the same as the OP posted. I tried all the possible fix I could found but none fixed.
The exact error I got was
Android resource linking failed
com.bignerdranch.android.geoquiz.app-mergeDebugResources-43:/layout/activity_main.xml:49: error: attribute iconGravity (aka com.bignerdranch.android.geoquiz:iconGravity) not found.
error: failed linking file resources.
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.res.LinkApplicationAndroidResourcesTask$TaskAction
Android resource linking failed
com.bignerdranch.android.geoquiz.app-mergeDebugResources-43:/layout/activity_main.xml:49: error: attribute iconGravity (aka com.bignerdranch.android.geoquiz:iconGravity) not found.
error: failed linking file resources.