简体   繁体   中英

Error:(453, 69) String types not allowed (at 'activity_horizontal_margin' with value '')

Hi i have encountered a problem while remaking a code. This code was previously working until i messed it up by attempting to change the theme of the app. Basically there are 3 problems (Shown Below) 1. In values.xml i get an error Error:(453, 69) String types not allowed (at 'activity_horizontal_margin' with value ''). . here is the block that gives me the problem (the parent="" is where the problem occurs)

<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>
  1. My second problem is this and it occurs when i try to clean and/or rebuild the build. Error:Execution failed for task ':app:processDebugResources'.

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

  2. The R in R.id cannot be recognized. In exact words "cannot resolve symbol 'R'". Again, this code was working prior to messing around with the theme and theme editor + some updates.

Help would be greatly appreciated.

EDIT: I'm updating this about a year after I solved the issue (Sorry for that if anyone was following). But long story short, I couldn't find the solution; I just ended up restarting the project as it was relatively in its early stages --Not ideal, I know.

In dimensions you kept the data as shown below

instead of this just keep the data as shown below.According to my knowledge it will work 16dp 16dp

I know this question is pretty old but I just had the same problem and found the solution that at least worked for me so I share it: indeed, it's not the file values.xml that you have to modify (besides you can't as it regenerates itself as already said) but the file that has been generated in your own ressources (res). For me it was dimens.xml. I deleted the file and then I could clean and rebuild without issues. Hope it will help someone ...someday :)

I just faced same problem , and resolved by simple task

that is Don't change the system build-ed code in .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:layout_width="match_parent" /* dont change this match_parent
android:layout_height="match_parent" /* dont change this match_parent
tools:context="com.example.suresh.myapplication.MainActivity">

Although This is an older post but I have seen that no one had pointed the right way to go about this error.

Here's how you can go about solving this.

First read where it is saying the error is? It could happen for a variety of resons. But the main thing is you must have something that is not as desired like in this particular problem you should look into your dimens.xml file and you will have a tag with the name specified in the error and you will be able to see that there is nothing except the tag and the name like given below.

<dimen name="activity_horizontal_margin"/>

This is incomplete it should be in the form of.

<dimen name="activity_horizontal_margin">20dp</dimen>

The main point here is you have to have all valid values in your xml files. Then the generated values.xml file will be right otherwise it will be wrong and the project won't be built.

Please go through your xmls carefully.

you need to add your parent theme name in parent ="" . If the name is AppTheme(most probably) then do this and clean - rebuild project.

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

Let me know if it changes anything for you. Your other errors should be resolved by resolving this one.

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