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

Free Support Forum - aspose.com

Re: Get IllegalAccessError while using Document.class

Not Resolve the Same error

FATAL EXCEPTION: main
java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
at com.aspose.words.Document.(Unknown Source)
at com.aspose.words.android.helloworld.MainActivity.onCreate(MainActivity.java:91)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)

Kinldy helpout

thank you

Hi Rahul,

Thanks for your inquiry. Please provide more details about this exception. What Aspose.API are you using? Please zip and attach source code and input document you’re getting this problem with here for testing. We will then investigate the issue on our end and provide you more information.

Best regards,

Sir file is not getting uploaded can u please provide any way to send the details .

Thank you

More Details

i wand to browse the documnt file like doc excel files

so i am sending the path to the document constructor its showing this kinds of errors

This is my Main Activity

and error is showing at the pink part


/**
* Copyright 2001-2013 Aspose Pty Ltd. All Rights Reserved.
*
* This file is part of Aspose.Words. The source code in this file
* is only intended as a supplement to the documentation, and is provided
* "as is", without warranty of any kind, either expressed or implied.
*/

package com.aspose.words.android.helloworld;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Environment;
import android.app.Activity;
import android.graphics.Color;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.aspose.words.Document;
import com.aspose.words.DocumentBuilder;

public class MainActivity extends Activity {

private static final int REQUEST_PATH = 1;

String curFileName;

EditText edittext;
public void GenerateDocument() throws Exception {

// This is the path to the SD card.
String dataDir = Environment.getExternalStorageDirectory().getPath() + File.separator;

// Create a new document.
Document doc = new Document();
Document document=new Document();
document.appendDocument(doc, MODE_APPEND);
document.toString();

// Use the document builder to insert text and other elements into the document.
DocumentBuilder builder = new DocumentBuilder(doc);
builder.getFont().setColor(Color.GREEN);
builder.writeln("Hello World!");
Bitmap bitmap = BitmapFactory.decodeResource(getApplicationContext().getResources(), R.drawable.ic_launcher);
builder.insertImage(bitmap);

//String doctext=doc.getText();
[//System.out.println](//System.out.println)(doctext);

// Save the document as different formats to the memory card.
// doc.save(dataDir + "Document Out.doc");
doc.save(dataDir + "Document Out.docx");
doc.save(dataDir + "Document Out.ooxml");
// doc.save(dataDir + "Document Out.pdf");

}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

final TextView tx = (TextView) findViewById(R.id.textBox);

try {
// GenerateDocument();
tx.setText("Documents created successfully, please check the root of your SD card");
} catch (Exception e) {
tx.setText("Error during document processing: " + e.getMessage());
}
edittext = (EditText)findViewById(R.id.editText);
InputStream fis = null;

try {
fis = new FileInputStream("C:\Users\User\Desktop"+"Desktop.docx");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
try {
Document document=new Document("C:\Users\User\Desktop\"+"Desktop.docx");
document.getText();
System.out.println("This is Desktop file"+document.getText());
} 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;
}
public void getfile(View view){
Intent intent1 = new Intent(this, FileChooser.class);
startActivityForResult(intent1,REQUEST_PATH);
}
// Listen for results.
protected void onActivityResult(int requestCode, int resultCode, Intent data){
// See which child activity is calling us back.
if (requestCode == REQUEST_PATH){
if (resultCode == RESULT_OK) {
curFileName = data.getStringExtra("GetFileName");
edittext.setText(curFileName);
}
}
}
}

Hi Rahul,

Thanks for your inquiry. Please download and try https://dl.dropboxusercontent.com/u/75404275/HelloWorld-v1.zip project. I have passed string parameter to the Document constructor and it works fine on my end. Hope, this helps.

Best regards,

Sir i want to read the file and i think you have sended me how to write it

Can u send me the example of how to read the document or the excel file that is stored in same path u have given

will be helpfull

thank you.

Hi Rahul,

Thanks for your inquiry. Please refer to the following sections of documentation:

How to Extract Selected Content Between Nodes in a Document using Aspose.Words for Android

Save Entire Workbook into Text or CSV Format using Aspose.Cells for Android

Hope, this helps.

Best regards,

Hello sir i just want to execute this below code


button.setOnClickListener(new View.OnClickListener() {
   @Override
   public void onClick(View v) {
      try {
         Document document=new Document("C:\\Users\\User\\Desktop\\Desktop.docx");
         document.getText();
         System.out.println("This is Desktop file"+document.getText());
      } catch (Exception e) {
         e.printStackTrace();
      }
   }
});

when i execute the following code i get this kind of errors

FATAL EXCEPTION: main

java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation

at com.aspose.words.Document.(Unknown Source)
at com.aspose.words.android.helloworld.MainActivity.onCreate(MainActivity.java:91)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)

justs thats it…

Kindly help it out.

thank you again for replying

Hi Rahul,

Thanks for your inquiry. Could you please attach your input Word document here for testing? We will investigate the issue on our end and provide you more information. Also, are you getting this problem with one particular document (C:\Users\User\Desktop\Desktop.docx) or every document you try cause the same issue?

Best regards,

getting same error for all types of documents

Hi Rahul,

Thanks for your inquiry. We are working over your query and will get back to you soon.

Best regards,

Hi Rahul,

Please upgrade to the latest version of Aspose.Words for Android 17.2.0 and see how it goes on your end? Hope, this helps.

Please also check: How to Use Aspose.Words for Android from 17.2.0 Onward

Best regards,