使用 Refrofit 简单 xml 转换器时出现编译错误

Getting compilation error when using Refrofit simple xml converter

我是 android 和 xmpp 的初学者,我正在开发一个使用 xmpp 作为协议和 openfire 的聊天应用程序 server.I 我正在使用 xmpp rest api 创建一个 group.To 创建一个组我需要使用 xml 数据主体向服务器发送 GET 请求..我在 android client.Whenever 中使用 retrofit2 我正在构建我的应用程序它给了我这个错误

错误:

E

rror:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:(com.bea.xml.stream.util.CircularQueue) that doesn't come with an
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:compiler that did not target the modern .class file format. The recommended
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:this warning is that reflective operations on this class will incorrectly
Error:indicate that it is *not* an inner class.
Error:trouble processing "javax/xml/XMLConstants.class":
Error:Ill-advised or mistaken usage of a core class (java.* or javax.*)
Error:when not building a core library.
Error:This is often due to inadvertently including a core library file
Error:in your application's project, when using an IDE (such as
Error:Eclipse). If you are sure you're not intentionally defining a
Error:core class, then this is the most likely explanation of what's
Error:going on.
Error:However, you might actually be trying to define a class in a core
Error:namespace, the source of which you may have taken, for example,
Error:from a non-Android virtual machine project. This will most
Error:assuredly not work. At a minimum, it jeopardizes the
Error:compatibility of your app with future versions of the platform.
Error:It is also often of questionable legality.
Error:If you really intend to build a core library -- which is only
Error:appropriate as part of creating a full virtual machine
Error:distribution, as opposed to compiling an application -- then use
Error:the "--core-library" option to suppress this error message.
Error:If you go ahead and use "--core-library" but are in fact
Error:building an application, then be forewarned that your application
Error:will still fail to build or run, at some point. Please be
Error:prepared for angry customers who find, for example, that your
Error:application ceases to function once they upgrade their operating
Error:system. You will be to blame for this problem.
Error:If you are legitimately using some code that happens to be in a
Error:core package, then the easiest safe alternative you have is to
Error:repackage that code. That is, move the classes in question into
Error:your own package namespace. This means that they will never be in
Error:conflict with core system classes. JarJar is a tool that may help
Error:you in this endeavor. If you find that you cannot do this, then
Error:that is an indication that the path you are on will ultimately
Error:lead to pain, suffering, grief, and lamentation.
Error:1 error; aborting
:app:transformClassesWithDexForDebug FAILED
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_05\bin\java.exe'' finished with non-zero exit value 1

下面是我的改造代码

@GET("/plugins/restapi/v1/groups")
        Call<Void> createGroup(@Header("Accept") String content_type,
                               @Header("Authorization") String authorization,
                               @Body Group group);

函数

public static int doCreateGroup(String content_type, String authorization, Group group) {
        Retrofit retrofit = new Retrofit.Builder().baseUrl(StaticVariables.base_url)
                .client(new OkHttpClient())
                .addConverterFactory(SimpleXmlConverterFactory.create()).build();
        Alfa alfa = retrofit.create(Alfa.class);
        Call<Void> call = alfa.createGroup(content_type, authorization, group);
        try {
            Response<Void> response = call.execute();
            Log.e("Group Upi", String.valueOf(response.code()));
            return response.code();
        } catch (IOException e) {
            e.printStackTrace();
            return 0;
        }

    }

下面是我组的模型

@Root(name = "group")
public class Group {
    @Element(name = "name")
    public String name;

    @Element(name = "description")
    public String description;

    public Group(String name,String description){
        this.description=description;
        this.name=name;
    }

}

下面是我必须发送的实际 xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<group>
    <name>GroupName</name>
    <description>Some description</description>
</group>

下面是我的依赖项

compile 'com.google.android.gms:play-services:9.4.0'
    compile 'com.google.firebase:firebase-core:9.4.0'
    compile 'com.android.support:cardview-v7:23.2.0'
    compile 'com.android.support:recyclerview-v7:23.2.0'
    compile 'org.igniterealtime.smack:smack-android:4.1.4'
    compile 'org.igniterealtime.smack:smack-tcp:4.1.4'
    compile 'org.igniterealtime.smack:smack-im:4.1.4'
    compile 'org.igniterealtime.smack:smack-extensions:4.1.4'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
    compile 'com.google.code.gson:gson:2.6.2'
    compile 'com.squareup.retrofit2:converter-simplexml:2.1.0'
    compile('com.digits.sdk.android:digits:1.10.3@aar') {
        transitive = true;
    }

请告诉我哪里错了

错误是因为一些类 in simple xml converter.So 我们只需要删除一些类,解决方案是,只需在gradle编译依赖

compile ('com.squareup.retrofit2:converter-simplexml:2.1.0') {
        exclude group: 'xpp3', module: 'xpp3'
        exclude group: 'stax', module: 'stax-api'
        exclude group: 'stax', module: 'stax'
    }