Android无法找到依赖资源

时间:2019-12-04 01:09:51

标签: android android-layout gradle android-resources

我正在尝试向项目中添加dependency并继续运行:

C:\AndroidApp\app\src\main\res\layout\activity_main.xml:17: AAPT: error: resource style/MaterialSearchViewStyle (aka com.my.project:style/MaterialSearchViewStyle) not found.

activity_main.xml 来自here;按钮已删除:

<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"
    android:layout_height="match_parent"
    android:background="@color/white"
    tools:context=".view.MainActivity">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="#607D8B"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

    <br.com.mauker.materialsearchview.MaterialSearchView
        android:id="@+id/search_view"
        style="@style/MaterialSearchViewStyle"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:voiceIconEnabled="true" />

</RelativeLayout>

现在,在构建时,android进入styles.xml并抱怨找不到 MaterialSearchViewStyle 。但是“ MaterialSearch”已经被导入并添加为依赖项:

dependencies {
    ...
    // material search view
    implementation 'br.com.mauker.materialsearchview:materialsearchview:1.2.3'
}

在向资源/值添加 styles.xml 后:

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
        <!-- Customize your theme here. -->
    </style>

    <style name="MaterialSearchViewStyle">
        <item name="searchBackground">@color/white_ish</item>
        <item name="searchVoiceIcon">@drawable/ic_action_voice_search</item>
        <item name="searchCloseIcon">@drawable/ic_action_navigation_close</item>
        <item name="searchBackIcon">@drawable/ic_action_navigation_arrow_back</item>
        <item name="searchSuggestionBackground">@color/search_layover_bg</item>
        <item name="historyIcon">@drawable/ic_history_white</item>
        <item name="suggestionIcon">@drawable/ic_action_search_white</item>
        <item name="listTextColor">@color/white_ish</item>
        <item name="searchBarHeight">?attr/actionBarSize</item>
        <item name="voiceHintPrompt">@string/hint_prompt</item>
        <item name="android:textColor">@color/black</item>
        <item name="android:textColorHint">@color/gray_50</item>
        <item name="android:hint">@string/search_hint</item>
        <item name="android:inputType">textCapWords</item>
    </style>

</resources>

在android studio中一切看起来都正常(图标/颜色显示在左窗格中)。但是,样式路径指向gradle缓存(而不是local(project)定义的样式?)。

如何使android使用缓存中的资源,而不是尝试加载本地资源并抛出 AAPT:错误:未找到资源。似乎在构建过程中寻找了错误的软件包。

0 个答案:

没有答案