0

I try to make an android client for a server using spring's OAuth2 dependency. The problem is that when I call this constructor:

OAuth2RestTemplate oAuthRestTemplate = new Auth2RestTemplate(resourceDetails);

I get this Exception:

Didn't find class "javax.xml.transform.stax.StAXSource" on path: DexPathList

I use Android Studio which uses gradle and I include the OAuth2 dependency like this:

dependencies {
    implementation 'org.springframework.security.oauth:spring-security-oauth2:2.3.0.RC1'
    ...
}

In a similar question, the accepted answer suggests to include the Spring rest-template dependency (compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE') but when I do this I get another error that I have also posted here.

I believe that the Spring rest-template dependency should not be included because it may already be imported by the Spring OAuth dependency. Is it true? And if it is, how can I solve the fact that another class (javax.xml.transform.stax.StAXSource) can't be found? I think the reason that this class can't be found is because I am on android which uses its own implementation of JDK as this answer suggests.

If anyone could help me solve this problem, it would be really appreciated.

Thanasis1101
  • 1,614
  • 4
  • 17
  • 28

1 Answers1

0

Seems that the other dependency was needed (spring-android-rest-template dependency), and I had to put both of them and also exclude the duplicate modules. I did it like this:

compile('org.springframework.android:spring-android-rest-template:2.0.0.M3') {
    exclude module: 'spring-android-core'
}

compile('org.springframework.security.oauth:spring-security-oauth2:2.3.0.RC1'){
    exclude module: 'spring-web'
}
Thanasis1101
  • 1,614
  • 4
  • 17
  • 28