Azure / azure-sdk-for-java

This repository is for active development of the Azure SDK for Java. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/java/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-java.
MIT License
2.3k stars 1.96k forks source link

[ANDROID] Android incompatible method javax.xml.stream used causing Animal Sniffer test to fail on azure-core and azure-xml #36287

Open TristanBecker opened 1 year ago

TristanBecker commented 1 year ago

The method "javax.xml.stream.XMLStreamException" is used several time between this line and this line, As javax.xml.stream and its child classes are not Android compatible and this may cause issues.

The use of ReflectionSerializable in azure-core, as well as XmlReader, DefaultXmlReader and DefaultXmlWriter from azure-xml will result in compile time errors in Android

This is the output from animal-sniffer on azure-core

[ERROR] C:\Projects\azure-sdk-for-java\sdk\core\azure-core\src\main\java\com\azure\core\implementation\ReflectionSerializable.java:349: Undefined reference: javax.xml.stream.XMLStreamException
[ERROR] C:\Projects\azure-sdk-for-java\sdk\core\azure-core\src\main\java\com\azure\core\implementation\ReflectionSerializable.java:350: Undefined reference: javax.xml.stream.XMLStreamException
[ERROR] C:\Projects\azure-sdk-for-java\sdk\core\azure-core\src\main\java\com\azure\core\implementation\ReflectionSerializable.java:352: Undefined reference: javax.xml.stream.XMLStreamException
[ERROR] C:\Projects\azure-sdk-for-java\sdk\core\azure-core\src\main\java\com\azure\core\implementation\ReflectionSerializable.java:352: Undefined reference: void javax.xml.stream.XMLStreamException.<init>(Throwable)
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Microsoft Azure SDK for Java Parent 1.6.0 .......... SUCCESS [  0.308 s]
[INFO] Maven Build Tools 1.0.0 ............................ SUCCESS [  2.277 s]
[INFO] Microsoft Azure SDK for Java - Client Libraries 1.7.0 SUCCESS [  2.268 s]
[INFO] Microsoft Azure Java Core Library 1.43.0-beta.1 .... FAILURE [ 10.050 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE

A possible fix would be to use an external dependency for android users e.g. https://mvnrepository.com/artifact/javax.xml.stream/stax-api/1.0-2 or https://mvnrepository.com/artifact/stax/stax as we have had some success with this in Android

JonathanGiles commented 1 year ago

Thanks @TristanBecker

joshfree commented 1 year ago

related: https://github.com/Azure/azure-sdk-for-java/issues/36275

JonathanGiles commented 1 year ago

@TristanBecker To validate this, it would be a good idea to work on the sample Android app I mentioned on our Discord chat.