karelpeeters
01/10/2019, 7:29 PMamanda.hinchman-dominguez
01/10/2019, 7:32 PMamanda.hinchman-dominguez
01/10/2019, 7:32 PMamanda.hinchman-dominguez
01/10/2019, 7:32 PMRavin Jain
12/05/2020, 1:33 AMimport cocoapods.<libraryname>.*
but its not able to find the library. I am trying to develop a kotlin library which works on both ios and android.
Do i have to add a Podfile as well ?Daronee
12/06/2020, 1:41 AMCyberpunk Keanu
12/07/2020, 12:25 PM<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="<http://schemas.xmlsoap.org/soap/envelope/>" xmlns:glob="<http://sap.com/xi/SAPGlobal20/Global>">
<soap:Header/>
<soap:Body>
{Data structure will change here as per different apis}
</soap:Body>
</soap:Envelope>
Now I've generated this Generic Class called GeneralRequestEnvelope
and added a Generic Type paramter so that I can define which Class Type I'll be appending to the body when calling the Apis.
GeneralRequestEnvelope.kt
import com.tickaroo.tikxml.annotation.Xml
import com.tickaroo.tikxml.annotation.Element
@Xml(
name = "soap:Envelope",
writeNamespaces = [
"soap=<http://schemas.xmlsoap.org/soap/envelope/>",
"glob=<http://sap.com/xi/SAPGlobal20/Global>"
]
)
class GeneralRequestEnvelope <Type> {
@Element(name = "soap:Header")
var header: String? = null
@Element(name = "soap:Body")
var body: Type? = null /**Must ALWAYS be a class but can be any XML defined class**/
}
Then I define my api endpoint in the Retrofit Interface like..
Api.kt
interface Api {
@Headers("Content-Type: text/xml; charset=utf-8")
@POST("querysitelogisticstaskin")
fun callSampleSoapApiAsync(
@Body data: GeneralRequestEnvelope<TasksByElementsQuery>
) : Deferred<GeneralResponseEnvelope>
}
And then finally I'll call my api from my activity
MainActivity.kt
class MainActivity: BaseActivity(){
//All other non-relveant code above
suspend fun callTestSoapApi(
data: TasksByElementsQuery,
onDone: (response: GeneralResponseEnvelope) -> Unit
){
/** Here I'll Define which class type will be used as Body in the General Request*/
val request = GeneralRequestEnvelope<TasksByElementsQuery>()
request.body = data
response(onDone){
soapService.callSampleSoapApiAsync(request)
}
}
}
All well and Good. Now kapt is enabled in my project, and the Library TikXml
uses annotation processor on classes defined with @Xml
annotation to generate kapt classes with mappings between java pojo & xml. So when I build the project, I get this build error:
~:Project_Location\app\build\tmp\kapt3\stubs\developmentDebug\com\qwerty\soapapitest\codebase\models\envelopes\GeneralRequestEnvelope.java:13: error: The type of field 'body' in class com.qwerty.soapapitest.codebase.models.envelopes.GeneralRequestEnvelope is not a class nor a interface. Only classes or interfaces can be annotated with @Element annotation. If you try to annotate primitives than @PropertyElement
private Type body;
Going back to GeneralRequestEnvelope.kt, How do I define a Generic type of class there, which the annotation processor will recognize as I guess T::class.java
i.e. var Body is of a generic class of type T?
I'm not familiar with Kotlin Generics much so any help regarding this would be greatly appreciated. 🙏Vivek Modi
12/07/2020, 12:49 PMVivek Modi
12/07/2020, 12:49 PMVivek Modi
12/07/2020, 12:50 PMVivek Modi
12/07/2020, 12:50 PMVivek Modi
12/07/2020, 12:51 PMKrzysztof Światły
12/07/2020, 1:06 PMuser
12/07/2020, 2:20 PMScott Whitman
12/07/2020, 5:20 PMuser
12/07/2020, 5:43 PMuser
12/07/2020, 5:52 PMuser
12/07/2020, 6:01 PMPratik Tandel
12/07/2020, 8:57 PMuser
12/08/2020, 9:16 AMAbduqodiri Qurbonzoda [JB]
12/08/2020, 9:45 AMuser
12/08/2020, 1:10 PMadk
12/09/2020, 8:51 AMkotlin.test
package? (If I add them manually, everything works fine, so seems unlikely to be a setup error.)Jason
12/09/2020, 12:13 PMuser
12/09/2020, 12:13 PMJason
12/09/2020, 12:13 PMJason
12/09/2020, 12:13 PMCause: cannot find META-INF.versions.9.module-info: module-info found in META-INF/versions/9/module-info.class
user
12/09/2020, 1:23 PMuser
12/09/2020, 2:43 PMuser
12/09/2020, 3:42 PM