Free Support Forum - aspose.com

Cannot Save Any File on Android

Hi all!

I’m trying Aspose.Words for Android with the restricted evaluation version (free download). Unfortunately, I have problems already when trying the simplest examples: whenever saving a document (be it read from an existing file or a newly created one), a file is created with the name I specify, but this file is empty (0 bytes). The problem occurs with .docx, .doc, and .txt files; I haven’t tried other formats yet.

Here’s the code of one example which doesn’t work:

Document doc = new Document();
DocumentBuilder docb = new DocumentBuilder(doc);
docb.writeln("Test");

FileOutputStream stream = new FileOutputStream("/sdcard/Documents/FormatTest.doc");

doc.save(stream, SaveFormat.DOC);
stream.close();

No exception is thrown, and I can’t find anything helpful in the logs.

It doesn’t seem to be a problem related to permissions or other general Android storing issues: when I write a bunch of bytes directly to the FileOutputStream with stream.write(…), the bytes are written correctly.

I’m using Android 9 and Aspose.Words v. 20.9.0.

Thank you very much in advance for any help!

Cheers,

Chris

@christopher.kopel,

After an initial test with the licensed latest (20.9) version of Aspose.Words for Android via Java, we were unable to reproduce this issue on our end. We used the following simple code to test the scenario over Android 10 on our end:

License lic = new License();
lic.setLicense(pathto_License);

Document doc = new Document();
DocumentBuilder docb = new DocumentBuilder(doc);
docb.writeln("Test");

doc.save(outputPathof_DOCX);
doc.save(outputPath_PDF);

Can you please provide your Android Studio project to be able to reproduce the exact problem on our end?

Hi,

Thank you for your quick reply!

Here’s my AndroidStudio project. I removed the Aspose.Words jar file from the zip archive in order to reduce the file size; in my project, I put the library in the subdirectory app/libs and named it aspose.jar.

Thank you for your help!

Cheers,

Chris

Aspose-Words-Test-Project.zip (458.0 KB)

@christopher.kopel,

We are working on your query and will get back to you soon.

@christopher.kopel,

I am afraid, we are still unable to reproduce this problem on our end. Please see the following code that we used on our end for testing with 20.9 version of Aspose.Words for Android via Java API.