简体   繁体   中英

Android - Error:String types not allowed (at 'imageViewScramble' with value '')

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

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: 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>

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.

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>

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

I fix a similar issue: searching (CTRL + SHIFT + F) for the literal value that is mentioned in the message eg: 'imageViewScramble' .

In the result I went to the dimens.xml file where was located the match and I found an inconsistency in the value.

Eg: 5dp 5dp

So replacing the line with the mentioned by 5dp

Fix the issue.

Thanks for read.

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.

for fixing this error goto res/value then delete the dimens.xml . it worked for me

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM