在執行升級到 AGP 7.1.1 并在庫專案中從 Android Studio 執行自動升級步驟后,我的構建失敗。
我遵循以下指南:https ://developer.android.com/studio/build/maven-publish-plugin
我們已經使用它很長一段時間沒有問題。
從 IDE 執行自動化步驟后,我現在收到以下錯誤:
A problem occurred configuring project ':some-lib'.
> Could not find method publications() for arguments [build_546b384slk3v64hu8jsdnbywh$_run_closure1$_closure5$_closure9$_closure10@333a4a39] on object of type com.android.build.gradle.internal.dsl.LibraryPublishingImpl$AgpDecorated.
我的 build.gradle 檔案如下所示:
android {
...
afterEvaluate {
publishing {
publications {
mavenAar(MavenPublication) {
from components.release
}
}
repositories {
maven {
url artifact_repo_url
credentials {
...
}
}
}
}
}
}
我的 gradle-wrapper.properties 看起來像這樣:
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
有關如何解決此問題的任何建議?
uj5u.com熱心網友回復:
我的問題的答案顯示在這里: https ://developer.android.com/reference/tools/gradle-api/7.1/com/android/build/api/dsl/LibraryPublishing
該afterEvaluate{ publishing {} }
部分應該在 android {} 塊之外并且在它自己的afterEvaluate {}
我們還需要publishing {}在 android 塊中添加一個部分,指定要發布的變體。
對我來說,結果看起來像這樣:
android {
publishing {
singleVariant("release")
}
}
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.release
// ......
}
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/425840.html
標籤:安卓 毕业典礼 android-gradle-插件 maven-发布
