centic9 / poi-on-android

A sample project that shows how Apache POI can be used in an Android application
Apache License 2.0
357 stars 89 forks source link

Error:Execution failed for task #28

Closed DipakMahapurkar closed 2 years ago

DipakMahapurkar commented 6 years ago

Hello @centic9, Thanks For such great library. I am integrating it in android application, At the time of build it will not giving any error, But When i run my app the below exception is getting. I am not able to run my app. Please help me. Thanks in advance.

I am using jar file and version is latest one.

Error:Execution failed for task ':app:transformClassesWithNewClassShrinkerForDebug'.

com.android.build.gradle.shrinker.ClassLookupException: Invalid class reference: javax/xml/crypto/KeySelector

centic9 commented 6 years ago

This indicates that you use some signing/encryption and we do not include proper shaded versions of the code currently, you can try to adjust the exclude and relocate statements in build.gradle to see if that makes it work.

centic9 commented 6 years ago

Can you provide some sample code for what you try to do so I can try to add this to the sample project?

DipakMahapurkar commented 6 years ago

Thanks @centic9 for reply. Actually i am not use any signing/encryption, I am just using the MD5 password, But that mothod is not use any kind of library, You can check my build.gradle file.

apply plugin: 'com.android.application'

android { compileSdkVersion 25 buildToolsVersion "25.0.2" defaultConfig { applicationId "com.schoolapp" minSdkVersion 15 targetSdkVersion 25 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { debug { minifyEnabled true useProguard false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } release { minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } }

aaptOptions {
    cruncherEnabled = true
}

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

}

dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) testCompile 'junit:junit:4.12' compile 'com.android.support.constraint:constraint-layout:1.0.2' compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1' compile 'com.android.support:appcompat-v7:25.3.1' compile 'com.android.support:design:25.3.1' compile 'com.intuit.sdp:sdp-android:1.0.4' compile 'com.intuit.ssp:ssp-android:1.0.4' compile 'com.squareup.okhttp3:okhttp:3.8.1' compile 'com.squareup.retrofit2:retrofit:2.3.0' compile 'com.squareup.retrofit2:converter-gson:2.3.0' compile 'com.android.support:support-v4:25.3.1' compile 'com.android.support:gridlayout-v7:25.3.1' compile 'com.android.support:recyclerview-v7:25.3.1' compile 'com.android.support:cardview-v7:25.3.1' compile 'de.hdodenhof:circleimageview:1.3.0' compile 'com.master.android:permissionhelper:1.0' compile 'com.wdullaer:materialdatetimepicker:3.2.0' compile 'com.github.clans:fab:1.6.4' compile 'com.master.android:glideimageview:1.0' compile 'com.github.MdFarhanRaja:SearchableSpinner:1.2' compile 'com.github.lovetuzitong:MultiImageSelector:1.2' compile 'com.github.PhilJay:MPAndroidChart:v3.0.2' compile 'com.github.barteksc:android-pdf-viewer:2.0.3' compile files('libs/poishadow-all.jar') }

Source code:

private boolean saveExcelFile(String fileName) { // check if available and not read only if (!isExternalStorageAvailable() || isExternalStorageReadOnly()) { Log.e(TAG, "Storage not available or read only"); return false; } boolean success = false; //New Workbook Workbook wb = new HSSFWorkbook(); Cell c = null; //Cell style for header row CellStyle cs = wb.createCellStyle(); cs.setFillForegroundColor(HSSFColor.LIME.index); //New Sheet Sheet sheet1 = null; sheet1 = wb.createSheet("wrok"); // Generate column headings Row row = sheet1.createRow(0); c = row.createCell(0); c.setCellValue("Name"); c.setCellStyle(cs); c = row.createCell(1); c = row.createCell(2); c.setCellValue("M"); c.setCellStyle(cs); c = row.createCell(3); c.setCellValue("A"); c.setCellStyle(cs); c = row.createCell(4); c.setCellValue("E"); c.setCellStyle(cs); int rowOne = 1; for (int i = 0; i < mChrDataList.size(); i++) { final Row row1 = sheet1.createRow(rowOne); int cell = 0; Cell cell1 = row1.createCell(cell++); cell1.setCellValue(mChrDataList.get(i).getStudentName()); cell1 = row1.createCell(cell++); cell1.setCellValue(mChrDataList.get(i).getMorning()); cell1 = row1.createCell(cell++); cell1.setCellValue(mChrDataList.get(i).getAfternoon()); cell1 = row1.createCell(cell++); cell1.setCellValue(mChrDataList.get(i).getEvening()); rowOne += 1; } sheet1.setColumnWidth(2, (15 * 500)); // Create a path where we will place our List of objects on external storage File file = new File(this.getExternalFilesDir(null), fileName); FileOutputStream os = null;

    try {
        os = new FileOutputStream(file);
        wb.write(os);
        Log.w("FileUtils", "Writing file" + file);
        success = true;
    } catch (IOException e) {
        Log.w("FileUtils", "Error writing " + file, e);
    } catch (Exception e) {
        Log.w("FileUtils", "Failed to save file", e);
    } finally {
        try {
            if (null != os)
                os.close();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    return success;
}

Thanks ... Please help me

centic9 commented 6 years ago

I tried to reproduce this with the included sample application but couldn't. Maybe you can use this sample app and add stuff from your app one-by-one to find out what is causing this?

centic9 commented 2 years ago

No update in a long time, so I expect this is either solved or not an issue any more.