Announcement

Collapse
No announcement yet.

[Android SDK] Unable to test any sample project

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Android SDK] Unable to test any sample project

    Hi,

    I want to create an Android App which can read \ write PDF files and display the PDF files embedded inside my App itself.
    To start, I would like try the Foxit samples but unsuccessfully.

    By following the steps of the tutorial "Using Foxit on the Android Platform", I don't understand step 5 a.

    ------------------------------------------------------------------------------------------------------
    The demo is shipped as:
    LOCAL_LDLIBS += ../bin/# fill in library name here

    To add downloaded libfoxit.a from step 2, fill in as:
    LOCAL_LDLIBS := ../bin/libfoxit.a

    If the library provide is not named "libfoxit.a" please adjust accordingly.
    -------------------------------------------------------------------------------------------------------

    Here are the contents of my Android.mk file in "fpdfemb_android/examples/demos/demo/jni/":

    # Copyright (C) 2009 The Android Open Source Project
    #
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    #
    # http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    #
    LOCAL_PATH := $(call my-dir)
    include $(CLEAR_VARS)
    LOCAL_MODULE := fpdfembedsdk
    LOCAL_SRC_FILES := ../../jni/FoxitEMBSDK_EMBJavaSupport.cpp
    LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../include
    LOCAL_LDLIBS := -llog -g -L. -ljnigraphics

    #fill in the foxit library here
    LOCAL_LDLIBS += ../bin/libfpdfemb_android.a

    include $(BUILD_SHARED_LIBRARY)

    After several attempts, I started compiling with the default file.
    This one was a success, but when I launch my App, it crash.
    I check if my files exist, and I update the parameters of the function named EMBJavaSupport.FSUnlock in the WrapPDFFunc.java with the corresponding License ID and Unlock Code specified in the sn.txt.

    However the log in a FPDFDocLoad(int fileRead, String password) function tell me invalidLicenseException message :
    "4527-4527/com.foxitsample.view V/FoxitDoc﹕ FPDFDocLoad: Doc did not load properly"

    Thanks and Regards,

    --
    Z4195

  • #2
    Hello Z4195,

    Please make sure your library is up-to-date, if you're unsure of what version you are using, use this link here http://cdn01.foxitsoftware.com/pub/f...2.1408_enu.zip is our current latest build. Please download the zip file, extract and overwrite where you previously had the library installed.

    Afterwards please change the Unlock value found to the one found in sn.txt, also if the parameters of the function EMBJavaSupport.FSUnlock have changed after the first time you built the NDK layer, remember to rebuild the NDK layer after changing the parameters. Please let me know if you are still having problems with the invalidLicenseException after rebuilding the NDK layer.

    Thank you,
    Huy Tran

    Comment


    • #3
      Hello huy_tran,

      First of all, I want to thank you for your support.
      However, "demo_view" not working yet.
      I made the different handling you had told me. But during the NDK build, I have errors:

      ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      [armeabi] SharedLibrary : libfpdfembedsdk.so
      C:/App/android-ndk-r9c/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: error: ../bin/libfpdfemb_android.a(dll_main.o): multiple definition of 'std::exception::exception()'
      C:/App/android-ndk-r9c/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: C:/App/android-ndk-r9c/sources/cxx-stl/stlport/libs/armeabi/libstlport_static.a(exception.o): previous definition here
      C:/App/android-ndk-r9c/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: error: ../bin/libfpdfemb_android.a(dll_main.o): multiple definition of 'vtable for std::exception'
      C:/App/android-ndk-r9c/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: C:/App/android-ndk-r9c/sources/cxx-stl/stlport/libs/armeabi/libstlport_static.a(exception.o): previous definition here
      C:/App/android-ndk-r9c/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: error: ../bin/libfpdfemb_android.a(dll_main.o): multiple definition of 'std::exception::exception()'
      C:/App/android-ndk-r9c/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: C:/App/android-ndk-r9c/sources/cxx-stl/stlport/libs/armeabi/libstlport_static.a(exception.o): previous definition here

      [...]

      collect2: ld returned 1 exit status
      /cygdrive/c/App/android-ndk-r9c/build/core/build-binary.mk:579: recipe for target 'obj/local/armeabi/libfpdfembedsdk.so' failed
      make: *** [obj/local/armeabi/libfpdfembedsdk.so] Error 1
      ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

      I tried to change the Application.mk file in demo_view/jni/
      I update stlport_static by stlport_shared, a build is success, but when I run the project with Android Studio, a demo view crash with an error:

      ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      03-20 11:42:14.157 17055-17055/com.foxitsample.view D/dalvikvm﹕ Trying to load lib /data/data/com.foxitsample.view/lib/libfpdfembedsdk.so 0x42253478
      03-20 11:42:14.157 17055-17055/com.foxitsample.view W/dalvikvm﹕ Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing LFoxitEMBSDK/EMBJavaSupport;
      03-20 11:42:14.157 17055-17055/com.foxitsample.view D/AndroidRuntime﹕ Shutting down VM
      ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

      Finally, I'm not sure that the file Android.mk in demo_view/jni/ is configured correctly:

      LOCAL_PATH := $(call my-dir)
      include $(CLEAR_VARS)
      LOCAL_MODULE := fpdfembedsdk
      LOCAL_SRC_FILES := ../../jni/FoxitEMBSDK_EMBJavaSupport.cpp
      LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../include
      LOCAL_LDLIBS := -llog -g -L. -ljnigraphics

      #fill in the foxit library here
      LOCAL_LDLIBS += ../bin/libfpdfemb_android.a

      include $(BUILD_SHARED_LIBRARY)


      Thanks and Regards,

      --
      Z4195

      Comment


      • #4
        Hello Z4195,

        Please copy and paste the following to your Application.mk file found in examples\demos\demo_<demo name>\jni:

        # Build both ARMv5TE and ARMv7-A machine code.
        APP_PLATFORM :=android-8
        APP_MODULES := fpdfembedsdk
        APP_ABI := armeabi
        #APP_ABI := x86
        #APP_ABI := armeabi-v7a
        APP_STL := stlport_shared
        #APP_STL := stlport_static
        STLPORT_FORCE_REBUILD := true

        Also in EMBJavaSupport.java file, (found in examples\demos\demo_<demo name>\src\FoxitEMBSDK\EMBJavaSupport.java example directory) make sure you have these lines:

        static{
        System.loadLibrary("fpdfembedsdk");
        System.loadLibrary("stlport_shared");
        }

        Please let me know if you are still having problems after changing those things and rebuilding the NDK layerr.

        Thank you,
        Huy Tran

        Comment


        • #5
          Hello huy_tran,

          After making your indications, ndk-build -B is a success.
          However when I run with eclipse, the demo_view app crash yet.

          I can join you again log errors:


          04-22 11:55:21.304: D/dalvikvm(7042): Trying to load lib /data/data/com.foxitsample.view/lib/libfpdfembedsdk.so 0x41490a70
          04-22 11:55:21.304: W/dalvikvm(7042): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing LFoxitEMBSDK/EMBJavaSupport;
          04-22 11:55:21.304: D/AndroidRuntime(7042): Shutting down VM
          04-22 11:55:21.304: W/dalvikvm(7042): threadid=1: thread exiting with uncaught exception (group=0x40ce32a0)
          04-22 11:55:21.312: E/AndroidRuntime(7042): FATAL EXCEPTION: main
          04-22 11:55:21.312: E/AndroidRuntime(7042): java.lang.ExceptionInInitializerError
          04-22 11:55:21.312: E/AndroidRuntime(7042): at com.foxitsample.service.WrapPDFFunc.InitFoxitFixed Memory(WrapPDFFunc.java:25)
          04-22 11:55:21.312: E/AndroidRuntime(7042): at com.foxitsample.view.mainActivity.onCreate(mainAct ivity.java:37)
          04-22 11:55:21.312: E/AndroidRuntime(7042): at android.app.Activity.performCreate(Activity.java:5 163)
          04-22 11:55:21.312: E/AndroidRuntime(7042): at android.app.Instrumentation.callActivityOnCreate(I nstrumentation.java:1094)
          04-22 11:55:21.312: E/AndroidRuntime(7042): at android.app.ActivityThread.performLaunchActivity(A ctivityThread.java:2061)
          04-22 11:55:21.312: E/AndroidRuntime(7042): at android.app.ActivityThread.handleLaunchActivity(Ac tivityThread.java:2122)
          04-22 11:55:21.312: E/AndroidRuntime(7042): at android.app.ActivityThread.access$600(ActivityThre ad.java:140)
          04-22 11:55:21.312: E/AndroidRuntime(7042): at android.app.ActivityThread$H.handleMessage(Activit yThread.java:1228)
          04-22 11:55:21.312: E/AndroidRuntime(7042): at android.os.Handler.dispatchMessage(Handler.java:99 )
          04-22 11:55:21.312: E/AndroidRuntime(7042): at android.os.Looper.loop(Looper.java:137)
          04-22 11:55:21.312: E/AndroidRuntime(7042): at android.app.ActivityThread.main(ActivityThread.jav a:4895)
          04-22 11:55:21.312: E/AndroidRuntime(7042): at java.lang.reflect.Method.invokeNative(Native Method)
          04-22 11:55:21.312: E/AndroidRuntime(7042): at java.lang.reflect.Method.invoke(Method.java:511)
          04-22 11:55:21.312: E/AndroidRuntime(7042): at com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:994)
          04-22 11:55:21.312: E/AndroidRuntime(7042): at com.android.internal.os.ZygoteInit.main(ZygoteInit .java:761)
          04-22 11:55:21.312: E/AndroidRuntime(7042): at dalvik.system.NativeStart.main(Native Method)
          04-22 11:55:21.312: E/AndroidRuntime(7042): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1892]: 111 could not load needed library 'libstlport_shared.so' for 'libfpdfembedsdk.so' (load_library[1094]: Library 'libstlport_shared.so' not found)
          04-22 11:55:21.312: E/AndroidRuntime(7042): at java.lang.Runtime.loadLibrary(Runtime.java:370)
          04-22 11:55:21.312: E/AndroidRuntime(7042): at java.lang.System.loadLibrary(System.java:535)
          04-22 11:55:21.312: E/AndroidRuntime(7042): at FoxitEMBSDK.EMBJavaSupport.<clinit>(EMBJavaSupport .java:15)
          04-22 11:55:21.312: E/AndroidRuntime(7042): ... 16 more

          Thank you,

          Z4195

          Comment


          • #6
            I also had same issue in #3 and it got fixed using #4.

            But I am getting below formatexception while loading the doc.

            Filename given in the code is privatestaticfinal String fileName = "/mnt/sdcard/oxit.pdf";

            And that file exists(attachment)




            04-23 20:21:38.645: I/EMBSDKJavaSupport(9948): sn = SDKEDTEMP,code = 3DD7025D791307453AF74AB963B73BB5B1F252C5
            04-23 20:21:38.872: D/EMBSDKJavaSupport(9948): FPDFEMB TRACE: FS_LoadJbig2Decoder called
            04-23 20:21:38.872: D/EMBSDKJavaSupport(9948): FPDFEMB BENCHMARK: FS_LoadJbig2Decoder, 0 ticks
            04-23 20:21:38.872: D/EMBSDKJavaSupport(9948): FPDFEMB TRACE: Loading JPEG2000 decoder called
            04-23 20:21:38.872: D/EMBSDKJavaSupport(9948): FPDFEMB BENCHMARK: Loading JPEG2000 decoder, 0 ticks
            04-23 20:21:38.872: D/EMBSDKJavaSupport(9948): FPDFEMB TRACE: FS_FontCMap_LoadGB called
            04-23 20:21:38.872: D/EMBSDKJavaSupport(9948): FPDFEMB BENCHMARK: FS_FontCMap_LoadGB, 0 ticks
            04-23 20:21:38.872: D/EMBSDKJavaSupport(9948): FPDFEMB TRACE: FS_FontCMap_LoadGBExt called
            04-23 20:21:38.872: D/EMBSDKJavaSupport(9948): FPDFEMB BENCHMARK: FS_FontCMap_LoadGBExt, 0 ticks
            04-23 20:21:38.872: D/EMBSDKJavaSupport(9948): FPDFEMB TRACE: FS_FontCMap_LoadCNS called
            04-23 20:21:38.872: D/EMBSDKJavaSupport(9948): FPDFEMB BENCHMARK: FS_FontCMap_LoadCNS, 0 ticks
            04-23 20:21:38.872: D/EMBSDKJavaSupport(9948): FPDFEMB TRACE: FS_FontCMap_LoadKorea called
            04-23 20:21:38.872: D/EMBSDKJavaSupport(9948): FPDFEMB BENCHMARK: FS_FontCMap_LoadKorea, 0 ticks
            04-23 20:21:38.872: D/EMBSDKJavaSupport(9948): FPDFEMB TRACE: FS_FontCMap_LoadJapan called
            04-23 20:21:38.872: D/EMBSDKJavaSupport(9948): FPDFEMB BENCHMARK: FS_FontCMap_LoadJapan, 0 ticks
            04-23 20:21:38.872: D/EMBSDKJavaSupport(9948): FPDFEMB TRACE: FS_FontCMap_LoadJapanExt called
            04-23 20:21:38.872: D/EMBSDKJavaSupport(9948): FPDFEMB BENCHMARK: FS_FontCMap_LoadJapanExt, 0 ticks
            04-23 20:21:39.216: D/dalvikvm(9948): threadid=1: still suspended after undo (sc=1 dc=1)
            04-23 20:21:48.583: D/EMBSDKJavaSupport(9948): FPDFEMB TRACE: FS_Memory_Alloc called
            04-23 20:21:48.583: D/EMBSDKJavaSupport(9948): FPDFEMB BENCHMARK: FS_Memory_Alloc, 0 ticks
            04-23 20:22:45.309: D/EMBSDKJavaSupport(9948): FPDFEMB TRACE: FPDF_Doc_Load called
            04-23 20:22:45.309: D/EMBSDKJavaSupport(9948): FPDF_Doc_Load: ready
            04-23 20:22:45.309: D/EMBSDKJavaSupport(9948): FPDF_Doc_Load: pFileAccess = 5EE26580
            04-23 20:22:45.309: D/EMBSDKJavaSupport(9948): FPDF_Doc_Load: pParser = 5EF07E68
            04-23 20:22:45.309: D/EMBSDKJavaSupport(9948): FPDF_Doc_Load: err = 2
            04-23 20:22:45.309: D/EMBSDKJavaSupport(9948): FPDFEMB BENCHMARK: FPDF_Doc_Load, 0 ticks
            04-23 20:22:45.309: I/EMBSDKJavaSupport(9948): DocLoad = 4
            04-23 20:23:01.481: W/System.err(9948): com.foxitsample.exception.formatException: FPDFDocLoad: Doc did not load properly
            04-23 20:23:01.489: W/System.err(9948): at FoxitEMBSDK.EMBJavaSupport.FPDFDocLoad(Native Method)
            04-23 20:23:01.489: W/System.err(9948): at com.foxitsample.service.WrapPDFFunc.InitPDFDoc(Wra pPDFFunc.java:97)
            04-23 20:23:01.497: W/System.err(9948): at com.foxitsample.annotations.mainActivity.onCreate( mainActivity.java:58)
            04-23 20:23:01.497: W/System.err(9948): at android.app.Activity.performCreate(Activity.java:5 133)
            04-23 20:23:01.497: W/System.err(9948): at android.app.Instrumentation.callActivityOnCreate(I nstrumentation.java:1087)
            04-23 20:23:01.505: W/System.err(9948): at android.app.ActivityThread.performLaunchActivity(A ctivityThread.java:2175)
            04-23 20:23:01.505: W/System.err(9948): at android.app.ActivityThread.handleLaunchActivity(Ac tivityThread.java:2261)
            04-23 20:23:01.505: W/System.err(9948): at android.app.ActivityThread.access$600(ActivityThre ad.java:141)
            04-23 20:23:01.505: W/System.err(9948): at android.app.ActivityThread$H.handleMessage(Activit yThread.java:1256)
            04-23 20:23:01.505: W/System.err(9948): at android.os.Handler.dispatchMessage(Handler.java:99 )
            04-23 20:23:01.513: W/System.err(9948): at android.os.Looper.loop(Looper.java:137)
            04-23 20:23:01.513: W/System.err(9948): at android.app.ActivityThread.main(ActivityThread.jav a:5103)
            04-23 20:23:01.513: W/System.err(9948): at java.lang.reflect.Method.invokeNative(Native Method)
            04-23 20:23:01.513: W/System.err(9948): at java.lang.reflect.Method.invoke(Method.java:525)
            04-23 20:23:01.513: W/System.err(9948): at com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:737)
            04-23 20:23:01.520: W/System.err(9948): at com.android.internal.os.ZygoteInit.main(ZygoteInit .java:553)
            04-23 20:23:01.520: W/System.err(9948): at dalvik.system.NativeStart.main(Native Method)

            Comment


            • #7
              Hi christomaliyekkal,

              I'm still without solution.
              Have you managed to find a solution to the problem ?

              Thank you,

              Z4195

              Comment


              • #8
                Dear Z4195 and christomaliyekkal,

                Here is a link to the Android demo that has already been built with NDK and unlock. User just need to Uploaded the files from FoxitEmbeddedSDKforAndroid2.1.23354.1092.101412.17 12_enu\examples\test_files to the device /mnt/sdcard/ directory and also the readme.pdf from FoxitEmbeddedSDKforAndroid2.1.23354.1092.101412.17 12_enu\examples\ to the device /mnt/sdcard/.

                The project should just build and run if you have your Android development environment correctly setup.



                Note: The built project license will expire on 09/08/2014.

                Sincerely,
                Huy

                Comment


                • #9
                  Hi Huy,

                  Your link is not available.

                  --
                  Z4195

                  Comment


                  • #10
                    I am also having the "multiple definition" error mentioned in the 3rd post. The fix supplied in the 4th post did not work for me and the prebuilt sample is not available for download.

                    Would love some help over here

                    Comment


                    • #11
                      Hi Z4195,

                      Sorry for the delay the link I posted earlier had a minor typo in the address, try this link http://sync-us.foxitsoftware.com/se/..._enu_built.zip. Let me know if you are still having trouble with the link and I'll try to fix it.

                      Thank you,
                      Huy Tran

                      Comment


                      • #12
                        Hi Ridge,

                        Please post your code and I will try and come up with a solution for you.

                        Thank you,
                        Huy Tran

                        Comment


                        • #13
                          Hi huy_tran,

                          Thank you for your help, the sources build is a success.

                          --
                          Z4195
                          Last edited by Z4195; 06-05-2014, 01:24 PM.

                          Comment


                          • #14
                            Hello all! I'm trying trying to compile the same demo_view project and I'm running into the same build issue mentioned in the 3rd post. For reference, I've added the lines huy_tran suggested for both the Android.mk and EMBJavaSupport.java but still no luck. I just downloaded the embedded sdk today so I ought to be the newest version (2.1.23354.1092.101412.1712_enu)

                            Any help would be greatly appreciated!

                            Comment


                            • #15
                              Hello everyone! I'm trying to build the same demo_view project with no luck. The NDK refuses to build the library and is giving me the same error found in the 3rd post. I've already implemented the changes suggested by huy_tran for modifying the Android.mk and .java with no luck. For the record, I just downloaded the embedded sdk today, so I should be on the most recent version (2.1.23354.1092.101412.1712_enu)

                              Any help is greatly appreciated!

                              Comment

                              Working...
                              X