11

I am having an issue with building new projects on android studio. I keep on getting the error:

Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed
     AAPT: error: failed writing to 'D:\Libraries\Documents\AndroidStudio\SocketTest\app\build\intermediates\runtime_symbol_list\debug\R.txt': The data is invalid. (13).

Here is my project build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion "29.0.2"

    defaultConfig {
        applicationId "com.example.sockettest"
        minSdkVersion 26
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility = 1.8
        targetCompatibility = 1.8
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

This problem only occurs on new projects I try to build and isn't an issue on older ones. I have read through R.txt': The data is invalid. (13) which leads to Long package name build error in Android Studio which still does not solve the problem.

I only encounter this issue while using windows 10 (update 1909), and not while using android studio on ubuntu. I am running android studio version 3.6.2

Alexander Laevens
  • 111
  • 1
  • 1
  • 4

6 Answers6

30

I know this is a year late but could it be an antivirus blocking it? This is what Avast came up with:

enter image description here

m4n0
  • 29,823
  • 27
  • 76
  • 89
Houston Austin
  • 413
  • 4
  • 4
10

In case someone new to android studios like me does not know how to downgrade Gradle and plugin, here's how (windows):

  1. Select File>Project Structure.
  2. Type in (3.6.3) the Android Gradle Plugin Version.
  3. Type/select (6.0) from dropdown menu the Gradle Version.
  4. Hit OK to Save.

Android Studios will download and set up the new Gradle for the current project. This resolved the data is invalid error for me.

Storytellerr
  • 642
  • 3
  • 18
Rahul K.
  • 111
  • 1
  • 7
1

Was getting the same error. I realized it had something to do with the Gradle version I was running, even though I usually stick to the stable channel of releases. I ended up downgrading to plugin version: 3.6.3 & Gradle version 6.0. I had previously been on plugin version 4.0.0 & Gradle version 6.1.1.

I don't know if this was for sure the same issue, this was happening to any projects on my Win10 PC (ver 2004) that were running that Gradle version.

Benjamin S
  • 575
  • 1
  • 7
  • 21
1

Please follow this :

Uninstall your System(Windows OS)anti virus and most probably it will work.

Maddy Sharma
  • 4,870
  • 2
  • 34
  • 40
1

I already solved by adding this in my dependency

implementation 'com.android.support:design:28.+'
argaw heye
  • 11
  • 2
0

I had a similar issue trying to build an ionic capacitor app with android studio. I later discovered that one of the directories' names in the project's path has space in the name. I just copied the project into another directory to form a path that has no space and recompiled the project and the error vernished.

Dharman
  • 30,962
  • 25
  • 85
  • 135