[英]Searchable.xml not found on build of instant app
功能部件/src/main/res/xml/searchable.xml :
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/app_name"
android:hint="@string/search_hint" >
<!-- TODO https://developer.android.com/guide/topics/search/searchable-config -->
</searchable>
在构建的即时应用程序中找不到,基本样式中的样式除外。 错误输出行是:
AGPBI: {"kind":"error","text":"error: resource xml/searchable (aka at.mts.arnatomy.app:xml/searchable) not found.","sources":[{"file":"./arnatomy/base/build/intermediates/manifests/full/feature/debug/AndroidManifest.xml","position":{"startLine":53}}],"original":"","tool":"AAPT"}
Feature / src / main / AndroidManifest.xml中的相应操作:
<activity
android:name=".SearchableActivity"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable"/>
</activity>
中相应文本字段的布局为feature / src / main / res / layout / search.xml :
...
<android.support.v7.widget.AppCompatEditText
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/search_hint"
android:imeOptions="actionSearch"
android:inputType="text"
android:layout_weight="1"/>
...
并且feature / src / main / java / SearchableActivity.java的相关代码是:
...
AppCompatEditText text = findViewById(R.id.text);
text.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
boolean handled = false;
if (actionId == EditorInfo.IME_ACTION_SEND) {
doMySearch(v.getText().toString());
handled = true;
}
return handled;
}
});
...
doMySerach方法仅打印Toast。 minSdkVersion是24, target-和compileSdkVersion是27。如何找不到searchable.xml文件? 我也尝试过,但是基本模块中的xml文件夹仍然没有成功。
将xml文件夹移至基本模块并进行干净的重建可以解决该问题。 在即时应用程序中,仅允许将searchable.xml接缝在构建模块中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.