bjoernQ / unmock-plugin

Gradle plugin to be used in combination with the new unit testing feature of the Gradle Plugin / Android Studio to use real classes for e.g. SparseArray.
Apache License 2.0
323 stars 22 forks source link

Crash during building in Android Studio #41

Closed OleksandrKucherenko closed 6 years ago

OleksandrKucherenko commented 7 years ago
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':modules:android-motionize-sdk:motionDNALib:unMock'.
        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: org.gradle.api.UncheckedIOException: java.util.zip.ZipException: error in opening zip file
        at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:57)
        at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:40)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:152)
        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.util.zip.ZipException: error in opening zip file
        at de.mobilej.ProcessRealAndroidJar.findAllClazzesIn(ProcessRealAndroidJar.java:306)
        at de.mobilej.ProcessRealAndroidJar.process(ProcessRealAndroidJar.java:115)
        at de.mobilej.unmock.UnMockPlugin$_apply_closure1$_closure4.doCall(UnMockPlugin.groovy:66)
        at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:681)
        at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:656)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
        ... 33 more
OleksandrKucherenko commented 7 years ago

gradle-4.1-bin

gradle version in use

bjoernQ commented 7 years ago

Just double checked it with

distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

and it it works fine for me.

From the exception it says it had trouble opening the downloaded android-all-file

Do you use the "downloadFrom" way to configure the android-all url or do you use the "unmock" dependency?

If you don't configure anything it will default to "downloadFrom" which is known to give problems like this sometimes. It seems that the downloaded file is corrupted and we cannot open it.

If you use the dependency then clearing the Gradle caches should help. If you are using "downloadFrom" (or just use the default) it would be best to change to the dependency way.

OleksandrKucherenko commented 7 years ago

project and sub-module both reference/depends on unMock plugin... maybe issues is in this area

bjoernQ commented 7 years ago

I'll try that setup, too (works with older versions of Gradle at least)

which Android Gradle plugin is in use? did this happen suddenly after upgrading the Gradle version?

OleksandrKucherenko commented 7 years ago

GRADLE_PLUGIN=2.3.3 GOOGLE_PLAY_PLUGIN=3.1.1 UNMOCK_PLUGIN=0.6.4

OleksandrKucherenko commented 7 years ago

Workaround:

step 1: disable unMock task for all sub-projects/modules:

Place it in root build.gradle:

subprojects {
    project.plugins.whenPluginAdded { plugin ->
         if ("de.mobilej.unmock.UnMockPlugin".equals(plugin.class.name)) {
            if(!"app".equals(project.name)) {
                project.tasks["unMock"].onlyIf{ false }
            }
        }
    }
}

in project dependencies:

step 2: upgrade version of unmock classes

dependencies {

        /* https://oss.sonatype.org/content/groups/public/org/robolectric/android-all/ */
        unmock 'org.robolectric:android-all:8.0.0_r4-robolectric-r1'
}
bjoernQ commented 7 years ago

Nice you found a way to make it work for you. Unfortunately I'm still unable to reproduce the behavior. Maybe you can share some minimal code to reproduce this?

OleksandrKucherenko commented 7 years ago

try to create a project with lib module. in both dirs app and module configure usage of the unMock plugin....

try full rebuild of the project. than it quite often fails...

bjoernQ commented 7 years ago

I tried that with a minimal project w/o any actual code but it works for me all the time

I attached the project unmocktest.zip

OleksandrKucherenko commented 7 years ago

I will try to find time for making a simplified version of project and will upload it here.

bjoernQ commented 6 years ago

Since there is no activity for a long time - closing it - if it is still a problem and there is a way to reproduce it please reopen