HujiangTechnology / gradle_plugin_android_aspectjx

A Android gradle plugin that effects AspectJ on Android project and can hook methods in Kotlin, aar and jar file.
Apache License 2.0
3.95k stars 570 forks source link

java.util.zip.ZipException: zip file is empty #277

Open tuke0919 opened 4 years ago

tuke0919 commented 4 years ago

条件: // aspectjx classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.8' apply plugin: 'android-aspectjx' aspectjx { // AspectJX功能 enabled true exclude 'com.tencent', 'androidx', 'com.google', 'com.squareup', 'com.alipay', 'org.apache', 'com.alipay', 'com.facebook', 'cn.jiguang', 'com.github', 'com.meizu', 'com.huawei', 'com.qiyukf', 'com.sina', 'io.reactivex', 'de.greenrobot.event', 'com.netease.neliveplayer', 'com.umeng', 'im.yixin', 'com.commonsware', 'io.fabric', 'rx.android', 'com.android' } AGP版本:3.1.4 Grade:5.1.1 代码: ` @Aspect public class AspectJx {

public static final String TAG = "AspectJx";

@Pointcut("execution(@com.xxx.vopen.aspectjx.ExecutionTime * *(..))")
public void executionTimePointCut(){
}

@Around("executionTimePointCut()")
public void executionTime(ProceedingJoinPoint joinPoint) {
    PalUiLog.d(TAG, "executionTime:");

    try {
        if (BuildConfig.DEBUG) {
            MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
            ExecutionTime executionTime = methodSignature.getMethod().getAnnotation(ExecutionTime.class);
            if (executionTime != null) {
                long start = System.currentTimeMillis();
                joinPoint.proceed();
                long end = System.currentTimeMillis();

                Object object = joinPoint.getTarget();
                String className = "";
                if (object != null) {
                    className = object.getClass().getName();
                }
                String methodName = methodSignature.getMethod().getName();
                PalUiLog.d(TAG, "executionTime: " + className + "_" + methodName + ":" + (end - start) + "ms" );
            } else {
                joinPoint.proceed();
            }
        } else {
            joinPoint.proceed();
        }

    } catch (Throwable throwable) {
        PalUiLog.d(TAG, "executionTime:" + throwable.getMessage());
        throwable.printStackTrace();
    }

}

} `

studio编译异常,求大神解答呀

Task :app:transformClassesWithDexBuilderForDebug FAILED java.util.zip.ZipException: zip file is empty at java.util.zip.ZipFile.open(Native Method) at java.util.zip.ZipFile.(ZipFile.java:225) at java.util.zip.ZipFile.(ZipFile.java:279) at com.android.tools.r8.ArchiveClassFileProvider.(ArchiveClassFileProvider.java:63) at com.android.tools.r8.ArchiveClassFileProvider.(ArchiveClassFileProvider.java:50) at com.android.builder.dexing.r8.CachingArchiveClassFileProvider.(CachingArchiveClassFileProvider.java:32) at com.android.builder.dexing.r8.ClassFileProviderFactory.createProvider(ClassFileProviderFactory.java:123) at com.android.builder.dexing.r8.ClassFileProviderFactory.(ClassFileProviderFactory.java:93) at com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform.transform(DexArchiveBuilderTransform.java:348) at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:239) at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:235) at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102) at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:230) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73) at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:47) at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:41) at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:28) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$2.run(ExecuteActionsTaskExecuter.java:284) at

fengyun703 commented 4 years ago

我这也出现这个问题。查到是语法写的有问题。可以Build Output 上部,会有红色提示的,不是Exception部分。

Invalid pointcut 'execution(@ExecuteTime (..)': org.aspectj.weaver.patterns.ParserException: ) at position 0 Invalid pointcut 'execution(@ExecuteTime (..)': org.aspectj.weaver.patterns.ParserException: ) at position 0

Task :app:transformClassesWithAjxForDebug :app:transformClassesWithAjxForDebug spend 489ms

Task :app:transformClassesWithDexBuilderForDebug FAILED com.android.builder.dexing.JarClassFileInput$JarClassFileInputsException: Unable to read jar file

menshen commented 2 years ago

I use include to fix this error. you can use exlude to fix this error, but i think exlude is unscientific. like this aspectjx { include 'com.macoli.marslog' }