compileSdkVersion 28

时间:2019-09-01 04:10:54

标签: java android gradle sdk android-gradle-plugin

我的项目没有问题,但是最近遇到了一个小错误,因此我单击了“无效并重新启动”选项以修复某些错误。该错误已修复,现在我无法构建我的项目

我重建项目时的错误

错误:任务':app:transformClassesWithMultidexlistForDebug'的执行失败。

  

java.io.IOException:无法编写[D:\ MessagePlus \ app \ build \ intermediates \ multi-dex \ debug \ componentClasses.jar](无法读取[C:\ Users \ Akash.gradle \ caches \ transforms-1 \ files-1.1 \ versionedparcelable-1.0.0.aar \ 6c766194e4753f670df775fbe4f9a9b0 \ jars \ classes.jar(;;;;;; **。class)](重复的zip条目[classes.jar:androidx / versionedparcelable /CustomVersionedParcelable.class]))

错误是控制台

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task 
':app:transformClassesWithMultidexlistForDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
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 org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)

Caused by: java.lang.RuntimeException: java.io.IOException: Can't write [D:\MessagePlus\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\Akash\.gradle\caches\transforms-1\files-1.1\versionedparcelable-1.0.0.aar\6c766194e4753f670df775fbe4f9a9b0\jars\classes.jar(;;;;;;**.class)] (Duplicate zip entry [classes.jar:androidx/versionedparcelable/CustomVersionedParcelable.class]))
at com.android.builder.profile.Recorder$Block.handleException(Recorder.java:55)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:104)
at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:213)
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)
... 27 more

Caused by: java.io.IOException: Can't write [D:\MessagePlus\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\Akash\.gradle\caches\transforms-1\files-1.1\versionedparcelable-1.0.0.aar\6c766194e4753f670df775fbe4f9a9b0\jars\classes.jar(;;;;;;**.class)] (Duplicate zip entry [classes.jar:androidx/versionedparcelable/CustomVersionedParcelable.class]))
at proguard.OutputWriter.writeOutput(OutputWriter.java:187)
at proguard.OutputWriter.execute(OutputWriter.java:79)
at proguard.ProGuard.writeOutput(ProGuard.java:427)
at proguard.ProGuard.execute(ProGuard.java:175)
at com.android.build.gradle.internal.transforms.BaseProguardAction.runProguard(BaseProguardAction.java:61)
at com.android.build.gradle.internal.transforms.MainDexListTransform.shrinkWithProguard(MainDexListTransform.java:232)
at com.android.build.gradle.internal.transforms.MainDexListTransform.transform(MainDexListTransform.java:184)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:222)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:218)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
... 39 more

Caused by: java.io.IOException: Can't read [C:\Users\Akash\.gradle\caches\transforms-1\files-1.1\versionedparcelable-1.0.0.aar\6c766194e4753f670df775fbe4f9a9b0\jars\classes.jar(;;;;;;**.class)] (Duplicate zip entry [classes.jar:androidx/versionedparcelable/CustomVersionedParcelable.class])
at proguard.InputReader.readInput(InputReader.java:188)
at proguard.InputReader.readInput(InputReader.java:158)
at proguard.OutputWriter.writeOutput(OutputWriter.java:176)
... 48 more

Caused by: java.io.IOException: Duplicate zip entry [classes.jar:androidx/versionedparcelable/CustomVersionedParcelable.class]
at proguard.io.JarWriter.getOutputStream(JarWriter.java:138)
at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:106)
at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:106)
at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:92)
at proguard.io.ClassRewriter.read(ClassRewriter.java:68)
at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
at proguard.io.JarReader.read(JarReader.java:65)
at proguard.io.DirectoryPump.readFiles(DirectoryPump.java:65)
at proguard.io.DirectoryPump.pumpDataEntries(DirectoryPump.java:53)
at proguard.InputReader.readInput(InputReader.java:184)
... 50 more

我的摇篮

apply plugin: 'com.android.application'

android {


compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
    applicationId 'com.scorpion.messageplus'
    minSdkVersion 17
    targetSdkVersion 28
    versionCode 4
    versionName "1.0.2"
    //noinspection GradleCompatible
    //noinspection GradleCompatible
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
productFlavors {
}
    //packagingOptions {
    //exclude 'META-INF/ASL2.0'
    //exclude 'META-INF/androidx.localbroadcastmanager_localbroadcastmanager.version'
    //exclude 'META-INF/androidx.swiperefreshlayout_swiperefreshlayout.version'
    //exclude 'META-INF/androidx.cursoradapter_cursoradapter.version'
    //exclude 'META-INF/androidx.drawerlayout_drawerlayout.version'
    //exclude 'META-INF/androidx.print_print.version'
    //exclude 'META-INF/androidx.versionedparcelable_versionedparcelable.version'
    //noinspection GradleCompatible
    //exclude 'META-INF/androidx.interpolator_interpolator.version'
    //exclude 'META-INF/androidx.fragment_fragment.version'
    //exclude 'META-INF/androidx.customview_customview.version'
    //exclude 'META-INF/androidx.documentfile_documentfile.version'
    //exclude 'META-INF/androidx.legacy_legacy-support-core-utils.version'
    //exclude 'META-INF/androidx.loader_loader.version'
    //exclude 'META-INF/androidx.viewpager_viewpager.version'
    //exclude 'META-INF/androidx.asynclayoutinflater_asynclayoutinflater.version'
    //exclude 'META-INF/androidx.core_core.version'
    //exclude 'META-INF/proguard/androidx-annotations.pro'
    //exclude 'META-INF/androidx.appcompat_appcompat.version'
    //exclude 'META-INF/androidx.vectordrawable_vectordrawable.version'
    //exclude 'META-INF/androidx.vectordrawable_vectordrawable-animated.version'
    //exclude 'META-INF/androidx.slidingpanelayout_slidingpanelayout.version'
    //exclude 'META-INF/androidx.coordinatorlayout_coordinatorlayout.version'
    //exclude 'META-INF/androidx.legacy_legacy-support-core-ui.version'
    //}
}


dependencies{

//noinspection GradleCompatible
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

testImplementation 'junit:junit:4.12'

implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support.constraint:constraint-layout:1.1.3'

//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'

implementation 'com.unstoppable:submitbutton:1.1.3'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.github.yukuku:ambilwarna:2.0.1'
implementation 'com.github.bumptech.glide:glide:4.6.1'
implementation 'com.github.siyamed:android-shape-imageview:0.9.3@aar'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'

implementation 'com.android.volley:volley:1.0.0'

implementation 'com.firebaseui:firebase-ui-database:3.3.0'
implementation 'com.firebaseui:firebase-ui-auth:3.3.0'
implementation 'com.firebaseui:firebase-ui-storage:3.3.0'

//noinspection GradleCompatible
implementation 'com.google.firebase:firebase-core:17.0.0'
implementation 'com.google.firebase:firebase-ads:17.0.0'
implementation 'com.google.firebase:firebase-auth:17.0.0'
implementation 'com.google.firebase:firebase-database:17.0.0'
implementation 'com.google.firebase:firebase-storage:17.0.0'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
implementation 'com.google.firebase:firebase-invites:17.0.0'

implementation 'id.zelory:compressor:2.1.0'

implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'com.google.android.gms:play-services-ads:17.0.0'

//    GoogleServicesPlugin.config.disableVersionCheck = true
}

apply plugin: 'com.google.gms.google-services'

自从Google强迫我在启动时将我的编译版本更新为28以来,这变得非常困难。现在,我必须每次都处理依赖性问题。 我能知道我哪里出错了吗?我已经尝试过StackOverflow和GItHub中所有现有的解决方案

1 个答案:

答案 0 :(得分:0)

使用AndroidX时,您应该更改依赖关系。 AndroidX中的所有程序包都位于以字符串androidx开头的一致名称空间中。支持库包已映射到相应的androidx。*包中。例如您依赖项中的'com.android.support:appcompat-v7'更改为实现'androidx.appcompat:appcompat'

根据Google文档:

  

AndroidX将原始支持库API替换为中的软件包   androidx名称空间。仅软件包和Maven工件名称   改变类,方法和字段名称保持不变。

在Android Studio 3.2及更高版本中,您可以通过从菜单栏中选择“重构”>“迁移到AndroidX”,将现有项目迁移到AndroidX。但是,如果您想手动进行操作,则可以找到适当的映射here

但是我建议将其委托给Android Studio。 指向AndroidX版本并非没有宽限期。与支持库不同,AndroidX软件包是分别维护和更新的。

androidx软件包从版本1.0.0开始使用严格的语义版本控制。您可以在项目中独立更新AndroidX库:

  

所有新的支持库开发都将在AndroidX中进行   图书馆。这包括原始支持库的维护   工件和新的Jetpack组件的介绍。

当前(正如我写这篇文章一样),最后一个稳定版本是AndroidX 1.0.0

最后,如果您不想使用AndroidX,除了更改依赖项外,别忘了在gradle.properties文件中设置错误的两个标志。