android资源加载失败

时间:2019-03-03 14:40:17

标签: android android-layout android-gradle android-resources

Android resource linking failed
/Users/suhaibaskar/Downloads/AndroidStudioProjects#Sqlite/app/src/main/res/layout/activity_main.xml:1: error: resource dimen/activity_vertical_margin (aka com.example.myapplication:dimen/activity_vertical_margin) not found.

/Users/suhaibaskar/Downloads/AndroidStudioProjects#Sqlite/app/src/main/res/layout/activity_main.xml:1: error: resource dimen/activity_horizontal_margin (aka com.example.myapplication:dimen/activity_horizontal_margin) not found.  

/Users/suhaibaskar/Downloads/AndroidStudioProjects#Sqlite/app/src/main/res/layout/activity_main.xml:1: error: resource dimen/activity_horizontal_margin (aka com.example.myapplication:dimen/activity_horizontal_margin) not found.  

/Users/suhaibaskar/Downloads/AndroidStudioProjects#Sqlite/app/src/main/res/layout/activity_main.xml:1: error: resource dimen/activity_vertical_margin (aka com.example.myapplication:dimen/activity_vertical_margin) not found.
error: failed linking file resources.

1 个答案:

答案 0 :(得分:0)

错误:链接文件资源失败。由于缺少dimen文件而发生此错误

首先在值包中创建dimen文件 请按照以下步骤创建dimen文件:

路径

右键单击值>新建>值资源文件>设置名称(尺寸),然后按确定

像这样在dimen文件中添加dimen

<resources>
<dimen name="fab_margin">16dp</dimen>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="nav_header_vertical_spacing">8dp</dimen>
<dimen name="nav_header_height">176dp</dimen>
</resources>

希望它对您有用