2016-09-23 5 views
3

Я начинаю работать в android и xmpp, я разрабатываю приложение чата с использованием протокола xmpp в качестве протокола и openfire как server.Я использую xmpp rest api для создания группы. Чтобы создать группа мне нужно отправить запрос GET на сервер с body..I XML-данными я использую retrofit2 в андроиде client.Whenever я строй моего заявления он дает мне эту ошибкуПолучение ошибки компиляции при использовании Refrofit simple xml converter

Ошибка:

E

rror:warning: Ignoring InnerClasses attribute for an anonymous inner class 
Error:(com.bea.xml.stream.util.CircularQueue$1) 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:[email protected]') { 
     transitive = true; 
    } 

Пожалуйста, скажи мне, где я неправильно

ответ

5

Ошибки из-за некоторые классы в простом 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' 
    } 
Смежные вопросы