Search code examples
javaandroidandroid-studioapollo-android

Android Studio can't import a java from 'generated_java' folder


I implement a package 'apollo-android' and generate 'FeedQuery' java file from the 'schema.json'. But I can't import that 'FeedQuery' java file to my project.


Solution

  • The apollo android plugin really depends on the android gradle plugin. So if your generated classes are in a java-library module, you will not be able to import them.

    Assuming you placed your graphql queries in an android module, please make sure that you have created a directory structure same as your module source directory structure under /graphql

    For example if your module directory structure is as follows

    src/main/java/com/example/

    Then create the graphql directory structure as follows.

    src/main/graphql/com/example/

    After doing this, clean and rebuild and try importing classes again.