Apollo Android Client - Cannot access generated classes on classpath

跟風遠走 提交于 2020-01-14 12:49:06

问题


I've generated the Apollo classes successfully and can see them in the build directory, however they're not available on the classpath. Strangely the Enum that is generated is available but the classes themselves aren't.

Running the sample project provided on Apollo's Github does work but I cant see the difference between the configurations.

mcve below.

https://github.com/michaeljq/graphQlMCVE


回答1:


Right now, you have src/main/graphql/ containing GraphQL documents. That means that your Java classes will be generated with no Java package, which probably is not what you want.

Instead, create a package tree under src/main/graphql/ (e.g., src/main/graphql/apollotest/mq/apollotest/api/). Move the GraphQL documents and schema.json there. Clean the project, and you should find that your Apollo-generated classes are available to you in whatever Java package you chose (e.g., apollotest.mq.apollotest.api in the above example).




回答2:


Here is a screenshot to understand the solution faster:



来源:https://stackoverflow.com/questions/44141835/apollo-android-client-cannot-access-generated-classes-on-classpath

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!