{"id":39710181,"url":"https://github.com/jdvp/androidaspectexample","last_synced_at":"2026-04-24T02:00:54.918Z","repository":{"id":41882159,"uuid":"139641305","full_name":"jdvp/AndroidAspectExample","owner":"jdvp","description":"Project to show examples of leveraging Aspect-Oriented Programming techniques","archived":false,"fork":false,"pushed_at":"2026-04-14T08:12:14.000Z","size":832,"stargazers_count":27,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-14T10:10:15.479Z","etag":null,"topics":["android","android-aspectj","aop","aspect-oriented-programming","aspectj"],"latest_commit_sha":null,"homepage":"https://jdvp.me/articles/AOP-in-Android","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jdvp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-07-03T22:04:02.000Z","updated_at":"2026-04-14T08:10:15.000Z","dependencies_parsed_at":"2023-11-12T06:22:41.440Z","dependency_job_id":"843854e1-217b-4720-9630-aba0fcd70cf5","html_url":"https://github.com/jdvp/AndroidAspectExample","commit_stats":null,"previous_names":[],"tags_count":74,"template":false,"template_full_name":null,"purl":"pkg:github/jdvp/AndroidAspectExample","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdvp%2FAndroidAspectExample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdvp%2FAndroidAspectExample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdvp%2FAndroidAspectExample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdvp%2FAndroidAspectExample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdvp","download_url":"https://codeload.github.com/jdvp/AndroidAspectExample/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdvp%2FAndroidAspectExample/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32205942,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T01:12:49.758Z","status":"online","status_checked_at":"2026-04-24T02:00:07.115Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-aspectj","aop","aspect-oriented-programming","aspectj"],"created_at":"2026-01-18T10:37:44.471Z","updated_at":"2026-04-24T02:00:54.911Z","avatar_url":"https://github.com/jdvp.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"## AndroidAspectExample\nProject to show examples of leveraging Aspect-Oriented Programming (AOP) techniques\n\nAspects are defined in AspectLogging.java and affect MainActivity.java. \nIn order to see that the code has been injected, build the app and check the app/build directory for the \najc-transform.log file which will show which advices have been added to the project during the build process.\n\nIf you run the app, the aspects added will simply log when a button is clicked or onCreate happens.\n\nCreated as a sample for my article \"[Aspect-Oriented Programming in Android]\".\n\n## Releases\nPlease see the [GitHub Releases Page]\nfor this example if you want to see details for a specific Android Gradle Plugin (AGP) version.\nEach release version for this sample project will correspond to the same AGP version.\n\n## Notes\n\n### Important: AGP 9.0.0 and AndroidAspectExample EOL\n\nIt seems this project is on its last legs with the introduction of AGP 9.0.0. It shouldn't matter too\nmuch since this is just a sample project, but heads up that since AGP will be updating their DSL in 9.0.0\nand removing it in the near future, this project will stop working. This is because the underlying \nAspect library [gradle-aspectj-pipeline-plugin] is no longer maintained since 2023 so has not updated\nto the new DSL. \n\nFor now, i.e. at least the first major release of AGP 9, this can be worked around by using the following\nflag in `gradle.properties`:\n\n```text\nandroid.newDsl=false\n```\n\nAs mentioned below, I do not personally recommend AspectJ anymore but if you still prefer to use it,\nthere do seem to be alternatives out there under active development, such as [AndroidAOP]. I have not\npersonally vetted that library but it does appear to be pretty active and have a decent amount of stars. \n\nThis project will be updated until the `newDsl` flag is removed after which I will probably archive the project.\n\n#### Plugin Change\n\nAs of v4.1.0, this sample project leverages the following Gradle Plugin for weaving aspects:\n\n[gradle-aspectj-pipeline-plugin]\n\nPreviously, this project was leveraging [android-gradle-aspectj].\nFor information on why I made the switch, you might be interested in reading my article \"[Switching AspectJ Plugins in Android]\".\n\nCode required using either plugin is the same since they both use the same aspectjrt library under the hood. The only difference is the required plugin setup in our gradle files.\n\n#### Kotlin 1.5.0 Support\n\nThis is more of an issue with AspectJ than this project or even the gradle-aspectj-pipeline-plugin project, but Kotlin code compiled with Kotlin version 1.5.0 now uses invokedynamic to to compile Single Abstract Method functions ([see here] for information in the documentation). This means that lambdas in Kotlin using this version or above will not be weaved as expected as the compiled bytecode will not be able to be matched by AspectJ pointcuts.\n\nTo get around this for now, enable the following in project-level build.gradle files:  \n```groovy\nkotlinOptions {\n    freeCompilerArgs = [\"-Xsam-conversions=class\"]\n}\n```\n\nIf you are using a version of Kotlin/AGP where `kotlinOptions` has been deprecated or removed, you can use the following\n```groovy\nkotlin {\n    compilerOptions {\n        freeCompilerArgs = [\"-Xsam-conversions=class\"]\n    }\n}\n```\n\n\nYou can read more about the issue [here] if interested.\n\n#### Using newer versions of AspectJ\n\nIf you are using AspectJ for some other reason and so want to leverage a different version of the library\nother than the one suggested by the Ibotta Plugin (1.9.6), which is used to compile the plugin, you can\ngenerally do so freely up until version 1.9.21 of the AspectJ Plugin (`org.aspectj:aspectjrt`).\n\nIf you have a minSdk of 25 or lower, 1.9.22 will likely give you problems. My testing seems to indicate \nthat this can be fixed by [desugaring].\n\nFirst, make sure the requisite compile option is set\n```groovy\ncompileOptions {\n    coreLibraryDesugaringEnabled true\n}\n```\n\nThen, include the desugaring dependency\n```groovy\ncoreLibraryDesugaring(\"com.android.tools:desugar_jdk_libs:2.0.4\")\n```\n\nMake sure to update this dependency to latest as required.\n\n#### Why I don't recommend AOP in 2023\n\nIn late January 2023, the AOP plugin that this project uses, [gradle-aspectj-pipeline-plugin], indicated\nthat the project would no longer be maintained due to issues with the upcoming AGP 8.0.0 updates removing\nrequired APIs. In response, I wrote \"[Why I Don't Recommend Aspect-Oriented Programming in Android in 2023]\",\nan article that explains why I would be hesitant to use AOP in an enterprise application in 2023.\n\nI did do some research and came to the conclusion that the plugin [would not be broken] by AGP 8.0.0\nand as such I will continue updating this sample project (playing both sides??) until the plugin\nbegins to stop working with AGP or Kotlin updates. \n\nThat being said, even though I am going to continue updating this sample app for the foreseeable future,\nI would recommend reading \"[Why I Don't Recommend Aspect-Oriented Programming in Android in 2023]\"\nand really thinking about if you actually need to leverage AOP in your project before continuing on\nand playing around with the sample project.\n\n\n[Aspect-Oriented Programming in Android]: https://jdvp.me/articles/AOP-in-Android\n[GitHub Releases Page]: https://github.com/jdvp/AndroidAspectExample/releases\n[gradle-aspectj-pipeline-plugin]: https://github.com/Ibotta/gradle-aspectj-pipeline-plugin\n[android-gradle-aspectj]: https://github.com/Archinamon/android-gradle-aspectj\n[Switching AspectJ Plugins in Android]: https://jdvp.me/articles/Switching-AspectJ-Plugins-Android\n[see here]: https://kotlinlang.org/docs/whatsnew15.html#sam-adapters-via-invokedynamic\n[here]: https://github.com/Ibotta/gradle-aspectj-pipeline-plugin/issues/8\n[Why I Don't Recommend Aspect-Oriented Programming in Android in 2023]: https://jdvp.me/articles/AOP-in-Android-2023\n[would not be broken]: https://github.com/Ibotta/gradle-aspectj-pipeline-plugin/issues/34\n[desugaring]: https://android-developers.googleblog.com/2023/02/api-desugaring-supporting-android-13-and-java-nio.html\n[AndroidAOP]: https://github.com/FlyJingFish/AndroidAOP","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdvp%2Fandroidaspectexample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdvp%2Fandroidaspectexample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdvp%2Fandroidaspectexample/lists"}