cardslib error resource android:attr/foregroundInsidePadding is private while targeting SDK 26

Try disabling the AAPT2 by adding android.enableAapt2=false to your gradle.properties file.

Builds may fail while AAPT2 is enabled. Additionally, AAPT2 is currently not compatible with Robelectric. If your build fails due to an AAPT2 resource processing issue or you want to use Roboelectric, you can disable AAPT2 by setting android.enableAapt2=false in your gradle.properties file and restarting the Gradle daemon by running ./gradlew --stop from the command line.

Reference : here

I was using Android studio 3.0 beta 5 In which I disabled the AAPT2 and it resolved my error.

UPDATE: 28 March 2018

With Android Studio 3.1.1 this might not work. One of your library might be using android's private resource. You need to find the error causing library and replace android:attr/foregroundInsidePadding with foregroundInsidePadding and import it to your project.

  1. Clone the library repo in your local.
  2. Open repository in Android Studio find xml having <attr name="android:foregroundInsidePadding" /> and replace it with
    <attr name="foregroundInsidePadding" /> and Build.
  3. Open your project and import that repository as dependency into your project.
  4. Remove library compile statements from app level build.gradle.
  5. Now you might be able to use AAPT2 so try changing android.enableAapt2=false to true in gradle.properties if present.

This is because you shouldn't use the 'android' namespace for this resource. To resolve this issue, replace android:foregroundInsidePadding with foregroundInsidePadding.
More info on the Android Studio AAPT2 migration guide.