Error:(8, 30) String types not allowed (at 'description' with value 'Public Albums of this username will be fetched')
Error:(8, 30) String types not allowed (at 'description' with value 'Public Albums of this username will be fetched')
我正在尝试在我的应用程序中配置 restrictions,但出现以下错误
Error:(8, 30) String types not allowed (at 'description' with value 'Public Albums of this username will be fetched').
Error:Execution failed for task ':app:processDebugResources'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\athakur\Softwares\adt-bundle-windows-x86_64-20140702\sdk\build-tools.0.1\aapt.exe'' finished with non-zero exit value 1
我的app_restriction.xml如下-
<?xml version="1.0" encoding="utf-8"?>
<restrictions xmlns:android="http://schemas.android.com/apk/res/android" >
<restriction
android:key="google_username"
android:title="Google Username"
android:restrictionType="string"
android:description="Public Albums of this username will be fetched"
android:defaultValue="opensourceforgeeks" />
</restrictions>
如果我删除说明,它就可以正常工作。我使用了与 android dev page 中指定的语法相同的语法,即
<?xml version="1.0" encoding="utf-8"?>
<restrictions xmlns:android="http://schemas.android.com/apk/res/android" >
<restriction
android:key="downloadOnCellular"
android:title="App is allowed to download data via cellular"
android:restrictionType="bool"
android:description="If 'false', app can only download data via Wi-Fi"
android:defaultValue="true" />
</restrictions>
不确定我错过了什么。感谢任何帮助。
限制元素的描述值必须是字符串资源,如文档所述here。因此,提取硬编码文本将修复构建。
正如@fractalwrench 正确指出的那样,描述属性只能指向资源[this documentation example 具有误导性。不允许纯文本。
public static final int RestrictionEntry_description
Must be a reference to another resource, in the form "@[+][package:]type:name" or to a theme attribute in the form "?[package:][type:]name".
This corresponds to the global attribute resource symbol description.
Constant Value: 0 (0x00000000)
以下对我有用
<restriction
android:key="google_username"
android:title="Google Username"
android:restrictionType="string"
android:description="@string/rest_uname_desc"
android:defaultValue="opensourceforgeeks" />
和
<string name="rest_uname_desc">Public Albums of this username will be fetched</string>
在string.xml
我正在尝试在我的应用程序中配置 restrictions,但出现以下错误
Error:(8, 30) String types not allowed (at 'description' with value 'Public Albums of this username will be fetched'). Error:Execution failed for task ':app:processDebugResources'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\athakur\Softwares\adt-bundle-windows-x86_64-20140702\sdk\build-tools.0.1\aapt.exe'' finished with non-zero exit value 1
我的app_restriction.xml如下-
<?xml version="1.0" encoding="utf-8"?>
<restrictions xmlns:android="http://schemas.android.com/apk/res/android" >
<restriction
android:key="google_username"
android:title="Google Username"
android:restrictionType="string"
android:description="Public Albums of this username will be fetched"
android:defaultValue="opensourceforgeeks" />
</restrictions>
如果我删除说明,它就可以正常工作。我使用了与 android dev page 中指定的语法相同的语法,即
<?xml version="1.0" encoding="utf-8"?>
<restrictions xmlns:android="http://schemas.android.com/apk/res/android" >
<restriction
android:key="downloadOnCellular"
android:title="App is allowed to download data via cellular"
android:restrictionType="bool"
android:description="If 'false', app can only download data via Wi-Fi"
android:defaultValue="true" />
</restrictions>
不确定我错过了什么。感谢任何帮助。
限制元素的描述值必须是字符串资源,如文档所述here。因此,提取硬编码文本将修复构建。
正如@fractalwrench 正确指出的那样,描述属性只能指向资源[this documentation example 具有误导性。不允许纯文本。
public static final int RestrictionEntry_description
Must be a reference to another resource, in the form "@[+][package:]type:name" or to a theme attribute in the form "?[package:][type:]name".
This corresponds to the global attribute resource symbol description. Constant Value: 0 (0x00000000)
以下对我有用
<restriction
android:key="google_username"
android:title="Google Username"
android:restrictionType="string"
android:description="@string/rest_uname_desc"
android:defaultValue="opensourceforgeeks" />
和
<string name="rest_uname_desc">Public Albums of this username will be fetched</string>
在string.xml