无法找到属性android:font for v7 support

时间:2017-11-01 19:52:28

标签: android gradle

我一直在开发一款Linphone应用程序,但却陷入了困境。我已经更改了应用名称并重构了所有相关包。应用程序没问题,直到我将gradle升级到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.

我已经阅读了有关无法找到属性错误但无法找到答案的其他问题。我尝试了下面的方法,但没有一个工作:

  1. 删除应用程序的bin /目录
  2. 清理缓存并重新构建应用
  3. 使缓存无效并重新启动(其中的每个选项)
  4. 更改sdk版本(api)
  5. multiDexEnabled true / false
  6. 以下是日志的详细信息:

    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)
    

11 个答案:

答案 0 :(得分:34)

要解决此问题,您应该:

  1. 安装mathching SDK版本(27)
  2. 在模块build.gradle中,您应将compileSdkVersion设置为27并更改com.android.support:appcompat-v7版本以匹配com.android.support:recyclerview-v7:(或您的其他支持库组件)使用)版本(27.0.0)
  3. <强> UPD:

    如果由于某种原因它对您没有帮助,请参阅@madu下面的评论

答案 1 :(得分:5)

我能够通过将以下值更新为&#39; 27&#39;来解决此问题:

android {
    compiledSdkVersion 27

    defaultConfig {
        targetSdkVersion 27
    }
}

答案 2 :(得分:5)

我遇到了同样的问题。只需调整compileSdkVersion和buildToolsVersion。

这是以前的版本:

enter image description here

这是没有问题的版本: enter image description here

答案 3 :(得分:1)

从v4:27.0.1降级到25.3.1后,好吧。之前res文件中有11个错误。

答案 4 :(得分:1)

我曾尝试将targetSdkVersion降级,并将compileSdkVersion 27降级到25,但是当我发现有某种松散性时,就会出现此错误,并且效果很好

我只是在gradle文件的代码行下面添加了

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

                details.useVersion '25.2.0'

        }
    }
}

如果您想将27降级到23、24、25等而不是更改详细信息。useVersion'_._._'<-放在此处yorr版本

答案 5 :(得分:1)

我通过更新targetSdkVersion和compileSdkVersion解决了这个问题。

targetSdkVersion 28
compileSdkVersion 28

答案 6 :(得分:0)

我遇到过同样的问题而且尚未解决问题。问题是com.android.support:support-v13或v7(可能是support-combat)依赖版本。如果是23.0.0或24.0.0则没有问题,但如果设置为27.0.0就会出现此错误。

答案 7 :(得分:0)

我能够通过将以下值从“25”更新为“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']

    }

}

答案 8 :(得分:0)

这只是一个缓存问题。内容在缓存文件中更新。

  1. 从中删除“ support-compat-27.0.0.aar”文件夹 C:/ USER /用户名/.gradle/caches/transforms-1/files-1.1/support-compat-27.0.0.aar / ...
    注意:转到错误显示的路径。

  2. 构建项目。

  3. 运行您的应用。

它将解决您的问题。

答案 9 :(得分:0)

我只是通过使用CTRL + SHIFT + F并在代码(整个作用域)中查找有问题的属性来找到问题的根源。在我看来,罪魁祸首是第三方的依赖。一旦我卸载它是固定的。我猜问题出在更新gradle以及这些过时的库以某种方式干扰了它。 我仍然不完全了解问题的性质,但我希望这可以帮助其他人处理同一问题。我只是花了很长时间才看这个。 在您的情况下,我想可能是v4和v7库的混合

答案 10 :(得分:-18)

也许卸载并重新安装整个android studio会有所帮助......记得备份你的项目。