This is really bugging me, I've installed and reinstalled JDK, ADK, Android Studio, and Gradle several times and in various different orders, but I can't get this error to go away. Either I'm not deleting enough when I uninstall, or there's some incompatibility with OS X Yosemite. It's also possible that I'm not pointing Android Studio at the right JDK or ADK... Basically, no idea what's going on. Any help would be greatly appreciated.
Here's the gradle stacktrace:
org.gradle.internal.service.ServiceCreationException: Could not create service of type DefaultClassLoaderRegistry using GlobalScopeServices.createClassLoaderRegistry().
at org.gradle.internal.service.DefaultServiceRegistry$FactoryMethodService.invokeMethod(DefaultServiceRegistry.java:643)
at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.create(DefaultServiceRegistry.java:597)
at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectProvider.getInstance(DefaultServiceRegistry.java:439)
at org.gradle.internal.service.DefaultServiceRegistry$SingletonService.get(DefaultServiceRegistry.java:479)
at org.gradle.internal.service.DefaultServiceRegistry.findConfigureMethod(DefaultServiceRegistry.java:145)
at org.gradle.internal.service.DefaultServiceRegistry.findProviderMethods(DefaultServiceRegistry.java:119)
at org.gradle.internal.service.DefaultServiceRegistry.addProvider(DefaultServiceRegistry.java:227)
at org.gradle.internal.service.ServiceRegistryBuilder.build(ServiceRegistryBuilder.java:52)
at org.gradle.launcher.cli.BuildActionsFactory.runBuildInProcess(BuildActionsFactory.java:167)
at org.gradle.launcher.cli.BuildActionsFactory.createAction(BuildActionsFactory.java:137)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.createAction(CommandLineActionFactory.java:242)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:232)
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 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
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)
Caused by: org.gradle.internal.service.UnknownServiceException: Could not find meta-data resource 'META-INF/services/javax.xml.datatype.DatatypeFactory' for service 'javax.xml.datatype.DatatypeFactory'.
at org.gradle.internal.service.ServiceLocator.getFactory(ServiceLocator.java:56)
at org.gradle.internal.classloader.DefaultClassLoaderFactory.makeServiceVisible(DefaultClassLoaderFactory.java:104)
at org.gradle.internal.classloader.DefaultClassLoaderFactory.createFilteringClassLoader(DefaultClassLoaderFactory.java:76)
at org.gradle.initialization.DefaultClassLoaderRegistry.restrictToGradleApi(DefaultClassLoaderRegistry.java:50)
at org.gradle.initialization.DefaultClassLoaderRegistry.<init>(DefaultClassLoaderRegistry.java:40)
at org.gradle.internal.service.scopes.GlobalScopeServices.createClassLoaderRegistry(GlobalScopeServices.java:115)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
at org.gradle.internal.service.DefaultServiceRegistry.invoke(DefaultServiceRegistry.java:328)
at org.gradle.internal.service.DefaultServiceRegistry.access$1200(DefaultServiceRegistry.java:58)
at org.gradle.internal.service.DefaultServiceRegistry$FactoryMethodService.invokeMethod(DefaultServiceRegistry.java:641)
... 27 more
I have encountered the same problem and read the gradle's full stack trace , and found that a jar is missing. The other missing jars, if any will be listed in the full stack trace.
the jar in question is commons-lang3.jar which is needed by gradle. I installed the jar in the below step
sudo apt-get install libcommons-lang3-java
then i ran gradle again and it worked fine.
来源:https://stackoverflow.com/questions/26371301/unable-to-compile-any-android-project-due-to-gradle-fail-could-not-find-javax-x