gpt4 book ai didi

java - android ClassNotFoundException : com. sun.msv.datatype.xsd.XSDatatype

转载 作者:行者123 更新时间:2023-12-01 09:37:37 25 4
gpt4 key购买 nike

我有一个使用 Apache POI 的应用程序。构建成功,但是当我运行代码时出现错误(我使用 Android Studio 2.1):

Execution failed for task ':app:transformClassesWithInstantRunForDebug'.
java.lang.ClassNotFoundException: com.sun.msv.datatype.xsd.XSDatatype

这是我的代码:

package com.example.lionel.xls_test;

import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.TextView;

import com.google.android.gms.appindexing.Action;
import com.google.android.gms.appindexing.AppIndex;
import com.google.android.gms.common.api.GoogleApiClient;

import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.CellReference;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;

import java.io.FileInputStream;
import java.io.IOException;

/**
* Created by Lionel on 31/07/2016.
*/
public class MainActivity extends Activity {

private TextView texte = null;

/**
* ATTENTION: This was auto-generated to implement the App Indexing API.
* See https://g.co/AppIndexing/AndroidStudio for more information.
*/


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
texte = (TextView) findViewById(R.id.question);

try {
FileInputStream file = new FileInputStream("C:/test.xls");
HSSFWorkbook wb = new HSSFWorkbook(file);
HSSFSheet sheet = wb.getSheetAt(0);
CellReference cr = new CellReference("A1");
Row row = sheet.getRow(cr.getRow());
Cell cell = row.getCell(cr.getCol());
String name = cell.getStringCellValue();
texte.setText(name);

} catch (IOException e) {
e.printStackTrace();
}


}
}

我认为我实现了 POI Apache 的所有 .jar 文件,这里是依赖项:

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile project(':poi-3.14-20160307')
compile project(':poi-ooxml-3.14-20160307')
compile project(':poi-ooxml-schemas-3.14-20160307')
compile project(':xmlbeans-2.6.0')
compile 'com.google.android.gms:play-services-appindexing:8.1.0'
compile project(':dom4j-1.6.1')
compile project(':poi-excelant-3.14-20160307')
compile project(':poi-scratchpad-3.14-20160307')
compile project(':commons-codec-1.10')
compile project(':commons-logging-1.2')
compile project(':log4j-1.2.17')
compile project(':junit-4.12')
}

我的代码中是否缺少某些内容?谢谢您的帮助

最佳答案

您显然需要添加 xsdlib作为项目的运行时依赖

关于java - android ClassNotFoundException : com. sun.msv.datatype.xsd.XSDatatype,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38726958/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com