Codenameone Android Debug工作版本失败 - 原生

时间:2014-12-03 11:23:41

标签: android codenameone

在我的Codenameone项目中,我在没有源代码的情况下调用本机libraty(andlib)。它在调试版本中运行良好,但在它使用release选项构建时会中断。应用程序启动但在调用本机代码时会中断。

即使" 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 = false"这些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.** {*;}

有没有人有任何线索?谢谢!

1 个答案:

答案 0 :(得分:0)

似乎enableProguard最近更新了Android SDK,我们正在尝试修复它,但与此同时我建议使用更具体的proguard条件。