Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,27 @@ Each release version for this sample project will correspond to the same AGP ver

## Notes

### Important: AGP 9.0.0 and AndroidAspectExample EOL

It seems this project is on its last legs with the introduction of AGP 9.0.0. It shouldn't matter too
much since this is just a sample project, but heads up that since AGP will be updating their DSL in 9.0.0
and removing it in the near future, this project will stop working. This is because the underlying
Aspect library [gradle-aspectj-pipeline-plugin] is no longer maintained since 2023 so has not updated
to the new DSL.

For now, i.e. at least the first major release of AGP 9, this can be worked around by using the following
flag in `gradle.properties`:

```text
android.newDsl=false
```

As mentioned below, I do not personally recommend AspectJ anymore but if you still prefer to use it,
there do seem to be alternatives out there under active development, such as [AndroidAOP]. I have not
personally vetted that library but it does appear to be pretty active and have a decent amount of stars.

This project will be updated until the `newDsl` flag is removed after which I will probably archive the project.

#### Plugin Change

As of v4.1.0, this sample project leverages the following Gradle Plugin for weaving aspects:
Expand All @@ -38,6 +59,16 @@ kotlinOptions {
}
```

If you are using a version of Kotlin/AGP where `kotlinOptions` has been deprecated or removed, you can use the following
```groovy
kotlin {
compilerOptions {
freeCompilerArgs = ["-Xsam-conversions=class"]
}
}
```


You can read more about the issue [here] if interested.

#### Using newer versions of AspectJ
Expand Down Expand Up @@ -90,3 +121,4 @@ and playing around with the sample project.
[Why I Don't Recommend Aspect-Oriented Programming in Android in 2023]: https://jdvp.me/articles/AOP-in-Android-2023
[would not be broken]: https://github.com/Ibotta/gradle-aspectj-pipeline-plugin/issues/34
[desugaring]: https://android-developers.googleblog.com/2023/02/api-desugaring-supporting-android-13-and-java-nio.html
[AndroidAOP]: https://github.com/FlyJingFish/AndroidAOP
9 changes: 5 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
apply plugin: "com.android.application"
apply plugin: "kotlin-android"
apply plugin: "com.ibotta.gradle.aop"

java {
Expand Down Expand Up @@ -30,7 +29,7 @@ android {
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), "proguard-rules.pro"
}
}

Expand All @@ -41,8 +40,10 @@ android {
issue here:
https://github.com/Ibotta/gradle-aspectj-pipeline-plugin/issues/8
*/
kotlinOptions {
freeCompilerArgs = ["-Xsam-conversions=class"]
kotlin {
compilerOptions {
freeCompilerArgs = ["-Xsam-conversions=class"]
}
}

testOptions {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}
dependencies {
//Android Gradle Plugin (AGP)
classpath "com.android.tools.build:gradle:8.13.2"
classpath "com.android.tools.build:gradle:9.0.0"

//Kotlin
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:2.3.0"
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ org.gradle.jvmargs=-Xmx1536m
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

android.newDsl=false