我正在构建一个Android库(uservoice,如果这很重要),使用gradle 2.1,插件0.13。这是构建文件
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.13.+'
}
}
apply plugin: 'com.android.library'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
android {
lintOptions {
abortOnError false
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
dependencies {
compile 'com.android.support:support-v4:20.+'
compile 'commons-codec:commons-codec:1.8'
compile 'oauth.signpost:signpost-commonshttp4:1.2.1.2'
compile 'oauth.signpost:signpost-core:1.2.1.2'
}
在终端编译时总是遇到此错误:
无法创建“LibraryPlugin”类型的插件。
正如您可能已经注意到的,该插件被命名为“com.android.library”以符合gradle 13构建工具,即使我改回“android-library”它也无济于事。
奇怪的是,如果我通过在Android Studio的Gradle窗口(右侧窗格)中点击任务来构建,则错误不会发生。
以前有人遇到过这个吗?你的解决方案/解决方法?
更新:正在运行gradle assembleDebug --debug
会显示以下内容:
8:24:06.991 [ERROR] [org.gradle.BuildExceptionReporter] Build file 'C:\Users\Tung\myprojects\project_name\libraries\uservoice-android-sdk\UserVoiceSDK\build.gradle' line: 11
18:24:06.991 [ERROR] [org.gradle.BuildExceptionReporter]
18:24:06.992 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
18:24:06.992 [ERROR] [org.gradle.BuildExceptionReporter] A problem occurred evaluating project ':UserVoiceSDK'.
18:24:06.992 [ERROR] [org.gradle.BuildExceptionReporter] > Could not create plugin of type 'LibraryPlugin'.
18:24:06.993 [ERROR] [org.gradle.BuildExceptionReporter]
18:24:06.994 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is:
18:24:06.995 [ERROR] [org.gradle.BuildExceptionReporter] org.gradle.api.GradleScriptException: A problem occurred evaluating project ':UserVoiceSDK'.
18:24:06.996 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:54)
18:24:06.997 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:152)
18:24:06.997 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:40)
18:24:06.998 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:26)
18:24:06.998 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
18:24:06.998 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55)
18:24:06.999 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:493)
18:24:06.999 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.AbstractProject.evaluationDependsOn(AbstractProject.java:597)
18:24:07.000 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.AbstractProject.evaluationDependsOn(AbstractProject.java:589)
18:24:07.000 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.Project$evaluationDependsOn.call(Unknown Source)
18:24:07.001 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.BasePlugin$_ensureConfigured_closure158.doCall(BasePlugin.groovy:2472)
18:24:07.001 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.BasePlugin.ensureConfigured(BasePlugin.groovy:2471)
18:24:07.002 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.BasePlugin.resolveDependencyForConfig(BasePlugin.groovy:2389)
18:24:07.002 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.BasePlugin.this$2$resolveDependencyForConfig(BasePlugin.groovy)
18:24:07.002 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.BasePlugin$this$2$resolveDependencyForConfig.callCurrent(Unknown Source)
18:24:07.003 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.BasePlugin.resolveDependencies(BasePlugin.groovy:2308)
18:24:07.004 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.VariantManager.createTasksForDefaultBuild(VariantManager.java:311)
18:24:07.004 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.VariantManager.createAndroidTasks(VariantManager.java:169)
18:24:07.005 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.VariantManager$createAndroidTasks.call(Unknown Source)
18:24:07.005 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.groovy:427)
18:24:07.006 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.BasePlugin$_apply_closure7.doCall(BasePlugin.groovy:338)
18:24:07.007 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:40)
18:24:07.007 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:25)
18:24:07.008 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:83)
18:24:07.008 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:31)
18:24:07.009 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
18:24:07.010 [ERROR] [org.gradle.BuildExceptionReporter] at $Proxy12.afterEvaluate(Unknown Source)
18:24:07.010 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:67)
18:24:07.010 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:61)
18:24:07.012 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:493)
18:24:07.012 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:80)
18:24:07.013 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:31)
18:24:07.014 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:142)
18:24:07.014 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
18:24:07.014 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
18:24:07.015 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:64)
18:24:07.015 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
18:24:07.016 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
18:24:07.016 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:35)
18:24:07.016 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:45)
18:24:07.017 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
18:24:07.017 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
18:24:07.017 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:42)
18:24:07.018 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
18:24:07.018 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:24)
18:24:07.019 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
18:24:07.019 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.StartStopIfBuildAndStop.execute(StartStopIfBuildAndStop.java:33)
18:24:07.019 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
18:24:07.020 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.ReturnResult.execute(ReturnResult.java:34)
18:24:07.020 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
18:24:07.020 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:71)
18:24:07.021 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:69)
18:24:07.021 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.util.Swapper.swap(Swapper.java:38)
18:24:07.022 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:69)
18:24:07.022 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
18:24:07.023 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
18:24:07.023 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
18:24:07.024 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
18:24:07.024 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:60)
18:24:07.026 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
18:24:07.027 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
18:24:07.027 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:45)
18:24:07.028 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.DaemonStateCoordinator.runCommand(DaemonStateCoordinator.java:186)
18:24:07.028 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy.doBuild(StartBuildOrRespondWithBusy.java:49)
18:24:07.029 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
18:24:07.030 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
18:24:07.030 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.HandleStop.execute(HandleStop.java:36)
18:24:07.031 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
18:24:07.031 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.DaemonHygieneAction.execute(DaemonHygieneAction.java:39)
18:24:07.032 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
18:24:07.032 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.CatchAndForwardDaemonFailure.execute(CatchAndForwardDaemonFailure.java:32)
18:24:07.033 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
18:24:07.034 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.DefaultDaemonCommandExecuter.executeCommand(DefaultDaemonCommandExecuter.java:51)
18:24:07.034 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.handleCommand(DefaultIncomingConnectionHandler.java:155)
18:24:07.035 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.receiveAndHandleCommand(DefaultIncomingConnectionHandler.java:128)
18:24:07.035 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.run(DefaultIncomingConnectionHandler.java:116)
18:24:07.036 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
18:24:07.036 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: org.gradle.api.plugins.PluginInstantiationException: Could not create plugin of type 'LibraryPlugin'.
18:24:07.037 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.plugins.DefaultPluginRegistry.loadPlugin(DefaultPluginRegistry.java:67)
18:24:07.037 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.plugins.DefaultPluginContainer.providePlugin(DefaultPluginContainer.java:103)
18:24:07.038 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.plugins.DefaultPluginContainer.addPluginInternal(DefaultPluginContainer.java:68)
18:24:07.038 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.plugins.DefaultPluginContainer.apply(DefaultPluginContainer.java:34)
18:24:07.038 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyPlugin(DefaultObjectConfigurationAction.java:116)
18:24:07.039 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:36)
18:24:07.039 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:85)
18:24:07.039 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:129)
18:24:07.040 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:41)
18:24:07.040 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.Project$apply.call(Unknown Source)
18:24:07.041 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.groovy:34)
18:24:07.041 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.Script$apply.callCurrent(Unknown Source)
18:24:07.042 [ERROR] [org.gradle.BuildExceptionReporter] at build_1e17m4j0u0t5o8s8i7cb99alap.run(C:\Users\Tung\tripgo-grad-space\tripgo-android\libraries\uservoice-android-sdk\UserVoiceSDK\build.gradle:11)
18:24:07.042 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
18:24:07.042 [ERROR] [org.gradle.BuildExceptionReporter] ... 76 more
18:24:07.043 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/typehandling/ShortTypeHandling
18:24:07.043 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.BasePlugin.getLocalVersion(BasePlugin.groovy:2956)
18:24:07.043 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.BasePlugin.<init>(BasePlugin.groovy:243)
18:24:07.044 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.LibraryPlugin.<init>(LibraryPlugin.groovy:40)
18:24:07.044 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.DependencyInjectingInstantiator.newInstance(DependencyInjectingInstantiator.java:62)
18:24:07.045 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.plugins.DefaultPluginRegistry.loadPlugin(DefaultPluginRegistry.java:65)
18:24:07.046 [ERROR] [org.gradle.BuildExceptionReporter] ... 89 more
18:24:07.047 [ERROR] [org.gradle.BuildExceptionReporter]
18:24:07.047 [LIFECYCLE] [org.gradle.BuildResultLogger]
更新2:真正的问题是我的命令行指向旧gradle(1.2)而不是新的(2.1),所以我只是改变了我的PATH var。问题解决了。
答案 0 :(得分:16)
我刚遇到同样的问题。我使用旧的Gradle 1.2。切换到Gradle 2.1解决了这一切。
答案 1 :(得分:1)
要解决此问题,请在gradle.properties中添加
org.gradle.jvmargs=-Xmx1512m -XX:MaxPermSize=1512m
答案 2 :(得分:0)
更新gradle版本应解决此问题。
您可以在build.gradle中执行此操作,查找dependencies
块并更新您的gradle类路径,例如:
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
将其更改为最新版本(应标有工具提示),目前为1.3.1。
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
}