2012-09-10 38 views
0

我用在這個所示(APV PDF瀏覽器)連接 link1 & link2的Android UnsatisfiedLinkError:parseFile採用APV

反正它工作正常。但是,當我通過這個項目改變了包的名字,它給了我以下異常:

09-10 22:02:35.936: E/AndroidRuntime(556): FATAL EXCEPTION: main 
09-10 22:02:35.936: E/AndroidRuntime(556): java.lang.UnsatisfiedLinkError: parseFile 
09-10 22:02:35.936: E/AndroidRuntime(556): at cx.hell.android.pdfviewIktab.PDF.parseFile(Native Method) 
09-10 22:02:35.936: E/AndroidRuntime(556): at cx.hell.android.pdfviewIktab.PDF.<init>(PDF.java:87) 
09-10 22:02:35.936: E/AndroidRuntime(556): at cx.hell.android.pdfviewIktab.OpenFileActivity.getPDF(OpenFileActivity.java:569) 
09-10 22:02:35.936: E/AndroidRuntime(556): at cx.hell.android.pdfviewIktab.OpenFileActivity.startPDF(OpenFileActivity.java:530) 
09-10 22:02:35.936: E/AndroidRuntime(556): at cx.hell.android.pdfviewIktab.OpenFileActivity.onCreate(OpenFileActivity.java:282) 
09-10 22:02:35.936: E/AndroidRuntime(556): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 
09-10 22:02:35.936: E/AndroidRuntime(556): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) 
09-10 22:02:35.936: E/AndroidRuntime(556): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 
09-10 22:02:35.936: E/AndroidRuntime(556): at android.app.ActivityThread.access$2300(ActivityThread.java:125) 
09-10 22:02:35.936: E/AndroidRuntime(556): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 
09-10 22:02:35.936: E/AndroidRuntime(556): at android.os.Handler.dispatchMessage(Handler.java:99) 
09-10 22:02:35.936: E/AndroidRuntime(556): at android.os.Looper.loop(Looper.java:123) 
09-10 22:02:35.936: E/AndroidRuntime(556): at android.app.ActivityThread.main(ActivityThread.java:4627) 
09-10 22:02:35.936: E/AndroidRuntime(556): at java.lang.reflect.Method.invokeNative(Native Method) 
09-10 22:02:35.936: E/AndroidRuntime(556): at java.lang.reflect.Method.invoke(Method.java:521) 
09-10 22:02:35.936: E/AndroidRuntime(556): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 
09-10 22:02:35.936: E/AndroidRuntime(556): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 
09-10 22:02:35.936: E/AndroidRuntime(556): at dalvik.system.NativeStart.main(Native Method) 

這是類(PDF.java):

package cx.hell.android.pdfviewIktab; 

import java.io.File; 
import java.io.FileDescriptor; 
import java.util.List; 
import cx.hell.android.lib.pagesview.FindResult; 


public class PDF { 
static { 
    System.loadLibrary("pdfview2"); 
} 


public static class Size implements Cloneable { 
    public int width; 
    public int height; 

    public Size() { 
     this.width = 0; 
     this.height = 0; 
    } 

    public Size(int width, int height) { 
     this.width = width; 
     this.height = height; 
    } 

    public Size clone() { 
     return new Size(this.width, this.height); 
    } 
} 


private int pdf_ptr = -1; 
private int invalid_password = 0; 

public boolean isValid() { 
    return pdf_ptr != 0; 
} 

public boolean isInvalidPassword() { 
    return invalid_password != 0; 
} 

synchronized private native int parseFile(String fileName, int box, String password); 

synchronized private native int parseFileDescriptor(FileDescriptor fd, int box, String password); 

public PDF(File file, int box) { 

// this is the line of (cx.hell.android.pdfviewIktab.OpenFileActivity.getPDF(OpenFileActivity.java:569)) 
    this.parseFile(file.getAbsolutePath(), box, ""); 
} 

public PDF(FileDescriptor file, int box) { 
    this.parseFileDescriptor(file, box, ""); 
} 

synchronized public native int getPageCount(); 

synchronized public native int[] renderPage(int n, int zoom, int left, int top, 
     int rotation, boolean gray, boolean skipImages, PDF.Size rect); 

synchronized public native int getPageSize(int n, PDF.Size size); 

synchronized public native List<FindResult> find(String text, int page); 

synchronized public native void clearFindResult(); 

synchronized public native List<FindResult> findOnPage(int page, String text); 

synchronized private native void freeMemory(); 

public void finalize() { 
    try { 
     super.finalize(); 
    } catch (Throwable e) { 
    } 
    this.freeMemory(); 
} 
} 

任何幫助,請?提前致謝。

回答

0

此錯誤表示Android Dalvik虛擬機無法找到給定Java類/方法所需的本機庫。請正確構建本地庫。如果本地庫已經正確創建,並且您確信它應該沒有問題地加載,那麼它就是Android/Dalvik bug或NDK bug ...但是這是不太可能的。這個問題已經在APV的用戶羣中多次提出,通常是因爲提出這個問題的人不知道JNI的基礎知識。

如果你仍然不知道如何解決這個問題,我會建議爲Java創建基本的JNI「hello,world」應用程序,然後爲Android(使用android-ndk)創建一個基本的JNI應用程序。這應該爲你清理一些事情。

對不起,但這個錯誤與APV本身無關,APV在這裏沒有做任何特殊的神祕魔法,它只是使用許多其他應用程序使用的標準驗證技術(JNI)。

Java如何發現和調用本機方法的說明:http://docs.oracle.com/javase/6/docs/technotes/guides/jni/spec/design.html#wp679

您粘貼的代碼已將pdfview軟件包名稱更改爲pdfviewIktab。確保您已經相應地更改了JNI(C)函數名稱。

+0

好的謝謝你的回答。 – user1553381

+0

是的,我將pdfview2.c中的包的名稱改爲了Java_cx_hell_android_pdfviewIktab而不是Java_cx_hell_android_pdfview,並且仍然給我提供了同樣的錯誤。 – user1553381