我刚刚将Realm添加到我的项目中,该项目以前运行良好。添加后,它在构建时开始抛出:
失败:构建失败,并出现异常。
org.gradle.api.tasks.TaskExecutionException:任务':app:transformClassesWithDexBuilderForDebug'的执行失败。 在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:103) 在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:73) 在org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)处 在org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59) 在org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54) 在org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59) 在org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)处 在org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44) 在org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91) 在org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)处 在org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59) 在org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54) 在org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) 在org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34) 在org.gradle.execution.taskgraph.DefaultTaskGraphExecuter $ EventFiringTaskWorker $ 1.run(DefaultTaskGraphExecuter.java:256) 在org.gradle.internal.progress.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)处 在org.gradle.internal.progress.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328) 在org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199) 在org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110) 在org.gradle.execution.taskgraph.DefaultTaskGraphExecuter $ EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:249)处 在org.gradle.execution.taskgraph.DefaultTaskGraphExecuter $ EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:238)处 在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)处 在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker.access $ 200(DefaultTaskPlanExecutor.java:79) 在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker $ 1.execute(DefaultTaskPlanExecutor.java:104) 在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker $ 1.execute(DefaultTaskPlanExecutor.java:98) 在org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:663)处 在org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:597) 在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98) 在org.gradle.internal.concurrent.ExecutorPolicy $ CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) 在org.gradle.internal.concurrent.ManagedExecutorImpl $ 1.run(ManagedExecutorImpl.java:46) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617) 在org.gradle.internal.concurrent.ThreadFactoryImpl $ ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) 在java.lang.Thread.run(Thread.java:745) ....
运行时例外:
java.lang.RuntimeException:com.android.build.api.transform.TransformException:java.lang.RuntimeException:java.lang.RuntimeException 在com.android.builder.profile.Recorder $ Block.handleException(Recorder.java:55) 在com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:104) 在com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:230) 在sun.reflect.GeneratedMethodAccessor989.invoke(未知来源) 在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在java.lang.reflect.Method.invoke(Method.java:498) 在org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73) 在org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:50) 在org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39) 在org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26) 在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter $ 1.run(ExecuteActionsTaskExecuter.java:124) 在org.gradle.internal.progress.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)处 在org.gradle.internal.progress.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328) 在org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199) 在org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110) 在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:113)处 在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:95) 在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:73) 在org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)处 在org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59) 在org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54) 在org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59) 在org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)处 在org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44) 在org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91) 在org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)处 在org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59) 在org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54) 在org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) 在org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34) 在org.gradle.execution.taskgraph.DefaultTaskGraphExecuter $ EventFiringTaskWorker $ 1.run(DefaultTaskGraphExecuter.java:256) 在org.gradle.internal.progress.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)处 在org.gradle.internal.progress.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328) 在org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199) 在org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110) 在org.gradle.execution.taskgraph.DefaultTaskGraphExecuter $ EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:249)处 在org.gradle.execution.taskgraph.DefaultTaskGraphExecuter $ EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:238)处 在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)处 在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker.access $ 200(DefaultTaskPlanExecutor.java:79) 在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker $ 1.execute(DefaultTaskPlanExecutor.java:104) 在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker $ 1.execute(DefaultTaskPlanExecutor.java:98) 在org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:663)处 在org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:597) 在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98) 在org.gradle.internal.concurrent.ExecutorPolicy $ CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) 在org.gradle.internal.concurrent.ManagedExecutorImpl $ 1.run(ManagedExecutorImpl.java:46) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617) 在org.gradle.internal.concurrent.ThreadFactoryImpl $ ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) 在java.lang.Thread.run(Thread.java:745)
这是我的 Gradle 应用:
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "goodweather.com.goodweather"
minSdkVersion 19
targetSdkVersion 28
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:multidex:1.0.3'
//Dagger 2
implementation 'com.google.dagger:dagger:2.16'
implementation 'com.google.dagger:dagger-android-support:2.16'
annotationProcessor 'com.google.dagger:dagger-compiler:2.16'
testAnnotationProcessor 'com.google.dagger:dagger-compiler:2.16'
//RxJava2
implementation "io.reactivex.rxjava2:rxjava:2.2.2"
implementation "io.reactivex.rxjava2:rxandroid:2.0.1"
// Retrofit 2
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
// OkHTTP
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'com.squareup.okio:okio:1.14.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.9.0'
//Glide
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
//Gson
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
//ButterKnife
implementation 'com.jakewharton:butterknife:9.0.0-rc1'
annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-rc1'
//Moxy
implementation 'com.arello-mobile:moxy-android:1.5.5'
implementation 'com.arello-mobile:moxy-app-compat:1.5.5'
annotationProcessor 'com.arello-mobile:moxy-compiler:1.5.5'
//Lombok
compileOnly 'org.projectlombok:lombok:1.18.4'
annotationProcessor 'org.projectlombok:lombok:1.18.4'
//SearchView
implementation 'com.miguelcatalan:materialsearchview:1.4.0'
// Logging
implementation 'com.jakewharton.timber:timber:4.6.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
}
Project Gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "io.realm:realm-gradle-plugin:5.8.0"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我已经尝试了许多对其他人有效的解决方案,但不适用于我。