Search code examples
gradlelibgdxbuild.gradlegoogle-vision

LibGDX: How to add Google Mobile Vision API to a LibGDX project?


Maybe the answer is simple, however I could not find anything that could help me yet. Basicaly, I want to add the Google Vision API to my project. I tried this by putting

compile 'com.google.android.gms:play-services-vision:9.0.0+'

in build.gradle dependencies in the Android module, like in this tutorial. This did not work (maybe I should write it somewhere else? I can't figure it out). Now there are many inspections shown in this build.gradle. There is said that there components cannot be applied to groovy.lang.Closure.

I have installed the Google Repository. And I've completed that tutorial, which is not LibGDX, and everything works fine there.

So how to make it work with LibGDX?


Solution

  • The solution is to add:

    compile 'com.google.apis:google-api-services-vision:v1-rev20-1.22.0'
    

    into root build.gradle (located in the root of your project) under android dependencies and not to module specific one.

    project(":android") {
        apply plugin: "android"
    
        configurations { natives }
    
        dependencies {
            compile project(":core")
            ........
            compile 'com.google.apis:google-api-services-vision:v1-rev20-1.22.0'
        }
    }