Gradle commands fails to build projects


(Moeed Ghaffar) #1

There is a bug possibly with gradle which fails the gradle commands giving the same error. For building the project I use maven repository and save it locally instead of gradle. After doing some research on the error, I found out that a POM file “gradle-core-1.3.0.pom” was missing in the local maven repository “.m2\repository\com\android\tools\build\gradle-core\1.3.0”. Just because of this missing POM file, the gradle commands did not let me build any projects. On the other hand, I could build all the projects through the android studio.

Below is the top level level build.gradle:

buildscript {
repositories {
mavenLocal()
}

dependencies {
    classpath 'com.android.tools.build:gradle:1.3.0'
    classpath 'com.android.tools.build:gradle-core:1.3.0'
}

}

allprojects {
repositories {
mavenLocal()
}
}

And the module level build.gradle:

apply plugin: ‘com.android.application’

android {
compileSdkVersion 19
buildToolsVersion “23.0.1”

defaultConfig {
    applicationId "com.example.test.testwebviewpinning"
    minSdkVersion 14
    targetSdkVersion 14
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

}

dependencies {
testCompile 'junit:junit:4.12’
testCompile 'org.hamcrest:hamcrest-core:1.3’
androidTestCompile 'com.android.support:support-annotations:19.0.1’
androidTestCompile 'com.android.support.test:runner:0.4.1’
androidTestCompile 'com.android.support.test:rules:0.4.1’
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1’
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2’
androidTestCompile 'com.squareup:javawriter:2.1.1’
androidTestCompile 'javax.inject:javax.inject:1’
androidTestCompile 'org.hamcrest:hamcrest-library:1.3’
androidTestCompile 'org.hamcrest:hamcrest-integration:1.3’
androidTestCompile 'org.hamcrest:hamcrest-core:1.3’
androidTestCompile 'com.google.code.findbugs:jsr305:2.0.1’
androidTestCompile ‘javax.annotation:javax.annotation-api:1.2’
}

Following is the error:

C:\Workspace\android-studio-workspace\TestSSLSocketFactory-gradlefail>gradlew clean -s
Picked up JAVA_TOOL_OPTIONS: -Duser.home=C:\Users\43780332
Gradle version = 2.4
User Home = C:\Users\43780332

FAILURE: Build failed with an exception.

  • Where:
    Build file ‘C:\Workspace\android-studio-workspace\TestSSLSocketFactory-gradlefail\app\build.gradle’ line: 1

  • What went wrong:
    A problem occurred evaluating project ‘:app’.

Failed to apply plugin [id ‘com.android.application’]
Could not create plugin of type ‘AppPlugin’.

  • Try:
    Run with --info or --debug option to get more log output.

  • Exception is:
    org.gradle.api.GradleScriptException: A problem occurred evaluating project ‘:app’.
    at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:76)
    at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$1.run(DefaultScriptPluginFactory.java:148)
    at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:156)
    at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:39)
    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.evaluate(LifecycleProjectEvaluator.java:55)
    at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:487)
    at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:85)
    at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:47)
    at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:129)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:90)
    at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
    at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:50)
    at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:27)
    at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:40)
    at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:169)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
    at org.gradle.launcher.Main.doAction(Main.java:33)
    at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
    at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
    at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:33)
    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
    Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id ‘com.android.application’]
    at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:160)
    at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:112)
    at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyType(DefaultObjectConfigurationAction.java:113)
    at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:36)
    at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:80)
    at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:136)
    at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:46)
    at org.gradle.api.plugins.PluginAware$apply.call(Unknown Source)
    at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.groovy:34)
    at org.gradle.api.Script$apply$0.callCurrent(Unknown Source)
    at build_7e30si32ve95opt8fel4lvgc8.run(C:\Workspace\android-studio-workspace\TestSSLSocketFactory-gradlefail\app\build.gradle:1)
    at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:74)
    … 38 more
    Caused by: org.gradle.api.plugins.PluginInstantiationException: Could not create plugin of type ‘AppPlugin’.
    at org.gradle.api.internal.plugins.DefaultPluginManager.instantiatePlugin(DefaultPluginManager.java:61)
    at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:135)
    … 49 more
    Caused by: java.lang.NoClassDefFoundError: com/android/ide/common/process/ProcessExecutor
    at org.gradle.api.internal.DependencyInjectingInstantiator.selectConstructor(DependencyInjectingInstantiator.java:83)
    at org.gradle.api.internal.DependencyInjectingInstantiator.newInstance(DependencyInjectingInstantiator.java:44)
    at org.gradle.api.internal.plugins.DefaultPluginManager.instantiatePlugin(DefaultPluginManager.java:59)
    … 50 more
    Caused by: java.lang.ClassNotFoundException: com.android.ide.common.process.ProcessExecutor
    … 53 more

BUILD FAILED

Total time: 5.245 secs


(Stefan Oehme) #2

I would not say this is a bug in Gradle. Your local repository was broken, so Gradle had no way to pick up the dependency information. The question is how did you end up with the broken repo and why don’t you let Gradle fetch the plugin from a known good repo?


(Moeed Ghaffar) #3

Hi Stefan,

I used the maven command to fetch the plugin manually because I thought the issue could possibly be there as all my projects would compile through android studio but would fail when i use the gradlew clean or any gradle command for that matter. Below is the maven command I used to fetch the plugin:

mvn dependency:get -DrepoUrl=https://repo1.maven.org/maven2/ -Dartifact=com.android.tools.build:gradle:1.3.0


(Stefan Oehme) #4

Okay so just to be clear, your project failed on the command line before you did the mavenLocal() modifications?


(Moeed Ghaffar) #5

No. I am using mavenLocal() since the beginning and the issue arises only when the POM file “gradle-core-1.3.0.pom” is missing in the local maven repository “.m2\repository\com\android\tools\build\gradle-core\1.3.0”. Due to this missing POM, I can NOT use ANY gradle command to build/clean project. But when I add this POM in the local repository path declared above, all the gralde commands run perfectly fine without any error.

The question simply is that WHY is only this “gradle-core-1.3.0.pom” is required in the maven repository and no other POM. Seems to me like this POM is requirement for using the gradle commands.

Please advice.


(Stefan Oehme) #6

POM files contain the transitive dependency information that Gradle (or Maven) use to determine which other jars you will need on your classpath. If that information is missing, then you end up with the ClassNotFoundExceptions you saw. The POMs should always be there for every artifact in your maven repo.

The question is: How did your mavenLocal end up in a broken state? Did you edit it manually or did some process crash halfway through an operation on it? In any case, the best thing you can do is to delete your local maven repository, so a fresh, working one will be created.


(Moeed Ghaffar) #7

I only see the POMs in gradle-core artifact and no other artifact have the POMs. This is the repo downloaded online.

And to your question, I did get a few artifacts manually so maybe something went wrong there.


(Stefan Oehme) #8

Yes, that is most probably the issue.