We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose Andoird Samples Crashes

Whenever I Run any of aspose Android sample, It crashes and says “Unfortunately, AppName is stopped”. Even the hello world example is not working.

Hi,


Please see the article/ document on how to use Aspose.Cells in a simple Android project for a “hello world” example for your reference:
http://www.aspose.com/docs/display/cellsandroid/Your+First+Application+using+Aspose.Cells+for+Android±+Hello+World

After running the example fine in a separate Android project in Eclipse ADT, you may just copy/paste any of the example or sample code to compile and run it accordingly.

Let us know if you still have any issue with using Aspose.Cells for Android in a project.

Thank you.

I have tried it but problem is still not solved. I have found the reason that whenever I import any of aspose.cell package and make an object of any class from it, the app craches when it reaches at that line. if I run the same app without using any class from aspose.jar, the same app goes fine.

There is something wrong with the jar files. I have downloaded aspose-cells-8.3.1-android.zip, Are they for android platform or for some other platform.

More precisely the code no 1 works fine while the code no 2 crashes the application just after it is launched.

//Code No 1:
try {
Toast.makeText(MainActivity.this, “Hello”, Toast.LENGTH_LONG).show();
Workbook wb=null;
} catch (Exception e) {
Toast.makeText(MainActivity.this, “Error”, Toast.LENGTH_LONG).show();
}
//Code No 2
try {
Toast.makeText(MainActivity.this, “Hello”, Toast.LENGTH_LONG).show();
Workbook wb=new Workbook();
} catch (Exception e) {
Toast.makeText(MainActivity.this, “Error”, Toast.LENGTH_LONG).show();
}

Hi,


I am not sure why you are getting this error (you should browse on other INTERNET forums for the error (e.g you may check on Stackoverflow for your reference)). I have tested our latest version: Aspose.Cells for Android v8.3.1 by using in a simple Android project under eclipse ADT (v21.1.0-569685) with Android v4.2.2, it works absolutely fine and I could not find any issue what so ever. I generated the output file by importing simple data into it, I pushed the file from “\mnt\sdcard” to the disk path and attach it here for your reference:
e.g
Sample code:


----MainActivity.java----
package com.example.com.example.helloworld1;

import java.io.File;
import java.util.Random;

import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.view.Menu;

import com.aspose.cells.Cells;
import com.aspose.cells.CellsHelper;
import com.aspose.cells.IWarningCallback;
import com.aspose.cells.WarningInfo;
import com.aspose.cells.WarningType;
import com.aspose.cells.Workbook;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try{
String sdCardPath = Environment.getExternalStorageDirectory().getPath()+ File.separator;

CellsHelper.setFontDir(sdCardPath + “font”);

//Instantiate a new Workbook
Workbook workbook = new Workbook();
//Get the first worksheet (default sheet) in the Workbook
Cells cells = workbook.getWorksheets().get(“Sheet1”).getCells();
//Define a multi-dimensional array and store some data into it.
String[][] strArray = {
{“A”, “1A”,“2A” },
{“B”, “2B”, “3B”}
};
//Import the multi-dimensional array to the sheet
cells.importArray(strArray, 0, 0);
//Save the Excel file.
workbook.save(sdCardPath + “outimportmultidimarrays2.xlsx”);
}
catch (Exception e)
{
e.printStackTrace();
}
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

}

class WarningCallback implements IWarningCallback {

@Override
public void warning(WarningInfo info) {
if(info.getWarningType() == WarningType.FONT_SUBSTITUTION)
{
System.out.println(“WARNING INFO: " + info.getDescription());
}
}
}


I will paste here the manifest file contents for your reference too.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=“http://schemas.android.com/apk/res/android
package=“com.example.com.example.helloworld1”
android:versionCode=“1”
android:versionName=“1.0” >
<uses-sdk
android:minSdkVersion=“8”
android:targetSdkVersion=“17” />

<application
android:allowBackup=“true”
android:icon=”@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=“com.example.com.example.helloworld1.MainActivity”
android:label="@string/app_name" >




Thank you.

I have also tested it on multiple OS, sdks and Android VMs. Thing goes wrong just as I create object an initialize it. I thought it may be a liciencing problem and also tried to use licence file but when I created the new object of Licence class, app crashed again.

Hi,


I am afraid, we are not sure why you are getting this issue. We tested Aspose.Cells for Android in separate eclipse ADT projects on different machines and platforms and it works absolutely fine and we could not trace the issue “Unfortunately, AppName is stopped”. So, we have no clue why you are getting this exception and why your application crashed out.

We recommend you a few things to try it on your end.
1) Kindly check and evaluate logcat window especially when your application crashes, so that you could debug it and find the culprit item accordingly.

2) Moreover, try to extend the JVM memory in “eclipse.ini” file (from the folder where your eclipse is located/installed). For example, you may try to find the “-Xmx” and give sufficient amount of RAM e.g to:
“-Xmx2000m” and check if it makes any difference.

If you still find the problem, kindly create a simple sample and a separate project in eclipse ADT, zip the project and share it here with all the files and resources, we will check it soon.

Thank you.

I reviewed the logCat window, It generated ClassDefNotFound Exception and app crashes.

I surrounded my following code in try block and catch block with NoClassDefFoundError exception. Finally my app launched succefully and I caught the exception and it displayed the message “com.aspose.cells.Workbook” in a Toast message.
//This code crashes my Application
Workbook wb=new Workbook(2);
Toast.makeText(MainActivity.this, “Hello”, Toast.LENGTH_LONG).show();
//This is the modified code which didn’t crash my app and display the given message.
try {
Workbook wb=new Workbook(2);
Toast.makeText(MainActivity.this, “Hello”, Toast.LENGTH_LONG)
.show();
} catch (NoClassDefFoundError e) {
Toast.makeText(MainActivity.this, "Error 1: " + e.getMessage(),
Toast.LENGTH_LONG).show();
}
I have included all the jar files and imported the required packages and code have no compile time errors. LogCat log is attached.

Hi,


Thanks for sharing the logcat contents.

Well, the error "NoClassDefFoundError " suggests and it looks Aspose.Cells for Android library jar(s) are not referenced properly, you should select Aspose.Cells for Android jars in Java build path (Order and Export) dialog, see the screen shot attached here for your reference:

Let us know if you still find any issue.

Thank you

Thank God this problem is solved in this century. I am very thankful to you too Sir.

Hi,


Thanks for your feedback.

Good to know that it figures out your issue now. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.