美文网首页
【我的Android进阶之旅】Proguard混淆配置错误导致混

【我的Android进阶之旅】Proguard混淆配置错误导致混

作者: 欧阳鹏 | 来源:发表于2018-12-06 19:39 被阅读20次

    一、错误描述

    刚刚完成一个新功能,然后加上了混淆配置,接着Jenkins自动化编译的时候出错了,错误描述如下所示:

    Warning: Exception while processing task java.io.IOException: proguard.ParseException: Unexpected keyword 'com.xtc.watch.view.account.login.utils.stroke.bean.**' in line 142 of file '/data/jenkins/workspace/AP_GlobalLoginBindModule/watch/proguard-module.pro'
    :watch:transformClassesAndResourcesWithProguardForRelease FAILED
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':watch:transformClassesAndResourcesWithProguardForRelease'.
    > Job failed, see logs for details
    
    * Try:
    Run with --info or --debug option to get more log output.
    
    * Exception is:
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':watch: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.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: 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:222)
        at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:218)
        at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
        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: proguard.ParseException: Unexpected keyword 'com.xtc.watch.view.account.login.utils.stroke.bean.**' in line 142 of file '/data/jenkins/workspace/AP_GlobalLoginBindModule/watch/proguard-module.pro'
        at com.android.build.gradle.internal.transforms.ProGuardTransform.doMinification(ProGuardTransform.java:259)
        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:259)
    Caused by: proguard.ParseException: Unexpected keyword 'com.xtc.watch.view.account.login.utils.stroke.bean.**' in line 142 of file '/data/jenkins/workspace/AP_GlobalLoginBindModule/watch/proguard-module.pro'
        at proguard.ConfigurationParser.unknownAccessFlag(ConfigurationParser.java:1123)
        at proguard.ConfigurationParser.parseClassSpecificationArguments(ConfigurationParser.java:606)
        at proguard.ConfigurationParser.parseKeepClassSpecificationArguments(ConfigurationParser.java:535)
        at proguard.ConfigurationParser.parse(ConfigurationParser.java:164)
        at com.android.build.gradle.internal.transforms.BaseProguardAction.applyConfigurationFile(BaseProguardAction.java:146)
        at com.android.build.gradle.internal.transforms.ProGuardTransform.doMinification(ProGuardTransform.java:244)
        ... 5 more
    
    在这里插入图片描述 在这里插入图片描述

    二、解决错误

    Caused by: proguard.ParseException: Unexpected keyword 'com.xtc.watch.view.account.login.utils.stroke.bean.**' in line 142 of file '/data/jenkins/workspace/AP_GlobalLoginBindModule/watch/proguard-module.pro'
        at proguard.ConfigurationParser.unknownAccessFlag(ConfigurationParser.java:1123)
        at proguard.ConfigurationParser.parseClassSpecificationArguments(ConfigurationParser.java:606)
        at proguard.ConfigurationParser.parseKeepClassSpecificationArguments(ConfigurationParser.java:535)
        at proguard.ConfigurationParser.parse(ConfigurationParser.java:164)
        at com.android.build.gradle.internal.transforms.BaseProguardAction.applyConfigurationFile(BaseProguardAction.java:146)
        at com.android.build.gradle.internal.transforms.ProGuardTransform.doMinification(ProGuardTransform.java:244)
        ... 5 more
    

    看上面的错误提示是Proguard在读取配置文件 /data/jenkins/workspace/AP_GlobalLoginBindModule/watch/proguard-module.pro 的时候,读取到142行的时候出现了错误,我们来看一看这一行到底有什么错误

    在这里插入图片描述
      # 汉字笔划排序
      -keep com.xtc.watch.view.account.login.utils.stroke.bean.** {*;}
    

    哎,写的太快了,少写了一个关键字 class,晕死。
    立马修复,将错误的keep改为 keep class

    在这里插入图片描述
    # 汉字笔划排序
    -keep class com.xtc.watch.view.account.login.utils.stroke.bean.** {*;}
    

    修改完毕之后,提交代码,重新使用Jenkins编译即可成功!


    image

    作者:欧阳鹏 欢迎转载,与人分享是进步的源泉!
    转载请保留原文地址:https://blog.csdn.net/qq446282412/article/details/84068255
    如果本文对您有所帮助,欢迎您扫码下图所示的支付宝和微信支付二维码对本文进行打赏。

    image

    相关文章

      网友评论

          本文标题:【我的Android进阶之旅】Proguard混淆配置错误导致混

          本文链接:https://www.haomeiwen.com/subject/dwhacqtx.html