是否必须在生成签名apk时启用minify

时间:2018-04-25 00:48:48

标签: android android-studio

我试图生成签名的apk但是当我在gradle中启用minify时我总是遇到这个错误..

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
    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.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: java.lang.RuntimeException: Job failed, see logs for details
    at com.android.build.gradle.internal.transforms.ProGuardTransform.transform(ProGuardTransform.java:196)
    at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:221)
    at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:217)
    at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
    at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:212)
    at sun.reflect.GeneratedMethodAccessor302.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    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)
    ... 32 more
Caused by: java.io.IOException: Please correct the above warnings first.
    at proguard.Initializer.execute(Initializer.java:473)
    at proguard.ProGuard.initialize(ProGuard.java:233)
    at proguard.ProGuard.execute(ProGuard.java:98)
    at com.android.build.gradle.internal.transforms.BaseProguardAction.runProguard(BaseProguardAction.java:61)
    at com.android.build.gradle.internal.transforms.ProGuardTransform.doMinification(ProGuardTransform.java:253)
    at com.android.build.gradle.internal.transforms.ProGuardTransform.access$000(ProGuardTransform.java:63)
    at com.android.build.gradle.internal.transforms.ProGuardTransform$1.run(ProGuardTransform.java:173)
    at com.android.builder.tasks.Job.runTask(Job.java:47)
    at com.android.build.gradle.tasks.SimpleWorkQueue$EmptyThreadContext.runTask(SimpleWorkQueue.java:41)
    at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:282)
    ... 1 more

这是我的gradle文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.xxx.xxxxx"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 4
        versionName "4.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        release {
            zipAlignEnabled true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.google.firebase:firebase-core:15.0.0'
    implementation 'com.google.code.gson:gson:2.8.0'
    implementation 'com.google.android.gms:play-services-ads:15.0.0'
    androidTestImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation 'com.android.support:design:26.1.0'
}

一些参考文献告诉我使用外部库可能有问题,我试图找到哪个库但仍然无法解决这个问题。 我将我的AS升级到3.1但仍然无法解决.. 我更新了我的sdk,但仍出现同样的错误.. 但是当我在gradle文件中禁用minify时我没有收到此错误

我在这里错过了什么吗?

添加java编译器错误消息

org.junit.experimental.results.ResultMatchers$1: can't find superclass or interface org.hamcrest.TypeSafeMatcher    
org.junit.experimental.results.ResultMatchers$2: can't find superclass or interface org.hamcrest.BaseMatcher    
org.junit.experimental.results.ResultMatchers$3: can't find superclass or interface org.hamcrest.BaseMatcher    
org.junit.internal.AssumptionViolatedException: can't find superclass or interface org.hamcrest.SelfDescribing  
org.junit.internal.matchers.StacktracePrintingMatcher: can't find superclass or interface org.hamcrest.TypeSafeMatcher  
org.junit.internal.matchers.ThrowableCauseMatcher: can't find superclass or interface org.hamcrest.TypeSafeMatcher  
org.junit.internal.matchers.ThrowableMessageMatcher: can't find superclass or interface org.hamcrest.TypeSafeMatcher    
org.junit.internal.matchers.TypeSafeMatcher: can't find superclass or interface org.hamcrest.BaseMatcher    
library class android.test.AndroidTestCase extends or implements program class junit.framework.TestCase 
library class android.test.AndroidTestRunner extends or implements program class junit.runner.BaseTestRunner    
library class android.test.InstrumentationTestCase extends or implements program class junit.framework.TestCase 
library class android.test.InstrumentationTestSuite extends or implements program class junit.framework.TestSuite   
library class android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests extends or implements program class junit.framework.TestCase   
org.junit.Assert: can't find referenced class org.hamcrest.MatcherAssert    
org.junit.Assert: can't find referenced class org.hamcrest.Matcher  
org.junit.Assume: can't find referenced class org.hamcrest.CoreMatchers 
org.junit.Assume: can't find referenced class org.hamcrest.Matcher  
org.junit.Assume: can't find referenced class org.hamcrest.CoreMatchers 
org.junit.Assume: can't find referenced class org.hamcrest.Matcher  
org.junit.AssumptionViolatedException: can't find referenced class org.hamcrest.Matcher 
org.junit.experimental.results.ResultMatchers: can't find referenced class org.hamcrest.Matcher 
org.junit.experimental.results.ResultMatchers$1: can't find referenced class org.hamcrest.TypeSafeMatcher   
org.junit.experimental.results.ResultMatchers$1: can't find referenced class org.hamcrest.Description   
org.junit.experimental.results.ResultMatchers$1: can't find referenced class org.hamcrest.TypeSafeMatcher   
org.junit.experimental.results.ResultMatchers$1: can't find referenced class org.hamcrest.Description   
org.junit.experimental.results.ResultMatchers$1: can't find referenced class org.hamcrest.TypeSafeMatcher   
org.junit.experimental.results.ResultMatchers$2: can't find referenced class org.hamcrest.BaseMatcher   
org.junit.experimental.results.ResultMatchers$2: can't find referenced class org.hamcrest.Matcher   
org.junit.experimental.results.ResultMatchers$2: can't find referenced class org.hamcrest.Description   
org.junit.experimental.results.ResultMatchers$2: can't find referenced class org.hamcrest.BaseMatcher   
org.junit.experimental.results.ResultMatchers$2: can't find referenced class org.hamcrest.Matcher   
org.junit.experimental.results.ResultMatchers$2: can't find referenced class org.hamcrest.Description   
org.junit.experimental.results.ResultMatchers$2: can't find referenced class org.hamcrest.BaseMatcher   
org.junit.experimental.results.ResultMatchers$3: can't find referenced class org.hamcrest.BaseMatcher   
org.junit.experimental.results.ResultMatchers$3: can't find referenced class org.hamcrest.Description   
org.junit.experimental.results.ResultMatchers$3: can't find referenced class org.hamcrest.BaseMatcher   
org.junit.experimental.results.ResultMatchers$3: can't find referenced class org.hamcrest.Description   
org.junit.experimental.results.ResultMatchers$3: can't find referenced class org.hamcrest.BaseMatcher   
org.junit.internal.AssumptionViolatedException: can't find referenced class org.hamcrest.StringDescription  
org.junit.internal.AssumptionViolatedException: can't find referenced class org.hamcrest.Description    
org.junit.internal.AssumptionViolatedException: can't find referenced class org.hamcrest.SelfDescribing 
org.junit.internal.AssumptionViolatedException: can't find referenced class org.hamcrest.StringDescription  
org.junit.internal.AssumptionViolatedException: can't find referenced class org.hamcrest.Description    
org.junit.internal.AssumptionViolatedException: can't find referenced class org.hamcrest.Matcher    
org.junit.internal.AssumptionViolatedException: can't find referenced class org.hamcrest.Description    
org.junit.internal.matchers.StacktracePrintingMatcher: can't find referenced class org.hamcrest.TypeSafeMatcher 
org.junit.internal.matchers.StacktracePrintingMatcher: can't find referenced class org.hamcrest.Matcher 
org.junit.internal.matchers.StacktracePrintingMatcher: can't find referenced class org.hamcrest.Description 
org.junit.internal.matchers.StacktracePrintingMatcher: can't find referenced class org.hamcrest.TypeSafeMatcher 
org.junit.internal.matchers.StacktracePrintingMatcher: can't find referenced class org.hamcrest.Matcher 
org.junit.internal.matchers.StacktracePrintingMatcher: can't find referenced class org.hamcrest.Description 
org.junit.internal.matchers.StacktracePrintingMatcher: can't find referenced class org.hamcrest.Matcher 
org.junit.internal.matchers.StacktracePrintingMatcher: can't find referenced class org.hamcrest.Description 
org.junit.internal.matchers.StacktracePrintingMatcher: can't find referenced class org.hamcrest.Matcher 
org.junit.internal.matchers.StacktracePrintingMatcher: can't find referenced class org.hamcrest.Factory 
org.junit.internal.matchers.StacktracePrintingMatcher: can't find referenced class org.hamcrest.Matcher 
org.junit.internal.matchers.StacktracePrintingMatcher: can't find referenced class org.hamcrest.Factory 
org.junit.internal.matchers.StacktracePrintingMatcher: can't find referenced class org.hamcrest.Description 
org.junit.internal.matchers.StacktracePrintingMatcher: can't find referenced class org.hamcrest.TypeSafeMatcher 
org.junit.internal.matchers.ThrowableCauseMatcher: can't find referenced class org.hamcrest.TypeSafeMatcher 
org.junit.internal.matchers.ThrowableCauseMatcher: can't find referenced class org.hamcrest.Description 
org.junit.internal.matchers.ThrowableCauseMatcher: can't find referenced class org.hamcrest.Matcher 
org.junit.internal.matchers.ThrowableCauseMatcher: can't find referenced class org.hamcrest.TypeSafeMatcher 
org.junit.internal.matchers.ThrowableCauseMatcher: can't find referenced class org.hamcrest.Description 
org.junit.internal.matchers.ThrowableCauseMatcher: can't find referenced class org.hamcrest.Matcher 
org.junit.internal.matchers.ThrowableCauseMatcher: can't find referenced class org.hamcrest.Description 
org.junit.internal.matchers.ThrowableCauseMatcher: can't find referenced class org.hamcrest.Matcher 
org.junit.internal.matchers.ThrowableCauseMatcher: can't find referenced class org.hamcrest.Factory 
org.junit.internal.matchers.ThrowableCauseMatcher: can't find referenced class org.hamcrest.Description 
org.junit.internal.matchers.ThrowableCauseMatcher: can't find referenced class org.hamcrest.TypeSafeMatcher 
org.junit.internal.matchers.ThrowableMessageMatcher: can't find referenced class org.hamcrest.TypeSafeMatcher   
org.junit.internal.matchers.ThrowableMessageMatcher: can't find referenced class org.hamcrest.Description   
org.junit.internal.matchers.ThrowableMessageMatcher: can't find referenced class org.hamcrest.Matcher   
org.junit.internal.matchers.ThrowableMessageMatcher: can't find referenced class org.hamcrest.TypeSafeMatcher   
org.junit.internal.matchers.ThrowableMessageMatcher: can't find referenced class org.hamcrest.Description   
org.junit.internal.matchers.ThrowableMessageMatcher: can't find referenced class org.hamcrest.Matcher   
org.junit.internal.matchers.ThrowableMessageMatcher: can't find referenced class org.hamcrest.Description   
org.junit.internal.matchers.ThrowableMessageMatcher: can't find referenced class org.hamcrest.Matcher   
org.junit.internal.matchers.ThrowableMessageMatcher: can't find referenced class org.hamcrest.Factory   
org.junit.internal.matchers.ThrowableMessageMatcher: can't find referenced class org.hamcrest.Description   
org.junit.internal.matchers.ThrowableMessageMatcher: can't find referenced class org.hamcrest.TypeSafeMatcher   
org.junit.internal.matchers.TypeSafeMatcher: can't find referenced class org.hamcrest.BaseMatcher   
org.junit.internal.runners.statements.FailOnTimeout: can't find referenced class java.lang.management.ManagementFactory 
org.junit.internal.runners.statements.FailOnTimeout: can't find referenced class java.lang.management.ThreadMXBean  
org.junit.internal.runners.statements.FailOnTimeout: can't find referenced class java.lang.management.ManagementFactory 
org.junit.internal.runners.statements.FailOnTimeout: can't find referenced class java.lang.management.ThreadMXBean  
org.junit.matchers.JUnitMatchers: can't find referenced class org.hamcrest.CoreMatchers 
org.junit.matchers.JUnitMatchers: can't find referenced class org.hamcrest.core.CombinableMatcher$CombinableBothMatcher 
org.junit.matchers.JUnitMatchers: can't find referenced class org.hamcrest.core.CombinableMatcher$CombinableEitherMatcher   
org.junit.matchers.JUnitMatchers: can't find referenced class org.hamcrest.CoreMatchers 
org.junit.matchers.JUnitMatchers: can't find referenced class org.hamcrest.core.CombinableMatcher   
org.junit.matchers.JUnitMatchers: can't find referenced class org.hamcrest.Matcher  
org.junit.matchers.JUnitMatchers: can't find referenced class org.hamcrest.core.CombinableMatcher$CombinableBothMatcher 
org.junit.matchers.JUnitMatchers: can't find referenced class org.hamcrest.Matcher  
org.junit.matchers.JUnitMatchers: can't find referenced class org.hamcrest.core.CombinableMatcher$CombinableBothMatcher 
org.junit.matchers.JUnitMatchers: can't find referenced class org.hamcrest.Matcher  
org.junit.matchers.JUnitMatchers: can't find referenced class org.hamcrest.core.CombinableMatcher$CombinableEitherMatcher   
org.junit.matchers.JUnitMatchers: can't find referenced class org.hamcrest.Matcher  
org.junit.matchers.JUnitMatchers: can't find referenced class org.hamcrest.core.CombinableMatcher$CombinableEitherMatcher   
org.junit.matchers.JUnitMatchers: can't find referenced class org.hamcrest.Matcher  
org.junit.rules.DisableOnDebug: can't find referenced class java.lang.management.ManagementFactory  
org.junit.rules.DisableOnDebug: can't find referenced class java.lang.management.RuntimeMXBean  
org.junit.rules.DisableOnDebug: can't find referenced class java.lang.management.ManagementFactory  
org.junit.rules.DisableOnDebug: can't find referenced class java.lang.management.RuntimeMXBean  
org.junit.rules.ErrorCollector: can't find referenced class org.hamcrest.Matcher    
org.junit.rules.ErrorCollector$1: can't find referenced class org.hamcrest.Matcher  
org.junit.rules.ExpectedException: can't find referenced class org.hamcrest.CoreMatchers    
org.junit.rules.ExpectedException: can't find referenced class org.hamcrest.StringDescription   
org.junit.rules.ExpectedException: can't find referenced class org.hamcrest.CoreMatchers    
org.junit.rules.ExpectedException: can't find referenced class org.hamcrest.StringDescription   
org.junit.rules.ExpectedException: can't find referenced class org.hamcrest.Matcher 
org.junit.rules.ExpectedExceptionMatcherBuilder: can't find referenced class org.hamcrest.Matcher   
org.junit.rules.ExpectedExceptionMatcherBuilder: can't find referenced class org.hamcrest.CoreMatchers  
org.junit.rules.ExpectedExceptionMatcherBuilder: can't find referenced class org.hamcrest.Matcher   
there were 308 unresolved references to classes or interfaces.  
there were 5 instances of library classes depending on program classes. 
Exception while processing task java.io.IOException: Please correct the above warnings first.   

0 个答案:

没有答案