-1

I try to compile a sample application with Facebook login button. Application uses AppCompatActivity. The application builds fine with compileSdkVersion 26, 27 but fails with 24. Are there any limits in using older API? This may have something to do with Google announcements https://android-developers.googleblog.com/2017/12/improving-app-security-and-performance.html requiring all new application to target API 26 from August 2018. If targeting API 26 is required, there is no point to provide libraries support for older APIs compiliation... While writing this post I have checked API 25 fails to compile as well with identical errors. My questions: Is it possible to have my app build with compileSdkVersion 24? Is my problem caused by new libraries getting ready to comply with target API >= 26 requirement? Regards, Jacek

compileSdkVersion gives errors like errors like:

/home/jb/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/8d2c125a87d6df61543bb0cc5de9ca22/res/values-v26/values-v26.xml
Error:(9, 5) error: resource android:attr/colorError not found.

Errors point to a resource file

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Base.Theme.AppCompat" parent="Base.V26.Theme.AppCompat"/>
    <style name="Base.Theme.AppCompat.Light" parent="Base.V26.Theme.AppCompat.Light"/>
    <style name="Base.V26.Theme.AppCompat" parent="Base.V23.Theme.AppCompat">
        <!-- We can use the platform styles on API 26+ -->
        <item name="colorError">?android:attr/colorError</item>
    </style>
    <style name="Base.V26.Theme.AppCompat.Light" parent="Base.V23.Theme.AppCompat.Light">
        <!-- We can use the platform styles on API 26+ -->
        <item name="colorError">?android:attr/colorError</item>
    </style>
    <style name="Base.V26.Widget.AppCompat.Toolbar" parent="Base.V7.Widget.AppCompat.Toolbar">
        <item name="android:touchscreenBlocksFocus">true</item>
        <item name="android:keyboardNavigationCluster">true</item>
    </style>
    <style name="Base.Widget.AppCompat.Toolbar" parent="Base.V26.Widget.AppCompat.Toolbar"/>
</resources>

I use imports like below:

import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

import com.facebook.CallbackManager;
import com.facebook.FacebookException;
import com.facebook.login.LoginResult;
import com.facebook.login.widget.LoginButton;

Here is my build.gradle, appcompat commented out or not provides same result.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    defaultConfig {
        applicationId "ijbd.eu.test123"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.facebook.android:facebook-android-sdk:4.31.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
//    implementation 'com.android.support:support-v4:24.2.1'
//    implementation 'com.android.support:appcompat-v7:24.2.1'
//    implementation "com.android.support:support-core-utils:24.2.1"

    //    testCompile 'junit:junit:4.12'
}
Jacek Błocki
  • 452
  • 3
  • 9

1 Answers1

0

The docs of android.R.attr.colorError says "added in API level 26" which means that it does not exist in api-s older than api-26 (i.e. in api-24). You have to compile with api-26 or newer (compileSdkVersion>=26) and you have to make shure that "colorError" is not used if android runtime is older than api-26 (targetSdkVersion)

[update] the errormessage says that "appcompat-v7-27.0.2.aar" uses colorError which is either inside your libs dir or directly referenced in one of your build.gradle files or indirectly referenced by one of your dependencies (i.e. "com.facebook.android:facebook-android-sdk:4.31.0")

k3b
  • 14,517
  • 7
  • 53
  • 85