Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation errors: classes missing on v2 version #81

Closed
alexcutovoi opened this issue Nov 22, 2016 · 15 comments
Closed

Compilation errors: classes missing on v2 version #81

alexcutovoi opened this issue Nov 22, 2016 · 15 comments

Comments

@alexcutovoi
Copy link

Compiling latest dropbox sdk produces these errors:
Starting a new Gradle Daemon for this build (subsequent builds will be faster).
Parallel execution with configuration on demand is an incubating feature.
Set JDK6_HOME environment to disable boot classpath warnings.
:generateStone UP-TO-DATE
:compileJava
warning: [options] bootstrap class path not set in conjunction with -source 1.6
/usr/local/AndroidProjects/dropbox-sdk-java-master/src/main/java/com/dropbox/core/v2/DbxTeamClientV2.java:24: error: cannot find symbol
public class DbxTeamClientV2 extends DbxTeamClientV2Base {
^
symbol: class DbxTeamClientV2Base
/usr/local/AndroidProjects/dropbox-sdk-java-master/src/main/java/com/dropbox/core/v2/DbxClientV2.java:19: error: cannot find symbol
public class DbxClientV2 extends DbxClientV2Base {
^
symbol: class DbxClientV2Base
/usr/local/AndroidProjects/dropbox-sdk-java-master/src/main/java/com/dropbox/core/v2/DbxAppClientV2.java:20: error: cannot find symbol
class DbxAppClientV2 extends DbxAppClientV2Base {
^
symbol: class DbxAppClientV2Base
3 errors
:compileJava FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':compileJava'.

Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
@greg-db
Copy link
Contributor

greg-db commented Nov 22, 2016

[Cross-linking for reference: https://stackoverflow.com/questions/40746004/compiling-dropbox-api-classes-missing / https://www.dropboxforum.com/t5/API-support/Compilation-error-whren-installing-API/m-p/195237#M8889 ]

Can you let us know what commands you're running, and which one in particular fails with this error? Thanks in advance!

@alexcutovoi
Copy link
Author

Sure:
./gradlew install
Executed in root folder of dropbox SDK.

@greg-db
Copy link
Contributor

greg-db commented Nov 22, 2016

Thanks! Did the other commands from the Building from source instructions run successfully?

@alexcutovoi
Copy link
Author

No. The errors is exactly the same. I downloaded the zip file instead of to clone repository.

@greg-db
Copy link
Contributor

greg-db commented Nov 22, 2016

I'm not sure I follow. Did you run those as well, and receive errors there as well? If you can share the full log, including the output for the other commands, that would be helpful so we can make sure we reproduce exactly what you're seeing.

@alexcutovoi
Copy link
Author

Executed command: ./gradlew build --stacktrace

Result:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':compileJava'. at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46) at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35) at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:66) at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53) at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110) at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37) at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37) at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23) at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43) at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32) at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37) at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30) at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.java:153) at org.gradle.internal.Factories$1.create(Factories.java:22) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:53) at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:150) at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32) at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:98) at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:92) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:63) at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:92) at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:83) at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:99) 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:48) at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:30) at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:81) at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:46) at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:51) at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:28) at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43) at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:173) at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:239) at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:212) 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.ExceptionReportingAction.execute(ExceptionReportingAction.java:33) at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22) at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:205) at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169) 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:55) at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:36) at org.gradle.launcher.GradleMain.main(GradleMain.java:23) at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30) at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129) at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61) Caused by: org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed; see the compiler error output for details. at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:48) at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:33) at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJavaCompiler.java:104) at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:53) at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:38) at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:35) at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:25) at org.gradle.api.tasks.compile.JavaCompile.performCompilation(JavaCompile.java:163) at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:145) at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:93) at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:245) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:221) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:232) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)

@alexcutovoi
Copy link
Author

I've attached a log file now
log.txt

@greg-db
Copy link
Contributor

greg-db commented Nov 22, 2016

Thanks, that's helpful. We'll look into it.

@Viktoryus78
Copy link

I have the same problem

@drizzd
Copy link

drizzd commented Nov 27, 2016

Running ./update-submodules before ./gradlew as described in ReadMe.md fixed the missing classes for me. An error message like "stone: Submodule missing. Did you run ./update-submodules?" would be nice, though.

However, I had to do some more work to make the build succeed.

  • I am on Windows 10 with Msys command line and mingw-w64-x86_64-python and mingw-w64-x86_64-python3 installed. The final version also works on Windows cmd (while having c:\msys64\mingw\bin in PATH).
  • I am using the gradle test task rather than build, because the build task fails the javadoc task, and I do not care about javadoc right now.
  • I do not claim that the changes below are correct fixes to be committed to the repository. I only present them for illustration and reproducibility.

$ git describe --tags
v2.1.2-5-g91b3c39
$ ./update-submodules
$ python -V
Python 2.7.11
$ ./gradlew test

Set JDK6_HOME environment to disable boot classpath warnings.
:generateStoneTraceback (most recent call last):
  File "C:/msys64/mingw64/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:/msys64/mingw64/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:/Users/Ricl/src/dropbox-sdk-java/stone/stone/cli.py", line 17, in <module>
    from .cli_helpers import parse_route_attr_filter
  File "C:/Users/Ricl/src/dropbox-sdk-java/stone/stone/cli_helpers.py", line 3, in <module>
    from typing import Tuple
ImportError: No module named typing
FAILED

According to typing docs, the module is new in Python 3.5. So let's use Python 3 instead of Python 2:

diff --git a/stone.gradle b/stone.gradle
index 7bb1de3..73c7d31 100644
--- a/stone.gradle
+++ b/stone.gradle
@@ -43,7 +43,7 @@ def runStoneGenerator(StoneConfig config,
     if (config.dataTypesOnly) {
         project.exec {
             standardOutput = new FileOutputStream(logFile)
-            commandLine "python", "-m", "stone.cli"
+            commandLine "python3", "-m", "stone.cli"

             environment PYTHONPATH: stoneDir.absolutePath
             args "--clean-build"
@@ -71,7 +71,7 @@ def runStoneGenerator(StoneConfig config,

         project.exec {
             standardOutput = new FileOutputStream(logFile, append)
-            commandLine "python", "-m", "stone.cli"
+            commandLine "python3", "-m", "stone.cli"

             environment PYTHONPATH: stoneDir.absolutePath
             if (isFirst) {

$ ./gradlew test

Set JDK6_HOME environment to disable boot classpath warnings.
:generateStoneError(s) in route filter:
Unexpected ID with value 'user'.
FAILED

Some experiments show that, at least on Windows, gradle's Exec command line arguments are not passed literally. As a result, stone.cli is called with auth=user for the routeFilter instead of auth="user", and that is not valid syntax. Adding the following quotes make stone.cli succeed:

diff --git a/stone.gradle b/stone.gradle
index 7bb1de3..f9418eb 100644
--- a/stone.gradle
+++ b/stone.gradle
@@ -147,21 +147,21 @@ generateStone {
         clients: [
             new ClientSpec(
                 name: 'DbxClientV2Base',
-                javadoc: 'Base class for user auth clients.',
+                javadoc: '"Base class for user auth clients."',
                 requestsClassnamePrefix: "DbxUser",
-                routeFilter: 'auth="user" or auth="noauth"',
+                routeFilter: 'auth=\\\"user\\\" or auth=\\\"noauth\\\"',
             ),
             new ClientSpec(
                 name: 'DbxTeamClientV2Base',
-                javadoc: 'Base class for team auth clients.',
+                javadoc: '"Base class for team auth clients."',
                 requestsClassnamePrefix: 'DbxTeam',
-                routeFilter: 'auth="team"',
+                routeFilter: 'auth=\\\"team\\\"',
             ),
             new ClientSpec(
                 name: 'DbxAppClientV2Base',
-                javadoc: 'Base class for app auth clients.',
+                javadoc: '"Base class for app auth clients."',
                 requestsClassnamePrefix: "DbxApp",
-                routeFilter: 'auth="app"',
+                routeFilter: 'auth=\\\"app\\\"',
             )
         ],
     )

$ ./gradlew test

Set JDK6_HOME environment to disable boot classpath warnings.
:generateStoneerror: Importing generator 'C:\Users\Ricl\src\dropbox-sdk-java\generator\java.stoneg.py' module raised an exception:
Traceback (most recent call last):
  File "C:/msys64/mingw64/lib/python3.5\runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "C:/msys64/mingw64/lib/python3.5\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:/Users/Ricl/src/dropbox-sdk-java/stone\stone\cli.py", line 342, in <module>
    api = main()
  File "C:/Users/Ricl/src/dropbox-sdk-java/stone\stone\cli.py", line 313, in main
    generator_module = imp.load_source('user_generator', args.generator)
  File "C:/msys64/mingw64/lib/python3.5\imp.py", line 172, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 693, in _load
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 662, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "C:\Users\Ricl\src\dropbox-sdk-java\generator\java.stoneg.py", line 54, in <module>
    StoneType.register(ApiNamespace)
AttributeError: type object 'StoneType' has no attribute 'register'
 FAILED

Python 3 does not have iteritems, and it needs a slightly different syntax when using the abc module:

diff --git a/generator/java.stoneg.py b/generator/java.stoneg.py
index 5623457..9ea1f0b 100644
--- a/generator/java.stoneg.py
+++ b/generator/java.stoneg.py
@@ -48,8 +48,8 @@ from stone.data_type import (
     Void,
 )

-class StoneType:
-    __metaclass__ = abc.ABCMeta
+class StoneType(metaclass=abc.ABCMeta):
+    pass

 StoneType.register(ApiNamespace)
 StoneType.register(ApiRoute)
@@ -2234,7 +2234,7 @@ class JavaReference(object):

     def _as_json(self):
         dct = {}
-        for k, v in self.__dict__.iteritems():
+        for k, v in self.__dict__.items():
             # avoid cyclic references issue
             if isinstance(v, JavaReference):
                 dct[k] = v.fq_name

$ ./gradlew test

Set JDK6_HOME environment to disable boot classpath warnings.
:generateStone
:compileJavawarning: [options] bootstrap class path not set in conjunction with -source 1.6

:processResources UP-TO-DATE
:classes
:generateTestStone UP-TO-DATE
:compileTestJavawarning: [options] bootstrap class path not set in conjunction with -source 1.6

:processTestResources UP-TO-DATE
:testClasses
:test

BUILD SUCCESSFUL

Total time: 57.584 secs

@DreierF
Copy link

DreierF commented Nov 27, 2016

@drizzd I had the same issue yesterday (on macOS), but instead of using python3, which comes bundled with typing, I installed the typing module and some other missing ones via pip install typing. Then it compiled successfully.

@GrahamBorland
Copy link

I get this too. I followed the instructions exactly. Fresh clone of the repo. ./gradlew install gives this compilation error. (OS X Sierra.)

@cakoose
Copy link
Contributor

cakoose commented Jan 9, 2017

I think there are two issues here

1. You need to pull in submodules

Like the ReadMe says, you need to clone and then run ./update-submodules before running ./gradew build. (Git should really do this automatically but it doesn't. Someone is working on it, but it's not clear that work will ever be merged...)

That said, ./gradlew build currently provides a misleading error message. It seems to silently ignore the error in the code generation step and then fail later in the compilation step. It should fail in the generation step and maybe tell the user to run ./update-submodules.

2. You need to install Stone's dependencies

Stone depends on ply, six, and typing. Currently, stone.gradle runs python -m stone, so a quick fix is to install those modules globally:

sudo -H python -m pip install ply six typing

That said:

  1. We should use a virtualenv instead of polluting the global module namespace.
  2. ./gradlew build should automatically install the dependencies (to a virtualenv).
    • IMPORTANT: If the dependencies have already been installed, ./gradlew build should not require network access. In other words, confirming that the dependencies are present should not require network access.

@deanrjy2020
Copy link

drizzd commented on Nov 27, 2016
It is very very helpful, thank you so much.

@tonylow
Copy link

tonylow commented Jul 15, 2017

Working on my Mac, followed @cakoose advice, installed my python version and manage to get it build successfully.

  1. Install python
  2. sudo -H python -m pip install ply six typing

DONE!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants