BuildException:无法在 Android Studio 3.1 Canary 6 中执行 aapt



我在gradle构建过程中遇到了这个问题:

org.gradle.tooling.BuildException: Failed to execute aapt
at com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask.invokeAaptForSplit(LinkApplicationAndroidResourcesTask.java:547)
at com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask.doFullTaskAction(LinkApplicationAndroidResourcesTask.java:280)
at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:106)
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.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:46)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
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:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
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.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
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:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
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:123)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
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: com.android.ide.common.process.ProcessException: Failed to execute aapt
at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:794)
at com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask.invokeAaptForSplit(LinkApplicationAndroidResourcesTask.java:525)
... 49 more
Caused by: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing process /home/local/MPROGA1/malwinder.singh/Desktop/SDK/android-sdk-linux/build-tools/27.0.1/aapt with arguments {package -f --no-crunch -I /home/local/MPROGA1/malwinder.singh/Desktop/SDK/android-sdk-linux/platforms/android-25/android.jar -M /home/local/MPROGA1/malwinder.singh/Desktop/Oversight/app/build/intermediates/manifests/full/debug/AndroidManifest.xml -S /home/local/MPROGA1/malwinder.singh/Desktop/Oversight/app/build/intermediates/res/merged/debug -m -J /home/local/MPROGA1/malwinder.singh/Desktop/Oversight/app/build/generated/source/r/debug -F /home/local/MPROGA1/malwinder.singh/Desktop/Oversight/app/build/intermediates/res/debug/resources-debug.ap_ -D /home/local/MPROGA1/malwinder.singh/Desktop/Oversight/app/build/intermediates/multi-dex/debug/manifest_keep.txt --custom-package com.emerson.oversight -0 apk --output-text-symbols /home/local/MPROGA1/malwinder.singh/Desktop/Oversight/app/build/intermediates/symbols/debug --no-version-vectors}
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:792)
... 50 more
Caused by: com.android.ide.common.process.ProcessException: Error while executing process /home/local/MPROGA1/malwinder.singh/Desktop/SDK/android-sdk-linux/build-tools/27.0.1/aapt with arguments {package -f --no-crunch -I /home/local/MPROGA1/malwinder.singh/Desktop/SDK/android-sdk-linux/platforms/android-25/android.jar -M /home/local/MPROGA1/malwinder.singh/Desktop/Oversight/app/build/intermediates/manifests/full/debug/AndroidManifest.xml -S /home/local/MPROGA1/malwinder.singh/Desktop/Oversight/app/build/intermediates/res/merged/debug -m -J /home/local/MPROGA1/malwinder.singh/Desktop/Oversight/app/build/generated/source/r/debug -F /home/local/MPROGA1/malwinder.singh/Desktop/Oversight/app/build/intermediates/res/debug/resources-debug.ap_ -D /home/local/MPROGA1/malwinder.singh/Desktop/Oversight/app/build/intermediates/multi-dex/debug/manifest_keep.txt --custom-package com.emerson.oversight -0 apk --output-text-symbols /home/local/MPROGA1/malwinder.singh/Desktop/Oversight/app/build/intermediates/symbols/debug --no-version-vectors}
at com.android.build.gradle.internal.process.GradleProcessResult.buildProcessException(GradleProcessResult.java:73)
at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:48)
at com.android.builder.internal.aapt.AbstractProcessExecutionAapt$1.onSuccess(AbstractProcessExecutionAapt.java:78)
at com.android.builder.internal.aapt.AbstractProcessExecutionAapt$1.onSuccess(AbstractProcessExecutionAapt.java:74)
at com.google.common.util.concurrent.Futures$CallbackListener.run(Futures.java:1237)
at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:911)
at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:822)
at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:664)
at com.google.common.util.concurrent.SettableFuture.set(SettableFuture.java:48)
at com.android.build.gradle.internal.process.GradleProcessExecutor$1.run(GradleProcessExecutor.java:58)
Caused by: org.gradle.process.internal.ExecException: Process 'command '/home/local/MPROGA1/malwinder.singh/Desktop/SDK/android-sdk-linux/build-tools/27.0.1/aapt'' finished with non-zero exit value 1
at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:382)
at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:46)
... 9 more

模块级别(内部)build.gradle

buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
//noinspection GradleDynamicVersion
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
//For green dao
apply plugin: 'org.greenrobot.greendao'
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url "https://jitpack.io" }
jcenter()
}
android {
compileSdkVersion 25
buildToolsVersion '27.0.1'
defaultConfig {
applicationId "com.example"
minSdkVersion 16
targetSdkVersion 25
versionCode 3
versionName "1.1.1"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
buildTypes {
release {
lintOptions {
disable 'MissingTranslation'
}
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile('com.crashlytics.sdk.android:crashlytics:2.6.7@aar') {
transitive = true
}
//AppCompat v7 support library
compile 'com.android.support:appcompat-v7:25.3.1'
//AppCompat v4 support library
compile 'com.android.support:support-v4:25.3.1'
//Support design
compile 'com.android.support:design:25.3.1'
//Google Maps
compile 'com.google.android.gms:play-services-maps:11.8.0'
//Retrofit - for making REST API calls
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
//For Runtime permissions
compile 'com.karumi:dexter:4.2.0'
//To set custom fonts
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
//Attaches bullets to viewpager
compile 'com.robohorse.pagerbullet:pagerbullet:1.0.8'
//Expandable recycler view
compile 'com.bignerdranch.android:expandablerecyclerview:3.0.0-RC1'
//For Graph
compile 'com.github.PhilJay:MPAndroidChart:v3.0.2'
//Date time
compile 'com.wdullaer:materialdatetimepicker:3.2.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
testCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support:support-annotations:25.3.1'
androidTestCompile 'com.android.support.test:runner:1.0.1'
androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.android.support:gridlayout-v7:25.3.1'
compile 'com.jakewharton:butterknife:8.6.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
compile 'com.android.support:cardview-v7:25.3.1'
// jCenter
compile 'jp.wasabeef:recyclerview-animators:2.2.6'
compile 'com.ncornette.cache:okcache-control:1.1.1'
compile 'org.greenrobot:greendao:3.2.2'
compile 'net.danlew:android.joda:2.9.9'
compile 'com.github.barteksc:android-pdf-viewer:3.0.0-beta.3'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'org.jetbrains.anko:anko-common:0.8.3'
compile 'me.dm7.barcodescanner:zbar:1.9.8'
// https://mvnrepository.com/artifact/com.openhtmltopdf/openhtmltopdf-parent
compile group: 'com.openhtmltopdf', name: 'openhtmltopdf-parent', version: '0.0.1-RC12', ext: 'pom'
}

主要(外部)build.gradle

buildscript {
ext.kotlin_version = '1.2.0'
repositories {
jcenter()
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0-alpha06'
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
google()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

此问题不会在 Android Studio 3.0.1 上出现

试试这个。我试过了,它正在工作。

Android Studio>帮助>检查更新>配置并在微调器上选择金丝雀频道,然后单击确定。清理项目并重建后。

我遇到了同样的错误,因为我添加了一个依赖项,该依赖项使用编译 sdk 版本和目标 sdk 版本,该依赖项大于我的项目的编译 sdk 版本。 我的项目 编译 sdk 版本是 26 我添加了使用编译 sdk 版本 28 的简单权限库。 添加"实现'pub.devrel:easypermissions:2.0.1'"后,抛出了上面的错误。修复是将我的编译 sdk 版本设置为 28。原因:

库是作为依赖应用程序项目的一部分编译的,因此>库项目中使用的 API 必须与用于>编译应用程序项目的 Android 库版本兼容。通常,库项目应使用 API 级别>该级别与应用程序使用的级别相同或更低。如果库>项目使用的 API 级别高于应用程序的 API 级别,则应用程序>项目将不会编译。例如,拥有一个使用>Android 1.5 API(API 级别 3)并在 Android 1.6(API 级别 4)或>Android 2.1(API 级别 7)项目中使用的库是完全可以接受的。

尝试添加:

implementation 'com.android.support.constraint: constraint-layout: 1.0.2'

在你的build.gradle {} dependencies就我而言,这就是问题所在,也许某些 xml 资源需要使用constraint-layout......

相关内容

  • 没有找到相关文章

最新更新