hujiangtechnology / gradle_plugin_android_aspectjx Goto Github PK
View Code? Open in Web Editor NEWA Android gradle plugin that effects AspectJ on Android project and can hook methods in Kotlin, aar and jar file.
License: Apache License 2.0
A Android gradle plugin that effects AspectJ on Android project and can hook methods in Kotlin, aar and jar file.
License: Apache License 2.0
Error:Execution failed for task ':aspectjx-demo:transformClassesWithAspectTransformForDebug'.
can't determine superclass of missing type android.support.v7.widget.CardView
when weaving type android.databinding.adapters.CardViewBindingAdapter
when weaving classes
when weaving
when batch building BuildConfig[null] #Files=0 AopXmls=#0
[Xlint:cantFindType]
比如我想修改java.net.Socket这个文件可以吗
谢谢!
org.aspectj:aspectjrt 对应的表达式在哪里可以看的?谢谢
如题,因为aspectjx插件是放在jcenter**库,如果出现插件拉不下来的情况,可以将jcenter的地址改为http
协议拉取,这样可以拉取成功,如:
buildScript {
repositories {
jcenter() {
url 'http://jcenter.bintray.com/'
}
}
}
实在不行可以通过依赖本地jar的方式来达到目的。
运行android_permission_aspectjx时报错:
java.lang.NoSuchMethodError: com.firefly1126.permissionaspect.aspect.PermissionAspect.aspectOf
Getting this error message when running instrumentation tests (androidTest
) both in my project and in AspectJX-Demo project:
Execution failed for task ':app:transformClassesWithAspectTransformForDebugAndroidTest'.
> classpath error: unable to find org.aspectj.lang.JoinPoint (check that aspectjrt.jar is in your classpath)
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesWithAspectTransformForDebugAndroidTest'.
Caused by: java.lang.NoClassDefFoundError: com/android/builder/signing/SignedJarBuilder$IZipEntryFilter
16:11:06.173 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.hujiang.gradle.plugin.android.aspectjx.AspectTransform.transform(AspectTransform.groovy:147)
16:11:06.173 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.api.transform.Transform.transform(Transform.java:290)
16:11:06.173 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:178)
16:11:06.173 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:174)
16:11:06.173 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:156)
16:11:06.173 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:173)
16:11:06.173 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
16:11:06.173 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:158)
16:11:06.173 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:129)
16:11:06.173 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:118)
16:11:06.173 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
16:11:06.173 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
16:11:06.173 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] ... 68 more
`Error:Execution failed for task ':app:transformClassesWithAspectTransformForDevDebug'.
can't determine superclass of missing type android.hardware.fingerprint.FingerprintManager$AuthenticationCallback
when weaving type android.support.v4.hardware.fingerprint.FingerprintManagerCompatApi23$1
when weaving classes
when weaving
when batch building BuildConfig[null] #Files=0 AopXmls=#0
[Xlint:cantFindType]`
我的目录结构最开始为:
---app
---aspjx1
其中app中也有切面编程的东西,此时打包是正常的
我就想把app中的切面编程移除来,变成:
---app
---aspjx1
---aspjx2
然后就报上述错误了
If you enable build-cache, then exploded jar will store in directory like
/Users/2dxgujun/.android/build-cache/a38fde34e54ce5d6da3f0f6f50d29f612279957f/output/jars/classes.jar
How to locate file?
比如我想在vollry request类的add方法前做一些事情
代码如下:
@before("call(* com.android.volley.RequestQueue.add(..))")
public void onGetVolleyHttpBefore(JoinPoint joinPoint) throws Throwable{
Log.v(TAG,"volley lib send request");
Object[] objects=joinPoint.getArgs();
Request request=(Request)objects[0];
Log.v(TAG,"volley lib request method="+request.getMethod());
String url=request.getUrl();
Log.v(TAG,"volley lib request url="+url);
}
不生效,为什么?求大神
是这样的:我想hook我们子工程中一个jar里面的一个类,但是include这个jar之后,会出现其中一个类superclass cantFindType的问题(因为这个jar编译的时候排除了一个类);exclude这个jar就不能实现我的需求。
谢谢=。=
Error:Execution failed for task ':app:transformClassesWithAspectTransformForDebug'.
can't determine modifiers of missing type com.yjl.test.external
when weaving type com.qihoo.apmsdkdemo.MainActivity
when weaving classes
when weaving
when batch building BuildConfig[null] #Files=2 AopXmls=#0
[Xlint:cantFindType]
错误如上所示
missing的类( com.yjl.test.external)是在jar包里,但是这个jar包是provided的方式引入的,如果不做aop是可以编译通过的,但是加上aop之后,就无法编译通过,不知道这个如何处理
我用provided方式引入jar的的场景是想调用系统不公开的api,比如PackageParser
混淆后就不工作了,请问这个如何混淆
Error:Execution failed for task ':app:transformClassesWithAspectTransformForDebug'.
Cannot read debug info for @aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)
我写了一个带@aspect的jar包加入工程中,如果是用IDE Export的jar包,就可以正常编译且aspect生效。现在我想用Ant给部分代码混淆,重新生成jar以后,编译时就出现了以上这个错误。
代码:
@aspect
public class SingleClickAspect {
static int TIME_TAG = 10000;
public static final int MIN_CLICK_DELAY_TIME = 600;
@Around("execution(* android.view.View.OnClickListener.onClick(..))")
public void aroundJoinPoint(ProceedingJoinPoint joinPoint) throws Throwable {
View view = null;
for (Object arg : joinPoint.getArgs())
if (arg instanceof View) view = (View) arg;
if (view != null) {
Object tag = view.getTag(TIME_TAG);
long lastClickTime = ((tag != null) ? (long) tag : 0);
KLog.debug("SingleClickAspect", "lastClickTime:" + lastClickTime);
long currentTime = Calendar.getInstance().getTimeInMillis();
if (currentTime - lastClickTime > MIN_CLICK_DELAY_TIME) {//过滤连续点击
view.setTag(TIME_TAG, currentTime);
KLog.debug("SingleClickAspect", "currentTime:" + currentTime);
joinPoint.proceed();
}
}
}
}
报错信息:
Error:Execution failed for task ':app:transformClassesWithDexForAppDebug'.
com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Return code 1 for dex process
Error:1 error; aborting
Error:Uncaught translation error: com.android.dx.cf.code.SimException: local variable type mismatch: attempt to set or access a value of type java.lang.Object using a local variable of type int. This is symptomatic of .class transformation tools that ignore local variable information.
删除around定义的代码块后即可正常运行,clean和rebuild也试过,均无用。求助,谢谢
Android Studio 3,Java 8,报了这样的错,而且貌似和hugo不兼容
org.aspectj.apache.bcel.classfile.ClassFormatException: File: '/Users/dzc/Desktop/Luoo_Android/app/build/intermediates/transforms/AspectTransform/developer/debug/folders/1/1f/aspect/net/luoo/LuooFM/activity/common/RecommendationCommentsActivity$2.class': Invalid byte tag in constant pool: 43 at org.aspectj.apache.bcel.classfile.ClassParser.readConstantPool(ClassParser.java:192) at org.aspectj.apache.bcel.classfile.ClassParser.parse(ClassParser.java:131) at org.aspectj.weaver.bcel.Utility.makeJavaClass(Utility.java:472) at org.aspectj.weaver.bcel.BcelWeaver.processReweavableStateIfPresent(BcelWeaver.java:1392) at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1098) at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.weaveQueuedEntries(AjPipeliningCompilerAdapter.java:514) at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.afterCompiling(AjPipeliningCompilerAdapter.java:375) at org.aspectj.ajdt.internal.compiler.CompilerAdapter.ajc$afterReturning$org_aspectj_ajdt_internal_compiler_CompilerAdapter$2$f9cc9ca0(CompilerAdapter.aj:78) at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:471) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:1036) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performBuild(AjBuildManager.java:272) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:185) at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:112) at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:60) at org.aspectj.tools.ajc.Main.run(Main.java:371) 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.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSite.invoke(PojoMetaMethodSite.java:192) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133) at com.hujiang.gradle.plugin.android.aspectjx.AspectWork.doWork(AspectWork.groovy:89) at com.hujiang.gradle.plugin.android.aspectjx.AspectWork$doWork$0.call(Unknown Source) at com.hujiang.gradle.plugin.android.aspectjx.AspectTransform.doAspectTransform(AspectTransform.groovy:174) 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.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:174) at com.hujiang.gradle.plugin.android.aspectjx.AspectTransform.transform(AspectTransform.groovy:100) at com.android.build.api.transform.Transform.transform(Transform.java:290) at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:185) at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:181) at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102) at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:176) at sun.reflect.GeneratedMethodAccessor1445.invoke(Unknown Source) 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.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:163) 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:123) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.execute(ExecuteActionsTaskExecuter.java:115) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.execute(ExecuteActionsTaskExecuter.java:109) at org.gradle.internal.Transformers$4.transform(Transformers.java:169) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:56) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:109) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:90) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:68) at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62) 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:46) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51) 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.execute(DefaultTaskGraphExecuter.java:236) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:228) at org.gradle.internal.Transformers$4.transform(Transformers.java:169) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:61) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:228) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:215) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:77) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:58) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:46) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)
被@aspect注解过的类,反编译后正常情况下会有以下代码,现在没有了,报找不到AdviceProcessor.aspectOf()错误,不知道什么原因会造成该现象。
private static Throwable ajc$initFailureCause;
public static final AdviceProcessor ajc$perSingletonInstance;
static
{
try
{
ajc$postClinit();
return;
}
catch (Throwable localThrowable)
{
ajc$initFailureCause = localThrowable;
}
}
private static void ajc$postClinit()
{
ajc$perSingletonInstance = new AdviceProcessor();
}
public static AdviceProcessor aspectOf()
{
if (ajc$perSingletonInstance == null)
throw new NoAspectBoundException("com.qiangqu.shandiangou.apptrace.annotation.AdviceProcessor", ajc$initFailureCause);
return ajc$perSingletonInstance;
}
public static boolean hasAspect()
{
return ajc$perSingletonInstance != null;
}
当 aspectjx 不是第一个被应用时,JarInput 的路径(举个例子:excludeJar:::/Users/.../.../app/build/intermediates/transforms/.../alpha/jars/1/10/e57ebac67c347bc2985e94932aa28dc58f848c3c.jar)无法作为判断条件,可能导致 aspectjx 找不到需要处理的文件
导致其他插件的可能无法正常执行 Transform JavaDoc
It is best practice to write into as many outputs as Jar/Folder Inputs have been received by the transform. Combining all the inputs into a single output prevents downstream transform from processing limited scopes.
Binh
05-07 14:59:31.935 16135-16135/com.example.lenovo.androidaop W/FeatureConfig: Could not get this feature:is_support_double_system, value is null
java.lang.Throwable
at com.yulong.android.feature.FeatureConfig.getIntValue(FeatureConfig.java:470)
at com.yulong.android.server.systeminterface.SystemInterfaceImpl.isSupportDoubleOS(SystemInterfaceImpl.java:5295)
at com.yulong.android.server.systeminterface.SystemInterfaceImpl.(SystemInterfaceImpl.java:5678)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:251)
at java.lang.Class.forName(Class.java:216)
at com.yulong.android.reflect.YLReflect.Load_class(YLReflect.java:59)
at com.yulong.android.reflect.YLReflect.(YLReflect.java:40)
at android.app.ContextImpl$49.createService(ContextImpl.java:683)
at android.app.ContextImpl$ServiceFetcher.getService(ContextImpl.java:281)
at android.app.ContextImpl.getSystemService(ContextImpl.java:1760)
at android.media.AudioManager.(AudioManager.java:454)
at android.app.ContextImpl$7.createService(ContextImpl.java:368)
at android.app.ContextImpl$ServiceFetcher.getService(ContextImpl.java:281)
at android.app.ContextImpl.getSystemService(ContextImpl.java:1760)
at android.view.ContextThemeWrapper.getSystemService(ContextThemeWrapper.java:117)
at android.app.Activity.getSystemService(Activity.java:4590)
at android.view.ViewRootImpl.getAudioManager(ViewRootImpl.java:5570)
at android.view.ViewRootImpl.playSoundEffect(ViewRootImpl.java:5658)
at android.view.View.playSoundEffect(View.java:17276)
at android.view.View.performClick(View.java:4462)
at android.view.View$PerformClick.run(View.java:18772)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5367)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:663)
at dalvik.system.NativeStart.main(Native Method)
Under android studio 3.0 & gradle 4.1 milestone, I encountered the compile error:
Caused by: java.lang.RuntimeException: Unexpected scopes found in folder '/app/build/intermediates/transforms/AspectTransform/debug'. Required: PROJECT, SUB_PROJECTS, EXTERNAL_LIBRARIES. Found: EXTERNAL_LIBRARIES, PROJECT, PROJECT_LOCAL_DEPS, SUB_PROJECTS, SUB_PROJECTS_LOCAL_DEPS at com.android.build.gradle.internal.pipeline.IntermediateFolderUtils.makeRestrictedCopies(IntermediateFolderUtils.java:455) at com.android.build.gradle.internal.pipeline.IntermediateFolderUtils.<init>(IntermediateFolderUtils.java:66) at com.android.build.gradle.internal.pipeline.IntermediateStream.init(IntermediateStream.java:191) at com.android.build.gradle.internal.pipeline.IntermediateStream.asNonIncrementalInput(IntermediateStream.java:146) at com.android.build.gradle.internal.pipeline.TransformTask.computeNonIncTransformInput(TransformTask.java:281) at com.android.build.gradle.internal.pipeline.TransformTask.access$500(TransformTask.java:70) at com.android.build.gradle.internal.pipeline.TransformTask$1.call(TransformTask.java:196) at com.android.build.gradle.internal.pipeline.TransformTask$1.call(TransformTask.java:157) at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102) at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:152) at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73) at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:168) 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)
I checked the build output dir, and there is a exactly a AspectTransform directory. maybe gradle considers it invalid?
I'm also working with hugo, and knows that our plugin works the same as hugo in the AspectJ part, so i made a compartion of source code between them.
the Hugo plugin is as follows:
JavaCompile javaCompile = variant.javaCompile javaCompile.doLast { String[] args = [ "-showWeaveInfo", "-1.5", "-inpath", javaCompile.destinationDir.toString(), "-aspectpath", javaCompile.classpath.asPath, "-d", javaCompile.destinationDir.toString(), "-classpath", javaCompile.classpath.asPath, "-bootclasspath", project.android.bootClasspath.join(File.pathSeparator) ] log.debug "ajc args: " + Arrays.toString(args) ......
and our plugin:
`def args = [
"-showWeaveInfo",
"-encoding", encoding,
"-source", sourceCompatibility,
"-target", targetCompatibility,
"-d", destinationDir,
"-classpath", classPath.join(File.pathSeparator),
"-bootclasspath", bootClassPath
]
if (!getInPath().isEmpty()) {
args << '-inpath'
args << getInPath().join(File.pathSeparator)
}
if (!getAspectPath().isEmpty()) {
args << '-aspectpath'
args << getAspectPath().join(File.pathSeparator)
}`
i doubt that the output dir differs, which caused gradle report this exception.
您好,我想插入aspetcjx的时候,不插桩任何第三方包,下面这个配置需要在哪里面配置呢
aspectjx {
excludeJarFilter '.jar'
}
Error:Execution failed for task ':app:transformClassesWithAspectTransformForFullDebug'.
trouble in:
public class com.eg.odk.client.utils.NameValuePairComparator extends java.lang.Object implements java.util.Comparator:
public void ():
ALOAD_0 // Lcom/eg/odk/client/utils/NameValuePairComparator; this (line 14)
INVOKESPECIAL java.lang.Object. ()V
constructor-execution(void com.eg.odk.client.utils.NameValuePairComparator.())
| RETURN
constructor-execution(void com.eg.odk.client.utils.NameValuePairComparator.())
end public void ()
public int compare(org.apache.http.NameValuePair, org.apache.http.NameValuePair):
ALOAD_1 // Lorg/apache/http/NameValuePair; lhs (line 17)
INVOKEINTERFACE org.apache.http.NameValuePair.getName ()Ljava/lang/String;
ALOAD_2 // Lorg/apache/http/NameValuePair; rhs
INVOKEINTERFACE org.apache.http.NameValuePair.getName ()Ljava/lang/String;
INVOKEVIRTUAL java.lang.String.compareTo (Ljava/lang/String;)I
IRETURN
end public int compare(org.apache.http.NameValuePair, org.apache.http.NameValuePair)
public volatile int compare(Object, Object):
ALOAD_0 // Lcom/eg/odk/client/utils/NameValuePairComparator; this (line 14)
ALOAD_1 // Ljava/lang/Object; x0
CHECKCAST org.apache.http.NameValuePair
ALOAD_2 // Ljava/lang/Object; x1
CHECKCAST org.apache.http.NameValuePair
INVOKEVIRTUAL com.eg.odk.client.utils.NameValuePairComparator.compare (Lorg/apache/http/NameValuePair;Lorg/apache/http/NameValuePair;)I
IRETURN
end public volatile int compare(Object, Object)
end public class com.eg.odk.client.utils.NameValuePairComparator
com.eg.odk 是引用的第三方包
java.lang.NoClassDefFoundError: com/android/builder/signing/SignedJarBuilder$IZipEntryFilter
at com.hujiang.gradle.plugin.android.aspectjx.AspectTransform.transform(AspectTransform.groovy:147)
这个类在plugin 2.2中已经不再提供了
Error:Execution failed for task ':app:transformClassesWithExtractJarsForDebug'.
error
新建project,只修改了两个build.gradle,clean不报错,运行时提示这个
环境:
AS 2.2.3
compileSdkVersion 25
buildToolsVersion "25.0.2"
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:1.0.8'
我想对Activity中的performCreate(Bundle icicle)方法进行hook,可以实现么?
1.0.5
版本在多渠道打包,或者多build type打包,并且加混淆(特别是使用了dexguard混淆)的情况下,打出的渠道包运行会出现NoSuchMethodError
。
现在1.0.6
版本已经解决了这个问题。出现这个问题的伙伴可以升级到1.0.6
版本使用。
com.hujiang.aspectjx:gradle-android-plugin-aspectjx:1.0.6
Hi, I am trying to use aspects on an android project but build failed with the exception
Execution failed for task ':app:transformClassesWithExtractJarsForInternalDebug'.
Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesWithExtractJarsForInternalDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
...
Caused by: java.lang.RuntimeException: error
at com.android.build.gradle.internal.pipeline.IntermediateFolderUtils.parseScopeLevelFolders(IntermediateFolderUtils.java:444)
at com.android.build.gradle.internal.pipeline.IntermediateFolderUtils.parseTypeLevelFolders(IntermediateFolderUtils.java:411)
at com.android.build.gradle.internal.pipeline.IntermediateFolderUtils.computeNonIncrementalInputFromFolder(IntermediateFolderUtils.java:116)
at com.android.build.gradle.internal.pipeline.IntermediateStream.asNonIncrementalInput(IntermediateStream.java:132)
at com.android.build.gradle.internal.pipeline.TransformTask.computeNonIncTransformInput(TransformTask.java:246)
What I did to use aspectJX
My objective is to add a join point in android.context.Context.
Note: my app has 2 "flavors" (public and internal), hence the "transform...InternalDebug", and no join point has been defined yet.
Did I miss something ?
Thanks
ABORT
org.aspectj.weaver.BCException: Whilst processing type 'Lcom/squareup/haha/guava/collect/Iterables$2;' - cannot cast the outer type to a reference type. Signature=Lcom/squareup/haha/guava/collect/Iterables; toString()=com.squareup.haha.guava.collect.Iterables class=Iterables
when processing type mungers
when weaving
when batch building BuildConfig[null] #Files=0 AopXmls=#0
No static method aspectOf()Lcom/gd/ge/aop/FragmentAspectj; 这个好像是没有注入成功,要怎么解决啊
I want to create a common error handler for a library class by means of your plugin. Is it possible at all? Can I do it without too much affecting client code, I mean if I do so, will client code be able to use instant run and other features?
`
Unexpected scopes found in folder '/home/fenggang/Desktop/AndridTips/AspectApp/build/intermediates/transforms/AspectTransform/debug'. Required: PROJECT, SUB_PROJECTS, EXTERNAL_LIBRARIES. Found: EXTERNAL_LIBRARIES, PROJECT, PROJECT_LOCAL_DEPS, SUB_PROJECTS, SUB_PROJECTS_LOCAL_DEPS
`
如题
环境是studio 3.0,项目中使用了retrolambda,所以Java升级到了1.8,错误如下:
Caused by: org.aspectj.apache.bcel.classfile.ClassFormatException: File: '/path/to/package/WebViewActivity.class': Invalid byte tag in constant pool: 17 at org.aspectj.apache.bcel.classfile.ClassParser.readConstantPool(ClassParser.java:192) at org.aspectj.apache.bcel.classfile.ClassParser.parse(ClassParser.java:131) at org.aspectj.weaver.bcel.Utility.makeJavaClass(Utility.java:472) at org.aspectj.weaver.bcel.BcelWeaver.processReweavableStateIfPresent(BcelWeaver.java:1392) at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1098) at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.weaveQueuedEntries(AjPipeliningCompilerAdapter.java:514) at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.afterCompiling(AjPipeliningCompilerAdapter.java:375) at org.aspectj.ajdt.internal.compiler.CompilerAdapter.ajc$afterReturning$org_aspectj_ajdt_internal_compiler_CompilerAdapter$2$f9cc9ca0(CompilerAdapter.aj:78) at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:471) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:1036) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performBuild(AjBuildManager.java:272) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:185) at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:112) at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:60) at org.aspectj.tools.ajc.Main.run(Main.java:371) at com.hujiang.gradle.plugin.android.aspectjx.AspectWork.doWork(AspectWork.groovy:89) ... 46 more
如题,不是以 jar 包导入的方式引进的库是不是不生效?
While using the aspectjx plugin, when I set the compile options to Java 8 and enable the jack toolchain,
` android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
jackOptions {
enabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
`
the build fails with the error:
Error:Cannot cast object 'task ':app:transformJackWithJackForDebug'' with class 'com.android.build.gradle.internal.pipeline.TransformTask_Decorated' to class 'org.gradle.api.tasks.compile.JavaCompile'
Using:
Hi,
When i tried to import the 'deprecated' plugin as stated on this page: http://blog.egorand.me/going-aspect-oriented-with-aspectj-and-google-analytics/ it worked:
buildscript {
...
dependencies {
...
classpath 'com.uphyca.gradle:gradle-android-aspectj-plugin:0.9.14'
}
}
However if I try to use the new one like you mention in 'How to use' section:
dependencies {
classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:1.0.5'
}
gradle fails to find it. Looks like it's not there?
如题,如果我想hook应用内所有try catch语句中的 catch代码块,那不是整个应用都无法混淆了么;另外,我理解这种方案其实就是在编译期将advice注入到代码中,和字节码注入有点类似,只要是在混淆之前注入的,按理说应该混淆了页没关系啊
因为你们现在使用的方式,是在lib里面不处理aspectj,在主工程处理,这样会导致会扫描所有包,虽然能用includeJar的方式,但是acpectj花费的时间还是要1分钟
你看这样可不可以,只在对应工程处理自己内部的aspectj,这样如果是aar或者maven依赖的话,就不用在扫描里面的了
还有你可以看看这个http://www.jianshu.com/p/814315922353,看看有没有可以吸取的**,提高编译速度
this is some of my app gradle file:
buildscript {
repositories {
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'org.aspectj:aspectjtools:1.8.10'
classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:1.0.11'
}
}
apply plugin: 'com.android.application'
apply plugin: 'android-aspectjx'
However, I get the following error, why?
org.aspectj.weaver.BCException: Unable to find Asm for stackmap generation (Looking for 'aj.org.objectweb.asm.ClassReader'). Stackmap generation for woven code is required to avoid verify errors on a Java 1.7 or higher runtime
Following the upgrade to Android Studio 3.0, ABT 3.0.0-beta2 with Gradle 4.1-rc-1 no weaving is occurring and the logs state;
:app:transformClassesWithAspectTransformForWithGoogleDebug
there is no aspectjrt dependencies in classpath, do nothing
directoryInput = 77e0d0e28e0bed23d54a35ca22a685be0ff20e71
jarInput = org.jacoco:org.jacoco.agent:0.7.4.201502262128
jarInput = org.aspectj:aspectjrt:1.8.9
My configuration was working as expected with Gradle 3.4 and ABT 2.3.3.
Specifically the errors emanate from;
static final ASPECTJRT = "aspectjrt"
...
def hasAjRt = false
for (TransformInput transformInput : inputs) {
for (JarInput jarInput : transformInput.jarInputs) {
if (jarInput.file.absolutePath.contains(ASPECTJRT)) {
hasAjRt = true
break
}
}
if (hasAjRt) break
}
}
Rest assured, the rest of the configuration is to standard;
build.gradle
buildscript {
dependencies {
classpath "com.android.tools.build:gradle:3.0.0-beta2"
classpath "org.aspectj:aspectjtools:1.8.9"
...
}
}
module.gradle
dependencies {
api "org.aspectj:aspectjrt:1.8.9"
}
root gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:1.0.2'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
lib gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'org.aspectj:aspectjrt:1.8.1'
}
app gradle
apply plugin: 'com.android.application'
apply plugin: 'android-aspectjx'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.mysmalldemo.myaopsample"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile project(':aoplib')
compile 'org.aspectj:aspectjrt:1.8.1'
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.