1

The feature/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>

is not found in my instant app on the build, nothing is in the base module except the styles. Error output line is:

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"}

The corresponding action in the 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>

The layout of the corresponding text field in is 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"/>
...

And the related code of the feature/src/main/java/SearchableActivity.java is:

...
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;
            }
        });
...

where the method doMySerach just prints a Toast. minSdkVersion is 24 and target- as well as compileSdkVersion are 27. How can the searchable.xml file be not found? I also tried to but the xml folder in the base module, still no success.

ManuelTS
  • 316
  • 4
  • 14

1 Answers1

0

Moving the xml folder into the base module and doing a clean rebuild solves the problem. In an instant app the searchable.xml seams to be only allowed to be in the build module.

ManuelTS
  • 316
  • 4
  • 14
  • anything referenced in your manifest must exist in the base module, please see https://stackoverflow.com/a/44928134/6668797 – TWL Jul 09 '18 at 15:39
  • Never read that on the docs of android.com, thanks for your explanation. – ManuelTS Jul 11 '18 at 05:54