32

I've been developing a Linphone application but got stuck in below point. I've changed the app name and refactored all relative packages. The application was ok until I upgraded gradle to 3.0.0.

AGPBI: {"kind":"error","text":"error: resource android:attr/fontStyle not found.","sources":[{"file":"~/.gradle/caches/transforms-1/files-1.1/support-compat-27.0.0.aar/61646c6d4479aff22f7047873e2edd7d/res/values/values.xml","position":{"startLine":20,"startColumn":4,"startOffset":1254,"endColumn":69,"endOffset":1319}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: resource android:attr/font not found.","sources":[{"file":"~/.gradle/caches/transforms-1/files-1.1/support-compat-27.0.0.aar/61646c6d4479aff22f7047873e2edd7d/res/values/values.xml","position":{"startLine":20,"startColumn":4,"startOffset":1254,"endColumn":69,"endOffset":1319}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: resource android:attr/fontWeight not found.","sources":[{"file":"~/.gradle/caches/transforms-1/files-1.1/support-compat-27.0.0.aar/61646c6d4479aff22f7047873e2edd7d/res/values/values.xml","position":{"startLine":20,"startColumn":4,"startOffset":1254,"endColumn":69,"endOffset":1319}}],"original":"","tool":"AAPT"}
~/app-name/bin/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:149: error: resource android:attr/fontStyle not found.
~/appname/bin/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:149: error: resource android:attr/font not found.
~/appname/bin/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:149: error: resource android:attr/fontWeight not found.
error: failed linking references.

I've read other questions about unabling to find attribute error but could not find an answer. I've tried below methods but none of them worked:

  1. delete bin/ directory of the app
  2. clean cache and rebuild the app again
  3. Invalidate cache and restart (every options in it)
  4. Changing sdk version (api)
  5. multiDexEnabled true/false

Below is detail log :

Failed to execute aapt
com.android.ide.common.process.ProcessException: Failed to execute aapt
    at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:793)
    at com.android.build.gradle.tasks.ProcessAndroidResources.invokeAaptForSplit(ProcessAndroidResources.java:566)
    at com.android.build.gradle.tasks.ProcessAndroidResources.doFullTaskAction(ProcessAndroidResources.java:293)
    at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:109)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:173)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
    at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
    at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:482)
    at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
    at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:791)
    ... 48 more
Caused by: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
    at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
    at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:462)
    at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
    at com.android.builder.internal.aapt.v2.QueueableAapt2.lambda$makeValidatedPackage$1(QueueableAapt2.java:179)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    ... 1 more
Caused by: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
    at com.android.builder.png.AaptProcess$NotifierProcessOutput.handleOutput(AaptProcess.java:454)
    at com.android.builder.png.AaptProcess$NotifierProcessOutput.err(AaptProcess.java:411)
    at com.android.builder.png.AaptProcess$ProcessOutputFacade.err(AaptProcess.java:332)
    at com.android.utils.GrabProcessOutput$1.run(GrabProcessOutput.java:104)
hatirlatici
  • 1,598
  • 2
  • 13
  • 24

11 Answers11

40

To solve this problem you should:

  1. Install the mathching SDK version (27)
  2. In module's build.gradle you should set compileSdkVersion to 27 and change the com.android.support:appcompat-v7 version to match the com.android.support:recyclerview-v7: (or the other support library component that you use) version (27.0.0)

UPD:

If for some reason it doesn't help you, please look at the comment below by @madu

Leo240
  • 766
  • 7
  • 16
  • 6
    By putting the compile sdk version to 26 and by putting the below list worked for me. If you are not sure whether what are the actual values to after : for com.android.support:recyclerview-v6 just put + sign as below. compile 'com.android.support:appcompat-v7:26+' compile 'com.android.support:design:26+' compile 'com.android.support:recyclerview-v7:26+' compile 'com.android.support:cardview-v7:26+' – madu Dec 07 '17 at 11:08
  • @madu I just described exactly that has worked for me – Leo240 Dec 07 '17 at 11:44
  • yes your answer helped me to get the clue (thank you), but I got into trouble in finding the matching com.android.support:recyclerview-v7. By putting '+' sign I was able to overcome the issue and is why I have put the above comment emphasising the '+' sign thinking it'll be helpful for someone else. – madu Dec 09 '17 at 20:21
  • @Leo240 I'm facing exactly this issue and tried everything to solve it out but it didn't help. – Nimesh khatri Mar 28 '18 at 10:24
  • @Nimeshkhatri Did you try the solution made by madu in the comment above? – Leo240 Mar 29 '18 at 09:20
  • yes that issue fixed but now getting another issue: Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(26.0.0-alpha1) from [com.android.support:appcompat-v7:25.3.1] AndroidManifest.xml:27:9-31 – Nimesh khatri Mar 29 '18 at 09:24
  • https://forum.ionicframework.com/t/solved-ionic-run-android-com-android-support-conflicting-v26-alpha1-and-v25-3-1/91826 – Nimesh khatri Mar 29 '18 at 09:24
  • If any body is using react-native and getting this error, check the compiledSdkVersion and targetSdkVersion on build.gradle of newly installed package (such as react-native-audio-record) also. Sometimes the values on these keys do not match with build.gradle file of app. – alchi baucha Nov 13 '18 at 02:25
8

I was able to fix this problem by updating the following values to '27':

android {
    compiledSdkVersion 27

    defaultConfig {
        targetSdkVersion 27
    }
}
Paul Wintz
  • 2,542
  • 1
  • 19
  • 33
  • where is it ? in "android/build.gradle"? – shinriyo Nov 06 '18 at 07:58
  • Yes, "these values are integrated into the tools system through inclusion in your module’s build.gradle file (also available through the Project Structure option in Android Studio" (source and more details here: https://medium.com/androiddevelopers/picking-your-compilesdkversion-minsdkversion-targetsdkversion-a098a0341ebd) – Paul Wintz Nov 07 '18 at 23:44
6

I got the same problem. Just adjust the compileSdkVersion and buildToolsVersion.

This is previous version:

enter image description here

this is the version without the problem: enter image description here

sunjenry
  • 141
  • 1
  • 4
3

I have fixed this issue by updating targetSdkVersion and compileSdkVersion.

targetSdkVersion 28
compileSdkVersion 28

In build.gradle(Module:app)

Pullat Junaid
  • 3,224
  • 3
  • 25
  • 25
Arti Patel
  • 671
  • 4
  • 15
1

I have faced with same issue and haven't solve it yet. Problem is com.android.support:support-v13 or v7 (maybe support-combat) dependency version. If it is 23.0.0 or 24.0.0 there is no problem, but if you set 27.0.0 it gives this error.

  • So you do downgrade like : compile 'com.android.support:appcompat-v7:24.0 instead of compile 'com.android.support:appcompat-v7:27.0 ? Should I use something like : compile 'com.android.support:support-v4:20.0.+' ? What is the meaning of + in here like this and upper versions will be supperted ? – hatirlatici Nov 02 '17 at 07:04
  • Could you test with 24.0.0 to see if it the problem because of version ? – Reso Alexandro Nov 02 '17 at 08:10
  • In my case, explicitly compiling with com.android.support:support-v4:25.3.1 fixed this (was not explicit in build.gradle before, so somehow gradle was including 27.0.x) – Sofi Software LLC Nov 28 '17 at 23:28
1

After downgrade from v4:27.0.1 to 25.3.1 all right. There was 11 errors in res files before .

Jorje
  • 11
  • 1
1

i was try downgrade targetSdkVersion and compileSdkVersion 27 to 25 but this error was come when i find some solotion and that works great

i was just add below line of code in my gradle file

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {

                details.useVersion '25.2.0'

        }
    }
}

if you want downgrade 27 to 23,24,25 etc than change the details.useVersion '_._._' <-- put here yorr version

Sanjay Hadiya
  • 864
  • 9
  • 21
0

I was able to fix this problem by updating the following values from '25' to '27':

buildscript {
    repositories {
        jcenter()
        google()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
    }
}

apply plugin: 'com.android.application'

repositories {
    jcenter()
    google()
}

dependencies {
    implementation "com.android.support:support-v4:27.0.2"
    implementation "com.android.support:support-v13:27.0.2"
    implementation "com.android.support:cardview-v7:27.0.2"
    implementation "com.android.support:appcompat-v7:27.0.2"
    implementation 'com.android.support:recyclerview-v7:25.0.1'
    implementation 'com.android.support:design:25.0.1'
}

// The sample build uses multiple directories to
// keep boilerplate and common code separate from
// the main sample code.
List<String> dirs = [
    'main',     // main sample code; look here for the interesting stuff.
    'common',   // components that are reused by multiple samples
    'template'] // boilerplate code that is generated by the sample template process

android {
    compileSdkVersion 27

    buildToolsVersion '27.0.3'

    defaultConfig {
        minSdkVersion 24
        targetSdkVersion 27
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    sourceSets {
        main {
            dirs.each { dir ->
                java.srcDirs "src/${dir}/java"
                res.srcDirs "src/${dir}/res"
            }
        }
        androidTest.setRoot('tests')
        androidTest.java.srcDirs = ['tests/src']

    }

}
Languoguang
  • 2,166
  • 2
  • 10
  • 15
0

It is just a caching problem. The contents are updated in the cache files.

  1. Delete "support-compat-27.0.0.aar" folder from C:/USER/user_name/.gradle/caches/transforms-1/files-1.1/support-compat-27.0.0.aar/...
    Note: Go to the path which displayed in error.

  2. Build the project.

  3. Run your app.

It will solve your problem.

Jaymin Soni
  • 451
  • 3
  • 10
0

I just found the source of the issue by using CTRL+SHIFT+F and looking for the problematic attributes in the code (of the entire scope). Turns out in my case the culprit was a third party dependency. Once i uninstalled it it was fixed. I guess the issue came from updating gradle and these outdated libraries somehow interfering with it. I still dont understand the nature of the issue exactly but I hope this helps someone else dealing with the same issue. I just spent waaay to long looking at this. in your case i guess it could be mixing of v4 and v7 libraries

quealegriamasalegre
  • 2,887
  • 1
  • 13
  • 35
-24

Maybe uninstalling and reinstalling whole android studio will help... Remember to backup your projects.