Android Studio Gradle 构建错误:不允许使用字符串类型('activity_horizontal_margin'值)



刚刚下载了Android Studio。逐字遵循本教程。尝试"构建"时不断遇到以下错误,我不知道如何克服它。

Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:compileDebugSources, :app:compileDebugAndroidTestSources, :app:compileDebugUnitTestSources]
C:UsersSVAndroidStudioProjectsToDoAppappbuildintermediatesresmergeddebugvaluesvalues.xml
Error:(872, 69) String types not allowed (at 'activity_horizontal_margin' with value '').
Error:(872, 69) String types not allowed (at 'activity_horizontal_margin' with value '').
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt
Information:BUILD FAILED
Information:Total time: 1.429 secs
Information:3 errors
Information:0 warnings
Information:See complete output in console

values文件夹中创建一个文件,如果您还没有文件,请将其调用dimens.xml。然后在其中添加以下代码:

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

最新更新