'Apache poi 5.2.2 - XWPFRun setText() error

I used Apache poi 4.1.2 and everything worked well . I tried the same code with the new version of Apache poi (5.2.2) and the error occurs when I use run.setText()

fun function(){
val document = XWPFDocument()
val paragraph = document!!.createParagraph()
        paragraph!!.alignment = alignment
        val run = paragraph!!.createRun()
        run!!.setText(text) --------> here the the error occurs
}

and i get this error:

E/org.apache.xmlbeans.SchemaTypeLoaderException: E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.e.testpoi, PID: 20131
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.e.testpoi/com.e.testpoi.MainActivity}: 
org.apache.xmlbeans.SchemaTypeLoaderException: Cannot resolve type for handle _XY_Q=space|R=space@http://www.w3.org/XML/1998/namespace (org.apache.poi.schemas.ooxml.system.ooxml.cttext7f5btype) - code 13
     Caused by: org.apache.xmlbeans.SchemaTypeLoaderException: Cannot resolve type for handle _XY_Q=space|R=space@http://www.w3.org/XML/1998/namespace (org.apache.poi.schemas.ooxml.system.ooxml.cttext7f5btype) - code 13
        at org.apache.xmlbeans.impl.schema.XsbReader.readHandle(XsbReader.java:483)
        at org.apache.xmlbeans.impl.schema.XsbReader.readTypeRef(XsbReader.java:548)
        at org.apache.xmlbeans.impl.schema.XsbReader.loadAttribute(XsbReader.java:1282)
        at org.apache.xmlbeans.impl.schema.XsbReader.readAttributeData(XsbReader.java:1275)
        at org.apache.xmlbeans.impl.schema.XsbReader.finishLoadingType(XsbReader.java:902)
        at org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl.resolveHandle(SchemaTypeSystemImpl.java:938)
        at org.apache.xmlbeans.SchemaComponent$Ref.getComponent(SchemaComponent.java:113)
        at org.apache.xmlbeans.SchemaType$Ref.get(SchemaType.java:1072)
        at org.apache.xmlbeans.impl.schema.SchemaPropertyImpl.getType(SchemaPropertyImpl.java:85)
        at org.apache.xmlbeans.impl.schema.SchemaTypeImpl.createElementType(SchemaTypeImpl.java:990)
        at org.apache.xmlbeans.impl.values.XmlObjectBase.create_element_user(XmlObjectBase.java:914)
        at org.apache.xmlbeans.impl.store.Xobj.getUser(Xobj.java:1597)
        at org.apache.xmlbeans.impl.store.Cur.getUser(Cur.java:2571)
        at org.apache.xmlbeans.impl.store.Xobj.insertElement(Xobj.java:2012)
        at org.apache.xmlbeans.impl.store.Xobj.add_element_user(Xobj.java:2093)
        at org.openxmlformats.schemas.wordprocessingml.x2006.main.impl.CTRImpl.addNewT(CTRImpl.java:318)
        at org.apache.poi.xwpf.usermodel.XWPFRun.setText(XWPFRun.java:362)
        at org.apache.poi.xwpf.usermodel.XWPFRun.setText(XWPFRun.java:349)

this is the single dependency i use build.gradle(app):

   implementation("org.apache.poi:poi-ooxml:5.2.2")

tried with/without these and the error didn't solve

    implementation("org.apache.xmlbeans:xmlbeans:5.0.3")

Tried these, Didn't work as well

   implementation("org.apache.poi:poi-ooxml-full:5.2.2")
   implementation("org.apache.poi:poi-ooxml-lite:5.2.2")


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source