[英]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 ''). 错误:(703,69)不允许使用字符串类型(在“ imageViewScramble”中,值为“”)。 Error:(703, 69) String types not allowed (at 'imageViewScramble' with value '').
错误:(703,69)不允许使用字符串类型(在“ imageViewScramble”中,值为“”)。 Error:Execution failed for task ':app:processDebugResources'.
错误:任务':app:processDebugResources'的执行失败。
com.android.ide.common.process.ProcessException: Failed to execute aapt.
com.android.ide.common.process.ProcessException:无法执行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. 奇怪的是,现在我删除了imageViewScramble,它甚至不在我的activity_main.xml文件中。 I tried adding a drawable resource to this ImageView, so that could be the problem.
我尝试将可绘制资源添加到此ImageView,所以可能是问题所在。
Here is my XML file: 这是我的XML文件:
<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". 另外,它还给我另一个错误:无法解析符号“ R”。
I fix a similar issue: searching (CTRL + SHIFT + F) for the literal value that is mentioned in the message eg: 'imageViewScramble' . 我修复了一个类似的问题:搜索(CTRL + SHIFT + F)查找消息中提到的文字值,例如: 'imageViewScramble' 。
In the result I went to the dimens.xml file where was located the match and I found an inconsistency in the value. 结果,我转到了匹配项所在的dimens.xml文件,发现值不一致。
Eg: 5dp 5dp 例如:5dp 5dp
So replacing the line with the mentioned by 5dp 所以用5dp替换上面提到的行
Fix the issue. 解决该问题。
Thanks for read. 感谢您的阅读。
Ok, I fixed it by removing file at res/refs.xml which got name imageViewScramble in it. 好的,我通过删除res / refs.xml中名为imageViewScramble的文件来修复它。 From what I've heard, this problems mostly occurs because of xml errors.
据我所知,这个问题主要是由于xml错误而发生的。 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 . 要修复此错误,请转到goto res / value,然后删除dimens.xml。 it worked for me
它对我有用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.