Mateus Barbosa Mateus Barbosa - 2 months ago 17
Android Question

RestTemplate Spring is not showing in android

I'm trying to make my application get some data from a WebApi, so I added

compile 'org.springframework.boot:spring-boot-gradle-plugin:2.0.0.M3'

to my Gradle and Sync with the project, but when I tried to declare my
RestTemplate restTemplate = new RestTemplate();
, it just show that it cannot resolve the symbol "RestTemplate" and there's no error message at all but this. Have I done something wrong? Anyone knows why is that happening?

Answer

Just to add a more complete answer, the following code is the one I'm using:

android { 
    // Default code...

    repositories {
        maven {
            url 'https://repo.spring.io/libs-milestone'
        }
    }
    packagingOptions {
        exclude 'META-INF/ASL2.0'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/notice.txt'
    }
}
dependencies {
    // Default code...
    compile 'org.springframework.android:spring-android-rest-template:2.0.0.M3'
}
Comments