问题描述
我想读 XLSX 文件,所以我使用的 org.apache.poi:POI-OOXML:3.7
I want to read a XLSX file, so I am using org.apache.poi:poi-ooxml:3.7
现在我所做的一切,没有错误为止,但是当我运行该应用程序,Android的工作室给我一个奇怪的错误结果。
Now I have done everything, no errors so far, but when I am running the application, Android Studio is giving me a weird error
错误:执行失败的任务:应用程序:transformClassesWithDexForDebug。
com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:过程'命令'C:\\ Program Files文件\\的Java \\ jdk1.7.0 \\斌\\ java.exe的'非零退出值完成1
现在标记这个问题进行重复之前,让我告诉你我迄今所做的:
Now before marking this question as duplicate, let me tell you what I have done so far:
1。的build.gradle文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "in.example.excel"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'org.apache.poi:poi-ooxml:3.7'
}
结果
2。舱单申报MultiDex 结果<应用
机器人:名字=android.support.multidex.MultiDexApplication
...
搜索结果
3。 readExcelFile(...)方法
private void readExcelFile(String path, Context ironMaiden)
{
try
{
File iSFile = new File(path);
FileInputStream inputStream = new FileInputStream(iSFile);
Workbook workbook = WorkbookFactory.create(inputStream);
org.apache.poi.ss.usermodel.Sheet sheet = workbook.getSheetAt(0);
Row row = sheet.getRow(0);
for (int i = 0; i < row.getLastCellNum(); i++)
{
Cell cell = row.getCell(i);
Log.d("DEBUG", cell.getStringCellValue());
}
}
catch (IOException | InvalidFormatException io)
{
io.printStackTrace();
}
}
结果
4。重建和清洁
是的,我有重建项目,并清洗了好几遍。
我也没有通过命令行相同 gradlew干净
和 gradlew应用:依赖
我即将放弃这个库。请帮助。
I am about to give up on this library. Please Help.
推荐答案
我通过从外部添加两个JAR解决了这个问题。
I resolved the problem by Adding two JARs externally.
- POI-3.9.jar
- POI-00xml-3.9.jar
- poi-3.9.jar Download
- poi-00xml-3.9.jar Download
结果PS:请添加的JAR外部,通过行家添加它们产生令人困惑的错误
PS: Please add the JARs externally, adding them via maven generates a confusing error.
这篇关于错误:3.7库:添加POI-OOXML后执行失败的任务“:transformClassesWithDexForDebug:应用”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!