gpt4 book ai didi

android-gradle-plugin - 使用 Groovy 插件 DSL 的 Crashlytics 的 Fabric 插件构建 Gradle

转载 作者:行者123 更新时间:2023-12-02 04:26:23 24 4
gpt4 key购买 nike

我使用 Crashlytics 和 Crashlytics gradle 文档中记录的标准 Gradle 设置对 Android 应用程序进行了完美的 gradle 构建。我正在使用 Android Studio 3.2.1,Gradle 4.6 Android 插件版本 3.2.1,

作为稍后将构建脚本转换为 Kotlin 的准备工作的一部分,我删除了 buildscript 和 apply plugin 子句,并将它们替换为 gradle supports and Kotlin requires 的 plugins 子句。我已经看到纯 kotlin 项目成功地做到了这一点,但无法使用 Groovy 来完成这个中间/准备步骤。插件子句出现此错误:

Crashlytics was applied to a project without an Android plugin. Please make sure the Crashlytics plugin is applied after the appropriate Android plugin for your project.

由于 Gradle 插件门户中不存在 Fabric 插件(还没有?),我正在使用这个 settings.gradle,这部分似乎工作正常。它发现 Fabric 没有问题:

pluginManagement {
repositories {
jcenter()
google()
maven { url "https://maven.google.com" }
gradlePluginPortal()
maven { url "https://maven.fabric.io/public" }
}
resolutionStrategy {
eachPlugin {
switch (requested.id.id) {
case "com.android.application":
useModule("com.android.tools.build:gradle:${requested.version}")
break
case "io.fabric":
useModule("io.fabric.tools:gradle:${requested.version}")
break
}
}
}
}
include ':app'

switch 中是否存在 com.android.application 似乎无关紧要,两种方式的行为都是相同的。

应用程序的 build.gradle 中相应的插件子句如下所示:

plugins {
id "com.android.application"
id "signing"
id "io.fabric" version "1.27.0"
}

如果有用,构建中同步尝试的完整异常堆栈如下所示:

Caused by: org.gradle.internal.exceptions.LocationAwareException: Build file 'D:\Working\Monay\trunk\app\build.gradle' line: 5
An exception occurred applying plugin request [id: 'io.fabric', version: '1.27.0', artifact: 'io.fabric.tools:gradle:1.27.0']
at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugin(DefaultPluginRequestApplicator.java:232)
at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugins(DefaultPluginRequestApplicator.java:148)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:184)
at org.gradle.configuration.BuildOperationScriptPlugin$1.run(BuildOperationScriptPlugin.java:61)
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:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.configuration.BuildOperationScriptPlugin.apply(BuildOperationScriptPlugin.java:58)
at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:41)
at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:26)
at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
at org.gradle.configuration.project.LifecycleProjectEvaluator.doConfigure(LifecycleProjectEvaluator.java:64)
... 84 more
Caused by: org.gradle.api.plugins.InvalidPluginException: An exception occurred applying plugin request [id: 'io.fabric', version: '1.27.0', artifact: 'io.fabric.tools:gradle:1.27.0']
at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.exceptionOccurred(DefaultPluginRequestApplicator.java:247)
at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugin(DefaultPluginRequestApplicator.java:229)
... 96 more
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'io.fabric']
at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:150)
at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:125)
at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator$3.run(DefaultPluginRequestApplicator.java:151)
at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugin(DefaultPluginRequestApplicator.java:225)
... 96 more
Caused by: org.gradle.api.GradleException: Crashlytics was applied to a project without an Android plugin. Please make sure the Crashlytics plugin is applied after the appropriate Android plugin for your project.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:247)
at com.crashlytics.tools.gradle.ExternalPluginsState.deriveFrom(ExternalPluginsState.groovy:23)
at com.crashlytics.tools.gradle.ExternalPluginsState$deriveFrom.call(Unknown Source)
at com.crashlytics.tools.gradle.CrashlyticsPlugin.apply(CrashlyticsPlugin.groovy:50)
at com.crashlytics.tools.gradle.CrashlyticsPlugin.apply(CrashlyticsPlugin.groovy)
at org.gradle.api.internal.plugins.ImperativeOnlyPluginTarget.applyImperative(ImperativeOnlyPluginTarget.java:42)
at org.gradle.api.internal.plugins.RuleBasedPluginTarget.applyImperative(RuleBasedPluginTarget.java:50)
at org.gradle.api.internal.plugins.DefaultPluginManager.addPlugin(DefaultPluginManager.java:164)
at org.gradle.api.internal.plugins.DefaultPluginManager.access$200(DefaultPluginManager.java:47)
at org.gradle.api.internal.plugins.DefaultPluginManager$AddPluginBuildOperation.run(DefaultPluginManager.java:252)
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:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:144)
... 99 more

出于某种原因,Crashlytics 插件无法以这种方式查看 Android 应用程序插件。任何人都知道我做错了什么,或者这种使用 plugins 子句是否应该与 Fabric 插件一起使用?在此先感谢您的帮助

最佳答案

对于遇到此问题的其他人,简单的解决方法是跳过在 plugins{} block 中应用插件,而是稍后在构建脚本中应用它(甚至紧跟在 plugins {} block 没问题):

plugins {
id("com.android.application")
id("io.fabric") version("1.27.0") apply(false)
}
apply plugin: 'io.fabric'

关于android-gradle-plugin - 使用 Groovy 插件 DSL 的 Crashlytics 的 Fabric 插件构建 Gradle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54102512/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com