Reputation: 43
I tried turning off AAPT2 but it didn't work. Below is the log.
Build: build failed 5s 44ms Run build 4s 889ms Load build 47ms Run init scripts 43ms Evaluate settings 2ms Configure build 776ms Calculate task graph 2s 211ms Run tasks 1s 839ms null
/Users/dt/AndroidStudioProjects/HappyBirthday app/src/main/res/layout/activity_main.xml error: resource dimen/activity_vertical_margin (aka com.example.android.happybirthday:dimen/activity_vertical_margin) not found. error: resource dimen/activity_horizontal_margin (aka com.example.android.happybirthday:dimen/activity_horizontal_margin) not found. null failed linking file resources.
Upvotes: 5
Views: 10635
Reputation: 1
I did a lot of research and this is what I found. Sometimes the problem is in the XML files when you're referring to a resource that Android Studio doesn't know where to find. In my case I was trying to set the color of an item using android:background="?attr/colorPrimary"
instead of android:background="@color/colorPrimary"
.
Also, in some cases if you're trying to get the dimension of the action bar like so android:height="?attr/actionBarSize"
it will result in the exception you mentioned. To get rid of it you should use android:height="?android:attr/actionBarSize"
. So make sure to check all recently modified XML files for these types of mistakes.
Upvotes: 0
Reputation: 1176
check your XML files for errors, there could be an error in
dimen
it says that
dimen/activity_vertical_margin
not found.
Upvotes: 0
Reputation: 7557
It is due some error on xml file. If you using kotlin its very hard find xml errors and it result causes simply build failures and no proper error log generated. Try below commands in android studio terminal and it will give where the error occurs exactly.
> ./gradlew clean
> ./gradlew assemble
Upvotes: 3
Reputation: 126445
After upgrading Android Studio you must invalidate caché and restart Android Studio
File
> Invalidate Cache / Restart
Upvotes: 6
Reputation: 43
I solved it just by reinstalling Android Studio 3.1. Thanks for your suggestions.
Upvotes: -2