2014-12-03 65 views
0

在我的Codenameone項目中,我調用沒有源代碼的本機libraty(andlib)。它在調試版本中運行良好,但在使用發佈選項構建時會中斷。應用程序啓動,但在調用本機代碼時會中斷。Codenameone Android調試工程發佈失敗 - 原生

即使使用「android.enableProguard = false」構建提示,它也會失敗。

我的Java代碼(它打破上的最後一行代碼):

final android.app.Activity ctx = com.codename1.impl.android.AndroidNativeUtil.getActivity(); 
Intent intent = new Intent(ctx, Pdf417ScanActivity.class); 

Pdf417MobiSettings sett = new Pdf417MobiSettings(); 
sett.setPdf417Enabled(true); 
sett.setNullQuietZoneAllowed(true); 
sett.setDecodeUSDriverLicenseData(true); 
sett.setQrCodeEnabled(true); 
sett.setDontShowDialog(true); 
sett.setRemoveOverlayEnabled(true); 
intent.putExtra(Pdf417ScanActivity.EXTRAS_SETTINGS, sett); 

System.out.println("----- before startActivityForResult"); 

com.codename1.impl.android.AndroidNativeUtil.startActivityForResult(intent, new IntentResultListener() { 

這是錯誤日誌從logcat的:

12-04 09:50:21.417: E/dalvikvm(31608): Class lookup Ljava/lang/NoClassDefFoundError; attempted while exception Ljava/lang/ExceptionInInitializerError; pending 
12-04 09:50:21.437: E/dalvikvm(31608): VM aborting 
12-04 09:50:28.324: E/dalvikvm(31677): Could not find class 'com.codename1.impl.android.AndroidTextureView', referenced from method com.codename1.impl.android.AndroidImplementation.initSurface 
12-04 09:50:28.534: E/libEGL(31677): eglCreateWindowSurface format=4 
12-04 09:50:32.307: E/TvOut-Observer(182): SetOrientation 
12-04 09:50:32.708: E/AutoRotationSettingButton(263): hr 
12-04 09:50:34.309: E/FastDormancy(275): before ======= ENTER DORMANCY ======= 

說明使用ProGuard本機庫是:

If you are using ProGuard, add the following lines to your application proguard-project.txt file 

-keep class net.photopay.** { *; } 

-keepclassmembers class net.photopay.** { 
    *; 
} 

-keep class mobi.pdf417.** { *; } 

-keepclassmembers class mobi.pdf417.** { 
    *; 
} 

-dontwarn android.hardware.** 

-dontwarn android.support.v4.** 

如果我設置了「android.enableProguard = f」,這些ProGuard指令是否應該重要別的「?


我們已經創建了一個簡單的測試項目與庫QRScanner.cn1lib(鏈接是從代號網站)。 QRScanner.cn1lib包含在我們的項目「lib」文件夾中,我們也有類似的問題。它在調試模式(掃描qr代碼)下工作正常,並且在發佈版本中失敗(無法掃描和崩潰)。構建命中「android.enableProguard」設置爲「false」。下面是錯誤日誌:

12-05 09:22:29.896: E/dalvikvm(13180): Could not find class 'com.codename1.impl.android.AndroidTextureView', referenced from method com.codename1.impl.android.AndroidImplementation.initSurface 
12-05 09:22:31.508: E/TvOut-Observer(182): SetOrientation 
12-05 09:22:31.668: E/AutoRotationSettingButton(263): hr 
12-05 09:22:32.559: E/QualcommCameraHardware(122): Failed to get maximum zoom value...setting max zoom to zero 
12-05 09:22:32.569: E/QualcommCameraHardware(122): native_set_ext_config E (cmd 46, param1 0 param2 0) 
12-05 09:22:32.569: E/QualcommCameraHardware(122): native_set_ext_config E (cmd 5, param1 0 param2 0) 
12-05 09:22:32.569: E/QualcommCameraHardware(122): native_set_ext_config E (cmd 11, param1 0 param2 0) 
12-05 09:22:32.569: E/QualcommCameraHardware(122): native_set_ext_config E (cmd 9, param1 5 param2 0) 
12-05 09:22:32.569: E/QualcommCameraHardware(122): native_set_ext_config E (cmd 12, param1 31 param2 0) 
12-05 09:22:32.569: E/QualcommCameraHardware(122): native_set_ext_config E (cmd 13, param1 0 param2 0) 
12-05 09:22:32.569: E/QualcommCameraHardware(122): native_set_ext_config E (cmd 13, param1 31 param2 0) 
12-05 09:22:32.579: E/QualcommCameraHardware(122): native_set_ext_config E (cmd 3, param1 0 param2 0) 
12-05 09:22:32.579: E/QualcommCameraHardware(122): #########################################SCENE_MODE : 0 
12-05 09:22:32.579: E/QualcommCameraHardware(122): native_set_ext_config E (cmd 7, param1 0 param2 0) 
12-05 09:22:32.579: E/QualcommCameraHardware(122): native_set_ext_config E (cmd 21, param1 0 param2 0) 
12-05 09:22:32.579: E/QualcommCameraHardware(122): native_set_ext_config E (cmd 8, param1 1 param2 0) 
12-05 09:22:32.579: E/QualcommCameraHardware(122): native_set_ext_config E (cmd 6, param1 5 param2 0) 
12-05 09:22:32.589: E/QualcommCameraHardware(122): native_set_ext_config E (cmd 4, param1 10 param2 0) 
12-05 09:22:32.589: E/QualcommCameraHardware(122): native_set_ext_config E (cmd 20, param1 0 param2 0) 
12-05 09:22:32.589: E/QualcommCameraHardware(122): native_set_ext_config E (cmd 14, param1 4 param2 0) 
12-05 09:22:32.589: E/QualcommCameraHardware(122): native_set_ext_config E (cmd 34, param1 0 param2 0) 
12-05 09:22:32.609: E/ANDROID_DRM_TEST(122): getPlayerType return 4 
12-05 09:22:32.619: E/AudioSink(122): AudioOutput(1180) 
12-05 09:22:32.619: E/ANDROID_DRM_TEST(122): setDataSource end status 0 
12-05 09:22:32.679: E/MediaPlayer(122): message received msg=5, ext1=0, ext2=0 
12-05 09:22:32.679: E/MediaPlayer(122): message received msg=1, ext1=0, ext2=0 
12-05 09:22:32.679: E/ANDROID_DRM_TEST(122): getPlayerType return 4 
12-05 09:22:32.679: E/AudioSink(122): AudioOutput(1181) 
12-05 09:22:32.679: E/ANDROID_DRM_TEST(122): setDataSource end status 0 
12-05 09:22:32.729: E/MediaPlayer(122): message received msg=5, ext1=0, ext2=0 
12-05 09:22:32.729: E/MediaPlayer(122): message received msg=1, ext1=0, ext2=0 
12-05 09:22:32.729: E/OverlayLIB(122): [/dev/graphics/fb0] open - fd: 912 
12-05 09:22:32.739: E/QualcommCameraHardware(122): native_set_ext_config E (cmd 46, param1 0 param2 0) 
12-05 09:22:32.739: E/QualcommCameraHardware(122): native_set_ext_config E (cmd 5, param1 0 param2 0) 
12-05 09:22:32.739: E/QualcommCameraHardware(122): #########################################SCENE_MODE : 0 
12-05 09:22:32.739: E/QualcommCameraHardware(122): native_set_ext_config E (cmd 10, param1 0 param2 0) 
12-05 09:22:32.739: E/QualcommCameraHardware(122): native_set_ext_config E (cmd 34, param1 0 param2 0) 
12-05 09:22:32.759: E/ShotSingle(122): startPreview - mUseOverlay(1) 
12-05 09:22:32.759: E/QualcommCameraHardware(122): native_set_ext_config E (cmd 23, param1 1 param2 0) 
12-05 09:22:32.759: E/CAM_FD(122): [HCHYUN]ce147_video_config, sfd = 907 
12-05 09:22:33.560: E/OverlayLIB(122): [/dev/graphics/fb0] open - fd: 912 
12-05 09:22:33.570: E/QualcommCameraHardware(122): Start AF 
12-05 09:22:33.570: E/QualcommCameraHardware(122): native_set_ext_config E (cmd 15, param1 0 param2 0) 
12-05 09:22:33.690: E/AndroidRuntime(13180): FATAL EXCEPTION: main 
12-05 09:22:33.690: E/AndroidRuntime(13180): java.lang.ExceptionInInitializerError 
12-05 09:22:33.690: E/AndroidRuntime(13180):  at com.dm.zbar.android.scanner.ZBarScannerActivity.onPreviewFrame(ZBarScannerActivity.java:127) 
12-05 09:22:33.690: E/AndroidRuntime(13180):  at android.hardware.Camera$EventHandler.handleMessage(Camera.java:590) 
12-05 09:22:33.690: E/AndroidRuntime(13180):  at android.os.Handler.dispatchMessage(Handler.java:99) 
12-05 09:22:33.690: E/AndroidRuntime(13180):  at android.os.Looper.loop(Looper.java:130) 
12-05 09:22:33.690: E/AndroidRuntime(13180):  at android.app.ActivityThread.main(ActivityThread.java:3687) 
12-05 09:22:33.690: E/AndroidRuntime(13180):  at java.lang.reflect.Method.invokeNative(Native Method) 
12-05 09:22:33.690: E/AndroidRuntime(13180):  at java.lang.reflect.Method.invoke(Method.java:507) 
12-05 09:22:33.690: E/AndroidRuntime(13180):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 
12-05 09:22:33.690: E/AndroidRuntime(13180):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) 
12-05 09:22:33.690: E/AndroidRuntime(13180):  at dalvik.system.NativeStart.main(Native Method) 
12-05 09:22:33.690: E/AndroidRuntime(13180): Caused by: java.lang.NoSuchFieldError: data 
12-05 09:22:33.690: E/AndroidRuntime(13180):  at net.sourceforge.zbar.Image.init(Native Method) 
12-05 09:22:33.690: E/AndroidRuntime(13180):  at net.sourceforge.zbar.Image.<clinit>(Unknown Source) 
12-05 09:22:33.690: E/AndroidRuntime(13180):  ... 10 more 
12-05 09:22:33.700: E/(182): Dumpstate > /data/log/dumpstate_app_error 

這是java代碼:

protected void onMain_ButtonScanAction(final Component c, ActionEvent event) { 
     Form f = c.getComponentForm(); 
     final TextArea tra = findTextAreaResult(f); 
     tra.setText("Wait for result ..."); 
     System.out.println("---- before QRScanner.scanQRCode"); 
     QRScanner.scanQRCode(new ScanResult() { 
        public void scanCompleted(String contents, String formatName, byte[] rawBytes) { 
         System.out.println("---- scanCompleted"); 
         System.out.println("---- contents=" + contents); 
         tra.setText(contents); 
        } 

        public void scanCanceled() { 
         System.out.println("---- scanCompleted"); 
         Dialog.show("QR Code", "scan Canceled", "OK", null); 
        } 

        public void scanError(int errorCode, String message) { 
         System.out.println("---- scanCompleted"); 
         Dialog.show("QR Code", "scan Error", "OK", null); 
        } 
       }); 
     } 
} 

這些鍵(從屬性文件)的要求QRScanner.cn1lib:

codename1.arg.android.xapplication=<activity android\:name\="com.dm.zbar.android.scanner.ZBarScannerActivity" android\:screenOrientation\="landscape" android\:label\="@string/app_name" /> 
codename1.arg.android.xpermissions=<uses-permission android\:name\="android.permission.CAMERA"/><uses-feature android\:name\="android.hardware.camera" android\:required\="false"/> 
codename1.arg.android.proguard.Keep=-keep class net.sourceforge.zbar.** {*;} 

沒有人有任何線索?謝謝!

+0

您確定您正確設置了android.enableProguard = false,並且沒有在屬性中包含空格或其他元素。你不只是把它輸入到屬性文件或類似的東西?對?它以什麼方式失敗?你有DDMS的崩潰日誌還是要繼續下去? – 2014-12-04 07:25:22

+0

我已經在NetBeans中輸入了android.enableProguard提示,並且沒有空格。在屬性文件中,它看起來像這樣:「codename1.arg.android.enableProguard = false」。我用崩潰日誌和我的java代碼更新了我的問題。 – 2014-12-04 09:15:30

+0

你現在可以試試看看它是否有效?查看日誌可能會遇到與支持Lollipop操作欄失敗嘗試相關的單獨問題。 – 2014-12-04 18:09:45

回答

0

似乎enableProguard在Android SDK的最近更新中爆發了,我們正在嘗試修復它,但同時我建議使用更具體的proguard條件。

+0

設置」android.enableProguard = false「時,它現在可以工作了,我沒有嘗試過其他特定的proguard條件謝謝你的努力和快速回復。 – 2014-12-06 11:47:57