0

I have a table with one row and 2 columns, in the first column - some number, in the second - some text. When I run my application, it gives me an error. What is this error and how can I fix it?

java.lang.NoSuchFieldError: No static field Factory of type Lorg/apache/xmlbeans/impl/schema/DocumentFactory; in class Lorg/openxmlformats/schemas/drawingml/x2006/main/ThemeDocument; or its superclasses (declaration of 'org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocument' appears in /data/app/~~QChpwb2OXOVI6YAzHGza8A==/com.example.metro-E4N772ORpPjYJpUasqdLVQ==/base.apk!classes5.dex)

Below is the code of my MainActivity and dependencies:

public class MainActivity extends AppCompatActivity{


    TextView TextView;
    private static final String TAG = "myLogs";


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TextView = findViewById(R.id.textView3);
        TextView.setText("SomeText");

        try {

            AssetManager am=getAssets();
            InputStream is=am.open("MyTest.xlsx");
            XSSFWorkbook book = new XSSFWorkbook(is);
            XSSFSheet mySheet = book.getSheet("0");
            XSSFRow row = mySheet.getRow(0);

            if(row.getCell(0).getCellType() == CellType.STRING){
                String name = row.getCell(0).getStringCellValue();
                Log.d(TAG,"/////////////////////////////////////////////////////////////////////////////////////name : " + name);
            }
            if(row.getCell(0).getCellType() == CellType.NUMERIC){
                double date = row.getCell(0).getNumericCellValue();
                Log.d(TAG,"/////////////////////////////////////////////////////////////////////////////////////date : : " + date);
            }

            book.close();
            TextView.setText("SomeText after all");

        } catch(Exception ex) {
            Log.d(TAG, "Loooooooooooooooooooooooooooooooooooooooooooooooooooooolg "+String.valueOf(ex));
            return;
        }
    }
}

Dependency:

dependencies {

    implementation 'androidx.appcompat:appcompat:1.4.0'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
    implementation files('libs\\commons-codec-1.15.jar')
    implementation files('libs\\commons-compress-1.21.jar')
    implementation files('libs\\commons-logging-1.2.jar')
    implementation files('libs\\curvesapi-1.06.jar')
    implementation files('libs\\poi-5.1.0.jar')
    implementation files('libs\\poi-ooxml-5.1.0.jar')

    implementation files('libs\\slf4j-api-1.7.32.jar')
    implementation files('libs\\xmlbeans-5.0.2.jar')
    implementation files('libs\\log4j-api-2.14.1.jar')
    implementation files('libs\\commons-io-2.11.0.jar')
    implementation files('libs\\commons-math3-3.6.1.jar')
    implementation files('libs\\poi-ooxml-schemas-4.1.2.jar')

    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
4
  • 1
    you need to replace poi-ooxml-schemas-4.1.2.jar with poi-ooxml-lite-5.1.0.jar
    – PJ Fanning
    Commented Jan 26, 2022 at 18:07
  • What should I do with this? org.apache.poi.ooxml.POIXMLException: error: The 'namespace-prefix' feature is not supported while the 'namespaces' feature is enabled.
    – aDragon
    Commented Jan 27, 2022 at 12:19
  • that is a separate issue and I would need the full stack trace to check
    – PJ Fanning
    Commented Jan 27, 2022 at 12:48
  • What it can be connected with? I dont see nothing in my logcat
    – aDragon
    Commented Jan 27, 2022 at 13:25

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.