1

When in my project I wanted to add swipe views material design sliding tabs. I am getting following error

Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72220Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72221Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42221Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources
C:\Users\saidur\AndroidStudioProjects\IELTS Writing_New\app\src\main\res\layout\activity_main.xml
Error:(27, 34) No resource found that matches the given name (at 'background' with value '@color/ColorPrimary').
Error:Execution failed for task ':app:processDebugResources'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\saidur\AppData\Local\Android\sdk\build-tools\22.0.1\aapt.exe'' finished with non-zero exit value 1
Information:BUILD FAILED
Information:Total time: 4.342 secs
Information:2 errors
Information:0 warnings
Information:See complete output in console

I have tried many solutions of below link's. But it did not work for me. appcompat-v7:21.0.0': No resource found that matches the given name: attr 'android:actionModeShareDrawable'

My activity_main.xml are follows:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:layout_weight="1">
    </android.support.v4.view.ViewPager>

    <me.saidur.ieltswriting.SlidingTabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:elevation="2dp"
        android:background="@color/ColorPrimary" />

    <LinearLayout
        android:id="@+id/container_toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <include
            android:id="@+id/toolbar"
            layout="@layout/toolbar" />
    </LinearLayout>

    <FrameLayout
        android:id="@+id/container_body"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />


</LinearLayout>


<fragment
    android:id="@+id/fragment_navigation_drawer"
    android:name="me.saidur.ieltswriting.activity.FragmentDrawer"
    android:layout_width="@dimen/nav_drawer_width"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    app:layout="@layout/fragment_navigation_drawer"
    tools:layout="@layout/fragment_navigation_drawer" />

Community
  • 1
  • 1
Saidur Rahman
  • 546
  • 2
  • 4
  • 20

2 Answers2

3

No resource found that matches the given name (at 'background' with value '@color/ColorPrimary'). Error:Execution failed for task ':app:processDebugResources'.

Problem is here

android:background="@color/ColorPrimary"

You can use this

<me.saidur.ieltswriting.SlidingTabLayout
    android:id="@+id/tabs"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:elevation="2dp"
    android:background="#54D66A" /> // set your own color code .

or create xml name colors.xml under values folder .

 <?xml version="1.0" encoding="utf-8"?>
<resources>

    <color name="colorprimary">#ff3333</color>

</resources>

Then

<me.saidur.ieltswriting.SlidingTabLayout
    android:id="@+id/tabs"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:elevation="2dp"
    android:background="@color/colorprimary" />
Nilpo
  • 4,675
  • 1
  • 25
  • 39
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
0

add your color attribute to your colors.xml in your values folder

<color name="colorPrimary">#679a01</color>

OR

Simply set a background color for your layout

 <me.saidur.ieltswriting.SlidingTabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:elevation="2dp"
        android:background="#FF4081" />
Mr Robot
  • 1,747
  • 6
  • 35
  • 67