kezong / fat-aar-android

A gradle plugin that merge dependencies into the final aar file works with AGP 3.+
MIT License
3.08k stars 607 forks source link

Support AGP 8.0+ #411

Open aasitnikov opened 1 year ago

aasitnikov commented 1 year ago

This pull request adds support for AGP 8.0.

Note that this branch includes fix from #403.

To get this version into your project, you can use jitpack as follows:

allprojects {
    repositories {
        ...
        maven {
            setUrl("https://jitpack.io")
            content { includeGroup("com.github.aasitnikov") }
        }
    }
}

dependencies {
    implementation("com.github.aasitnikov:fat-aar-android:b2a038763c")
}
KindiiV commented 1 year ago

@aasitnikov I have an error: Cause: {module_name} module's AndroidManifest not found. But this module has AndroidManifest file and it was working before Gradle 8, what can be wrong?

TVDiasDominik commented 1 year ago

same for me the first lib i do embed will end in this error Caused by: org.gradle.api.internal.tasks.properties.PropertyEvaluationException: Error while evaluating property 'visitorsList.$0.parameters.libraryNamespaces' of task ':app:transformDebugClassesWithAsm'. Caused by: org.gradle.api.internal.provider.AbstractProperty$PropertyQueryException: Failed to calculate the value of property 'libraryNamespaces'.

ralikhachev commented 1 year ago

@aasitnikov Hello, there are problems (AGP: 8.0.2, Gradle: 8.1.1)

Configuration 'embed' was resolved during configuration time. This is a build performance and scalability issue. See https://github.com/gradle/gradle/issues/2298 Run with --info for a stacktrace. java.lang.RuntimeException: Configuration 'embed' was resolved during configuration time. This is a build performance and scalability issue. See https://github.com/gradle/gradle/issues/2298 at com.android.build.gradle.internal.DependencyResolutionChecks$registerDependencyCheck$4$1.execute(DependencyResolutionChecks.kt:72)

Task :sdk:transformDebugClassesWithAsm FAILED

FAILURE: Build failed with an exception.

AGP: 7.2.0, Gradle: 7.6: Works without errors

AndreasBoehm commented 1 year ago

Hi @aasitnikov,

i tried to update my fork with your changes but unfortunately i do get the same error that others reported as soon as i use AGP 8.0.0 or higher.

After a first look it looks like you are trying to access the AndroidManifest of the exploded aar before you explode the aar.

Maybe you have an idea how to resolve this error.

Best regards, Andi

aasitnikov commented 10 months ago

I figured out potential issue, try "com.github.aasitnikov:fat-aar-android:b2a038763c" to see if it works for you

thisisatestuseraccount commented 10 months ago

Merged into an off-site repo, builds are successful. Thank you for bothering to fix what Google won't even develop.

AndreasBoehm commented 10 months ago

Thanks a lot @aasitnikov !

I used AGP 8.1.1 and gradle 8.3 and it's working fine now.

RedRackham-R commented 10 months ago

Thanks for the fix! Successfully used in gradle 8.3 :D

flasher297 commented 9 months ago

If you struggle with connecting this fix via Kotlin DSL use this approach: Add these closures to the settings.gradle

pluginManagement {
    repositories {
        maven {
            setUrl("https://jitpack.io")
            content { includeGroup("com.github.aasitnikov") }
        }
    }
}

In the root build.gradle.kts you have to use the old buildScript approach because I haven't figured out how to find plugin ID to add it to the plugins block.

buildscript {
    dependencies {
        classpath("com.github.aasitnikov:fat-aar-android:ce932b38ef")
    }
}

Finally, add the plugin in build.gradle.kts of your module.

plugins {
    ....
    id("com.kezong.fat-aar")
}
dh336699 commented 9 months ago

If you struggle with connecting this fix via Kotlin DSL use this approach: Add these closures to the settings.gradle

pluginManagement {
    repositories {
        maven {
            setUrl("https://jitpack.io")
            content { includeGroup("com.github.aasitnikov") }
        }
    }
}

In the root build.gradle.kts you have to use the old buildScript approach because I haven't figured out how to find plugin ID to add it to the plugins block.

buildscript {
    dependencies {
        classpath("com.github.aasitnikov:fat-aar-android:ce932b38ef")
    }
}

Finally, add the plugin in build.gradle.kts of your module.

plugins {
    ....
    id("com.kezong.fat-aar")
}

@flasher297 Hey guy, I just did as you say, it still threw error in Android Studio as below: image

bugDim88 commented 8 months ago

Hi @aasitnikov. Try you patch on my project. Versions: agp 8.1, gradle 8.3.

Looks like result lib.aar missing jar file with R classes. Application with aar like this fails. In attached screenshot you can see example of R classes jar file that missing in patched fat-aar output. What can be wrong? aar_tree

HamzaOban commented 7 months ago

Thank you @aasitnikov it's working.

dyguests commented 7 months ago

Works for me!

: gradle 8.0

And here is my changed files:

root settings.gradle

pluginManagement {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
        ...
    }
}

root build.gradle

buildscript{
    dependencies {
        // classpath 'com.github.kezong:fat-aar:1.3.8'
        classpath("com.github.aasitnikov:fat-aar-android:b2a038763c")
    }
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    ...
}

the sdk need embed. build.gradle

plugins {
    ...
    id 'com.kezong.fat-aar'
}
gaoruiqing187 commented 6 months ago

@dyguests 老哥,我的依然没成功,能留个联系方式交流交流吗

dyguests commented 6 months ago

@dyguests 老哥,我的依然没成功,能留个联系方式交流交流吗

我上面的回复,已经是我全部修改内容啦 ,没别的办法啦。

TVDiasDominik commented 5 months ago

@aasitnikov today i tried updating to gradle 8.6 and it does not work anymore. Can you maybe also fix it for 8.6?

lsuski commented 4 months ago

@TVDiasDominik you can try my fork https://github.com/lsuski/fat-aar-android/tree/support_gradle86

MichaelNien commented 3 months ago

Support AGP 8.3.1 ?

aasitnikov commented 3 months ago

Try out https://github.com/aasitnikov/fat-aar-android with AGP 8.3.0 support

jike1502jt commented 2 months ago

@dyguests 老哥,我的依然没成功,能留个联系方式交流交流吗

我上面的回复,已经是我全部修改内容啦 ,没别的办法啦。

Works for me!

: gradle 8.0

And here is my changed files:

root settings.gradle

pluginManagement {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
        ...
    }
}

root build.gradle

buildscript{
    dependencies {
        // classpath 'com.github.kezong:fat-aar:1.3.8'
        classpath("com.github.aasitnikov:fat-aar-android:b2a038763c")
    }
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    ...
}

the sdk need embed. build.gradle

plugins {
    ...
    id 'com.kezong.fat-aar'
}

dependencies依赖的还是用embed project吗?

jike1502jt commented 2 months ago

This pull request adds support for AGP 8.0.

Note that this branch includes fix from #403.

To get this version into your project, you can use jitpack as follows:

allprojects {
    repositories {
        ...
        maven {
            setUrl("https://jitpack.io")
            content { includeGroup("com.github.aasitnikov") }
        }
    }
}

dependencies {
    implementation("com.github.aasitnikov:fat-aar-android:b2a038763c")
}

image 我用了报这个是什么问题,我gradle版本是8.01

dyguests commented 2 months ago

@jike1502jt 我真不知道了。 而且这个方案我们已经废弃了,新方案都没用 fat-aar 了。 现在我都没做这个项目了。

jike1502jt commented 2 months ago

@jike1502jt 我真的不知道了。 而且这个方案我们已经荒废了,新方案都已经用 fat-aar 了。 现在我已经不再做这个项目了。

fat-aar 不是不支持gradle8以上吗?

MichaelNien commented 2 weeks ago

Try out https://github.com/aasitnikov/fat-aar-android with AGP 8.3.0 support

Support AGP 8.5.x ?

aasitnikov commented 2 weeks ago

Try out latest release with AGP 8.5 support at https://github.com/aasitnikov/fat-aar-android