Android - 错误:不允许字符串类型(在值为 ''的'imageViewScramble' 处) [英] Android - Error:String types not allowed (at 'imageViewScramble' with value '')

查看:42
本文介绍了Android - 错误:不允许字符串类型(在值为 ''的'imageViewScramble' 处)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的遇到了这个问题,我尝试在互联网上搜索但没有找到类似的内容.

I'm really having trouble with this one, I tried searching on the internet but didn't find anything similar.

当我尝试构建我的应用程序时,它给了我这个错误

When I try to build my app, it gives my this error

C:\Users\Tom\AndroidStudioProjects\Timer++\app\build\intermediates\res\merged\debug\values\values.xml

错误:(703, 69) 不允许字符串类型(在imageViewScramble",值为").错误:(703, 69) 不允许字符串类型(在值为 '' 的 'imageViewScramble' 处).错误:任务:app:processDebugResources"执行失败.

Error:(703, 69) String types not allowed (at 'imageViewScramble' with value ''). Error:(703, 69) String types not allowed (at 'imageViewScramble' with value ''). Error:Execution failed for task ':app:processDebugResources'.

com.android.ide.common.process.ProcessException:无法执行 aapt.

com.android.ide.common.process.ProcessException: Failed to execute aapt.

当我跳转到源时,它指向我:

When i jump to source it points me at this:

<style name="Base.TextAppearance.AppCompat.SearchResult" parent="">
    <item name="android:textStyle">normal</item>
    <item name="android:textColor">?android:textColorPrimary</item>
    <item name="android:textColorHint">?android:textColorHint</item>
</style>

奇怪的是,现在我删除了那个 imageViewScramble 甚至不在我的 activity_main.xml 文件中.我尝试向这个 ImageView 添加一个可绘制资源,所以这可能是问题所在.

The strange thing is, that imageViewScramble isn't even in my activity_main.xml file now that I removed it. I tried adding a drawable resource to this ImageView, so that could be the problem.

这是我的 XML 文件:

Here is my XML file:

<xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.tom.timer.MainActivity">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay"
    android:id="@+id/appBarLayout">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbarMainSession"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"

        android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
        android:layout_gravity="top">
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="?attr/actionBarSize"
        android:orientation="horizontal"
        android:showDividers="end">

        <Button
            android:text="Settings"
            android:layout_width="0dp"
            android:layout_height="?attr/actionBarSize"
            android:id="@+id/buttonDNF"
            android:layout_gravity="start"
            android:layout_weight="1"
            android:background="@color/colorPrimary"/>

        <Button
            android:text="Session"
            android:layout_width="0dp"
            android:layout_height="?attr/actionBarSize"
            android:id="@+id/buttonToSession"
            android:layout_gravity="end"
            android:layout_weight="1"
            android:background="@color/colorPrimary"/>

    </LinearLayout>
    </android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>

<TextView
    android:text="Scramble"
    android:layout_width="fill_parent"
    android:layout_height="350dp"
    android:textAlignment="center"
    android:id="@+id/textViewScramble"
    android:textSize="30sp"
    android:textColor="@color/colorText"
    android:gravity="center"
    android:layout_alignParentTop="true"
    android:layout_alignParentStart="true"
    android:layout_marginTop="75dp"
    android:layout_above="@+id/textViewTimer" />

<TextView
    android:text="0"
    android:layout_width="fill_parent"
    android:layout_height="100dp"
    android:textSize="90sp"
    android:textColor="@color/colorText"
    android:textAlignment="center"
    android:textStyle="bold"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true"
    android:id="@+id/textViewTimer" />

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbarDown"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    android:elevation="4dp"
    android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
    android:layout_gravity="bottom"
    android:layout_alignParentBottom="true"
    android:layout_alignParentStart="true">

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="?attr/actionBarSize"
        android:orientation="horizontal"
        android:showDividers="end"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true">

        <Button
            android:text="Draw Scramble"
            android:layout_width="0dp"
            android:layout_height="?attr/actionBarSize"
            android:id="@+id/buttonDraw"
            android:layout_gravity="start"
            android:layout_weight="1"
            android:background="@color/colorPrimary"/>

        <Button
            android:text="Choose Puzzle"
            android:layout_width="0dp"
            android:layout_height="?attr/actionBarSize"
            android:id="@+id/buttonChoosePuzzle"
            android:layout_gravity="end"
            android:layout_weight="1"
            android:background="@color/colorPrimary"/>

    </LinearLayout>
</android.support.v7.widget.Toolbar>

另外,它给了我另一个错误:无法解析符号R".

Also, it gives me another error: Can't resolve symbol "R".

推荐答案

好的,我通过删除 res/refs.xml 中的文件来修复它,其中文件名为 imageViewScramble.据我所知,这个问题主要是由于 xml 错误造成的.有时可能会因为使用旧的构建工具而发生.有时清理/重建可能会奏效.

Ok, I fixed it by removing file at res/refs.xml which got name imageViewScramble in it. From what I've heard, this problems mostly occurs because of xml errors. Sometimes it may happen because of using old build tools. Sometimes clean/rebuild might just work.

这篇关于Android - 错误:不允许字符串类型(在值为 ''的'imageViewScramble' 处)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆