Eibi
Eibi

Reputation: 400

Why do I get: "preserveIconSpacing is private" error

I took an old android project of mine, that was developed on eclipse Luna few years back and tried to revive it.

I have imported it into android studio which I was told can convert it into it's own format and I would be able to continue working on.

After going threw all the initial linking and versions compatibility errors, I got stuck on the following error and cannot get passed it:

c:\....\MyProjectFolder\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:643: error: resource android:attr/preserveIconSpacing is private.

Any way around this or is it a legit error?

Here is my build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "28.0.3"

    defaultConfig {
        applicationId "com.eibimalul.smartgallery"
        minSdkVersion 16
        targetSdkVersion 22
    }

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

dependencies {
    compile 'com.android.support:gridlayout-v7:19.1.0'
    compile 'com.android.support:appcompat-v7:19.1.0'
    compile files('libs/robobinding-0.8.3-jar-with-dependencies.jar')
    compile files('libs/simple-xml-2.7.1.jar')
    compile files('libs/universal-image-loader-1.9.2.jar')
}

Just to clear the solution: The solution for that error with the great help of the answer of Mohsen bellow was:

  1. I have changed the build.gradle content following Mohsen's answer bellow, updating old dependencies and changing compile to implementation - error is gone.
  2. I have followed the solution here to eliminate the second error I have got (resource integer/google_play_services_version) - see bellow.

I now have a third error but it seems not related to the first one, so I believe the main issue was resolved.

Upvotes: 4

Views: 3872

Answers (1)

ʍѳђઽ૯ท
ʍѳђઽ૯ท

Reputation: 16976

values.xml:643: error: resource android:attr/preserveIconSpacing is private.

You are using a private resource that's why this issue came up.

Commenting that line or removing it will help to proceed.


Update: Here is the changed build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.3"

    defaultConfig {
        applicationId "com.eibimalul.smartgallery"
        minSdkVersion 16
        targetSdkVersion 28
    }

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

dependencies {
    implementation 'com.android.support:gridlayout-v7:28.0.0'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation files('libs/robobinding-0.8.3-jar-with-dependencies.jar')
    implementation files('libs/simple-xml-2.7.1.jar')
    implementation files('libs/universal-image-loader-1.9.2.jar')
}

I simply changed the versions of the appcompat and compileSdkVersion and etc in order to update them. Also, if this didn't help, since those libraries are old enough (Date(Jul 08, 2013) e.g.) perhaps you should replace them with the newest dependencies.

For example, add:

implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'

Instead of compile files('libs/universal-image-loader-1.9.2.jar') since it can download the libraries from online repositories and you don't need to add them manually.

Also use implementation instead of compile.

If the error still show up, check this link and add the simple-xml that way: https://stackoverflow.com/a/19455878/4409113

Upvotes: 4

Related Questions