2014-02-25 30 views
0

我在這個環節運行時錯誤研製工作燈6.1

https://www.ibm.com/developerworks/community/blogs/WASFAQs/entry/using_a_barcode_scanner_with_worklight?lang=en

,通過它我可以使用工作燈6.1開發條形碼掃描儀下面的教程。但是,隨着一步教程步驟之後,我得到在logcat中下面的錯誤..

**02-25 04:33:05.013: D/AndroidRuntime(811): Shutting down VM 
02-25 04:33:05.013: W/dalvikvm(811): threadid=1: thread exiting with uncaught exception (group=0x414c4700) 
02-25 04:33:05.023: E/AndroidRuntime(811): FATAL EXCEPTION: main 
02-25 04:33:05.023: E/AndroidRuntime(811): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.BarcodeScannerSampleApp/com.BarcodeScannerSampleApp.BarcodeScannerSampleApp}: java.lang.ClassNotFoundException: Didn't find class "com.BarcodeScannerSampleApp.BarcodeScannerSampleApp" on path: DexPathList[[zip file "/data/app/com.BarcodeScannerSampleApp-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.BarcodeScannerSampleApp-2, /system/lib]] 
02-25 04:33:05.023: E/AndroidRuntime(811): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137) 
02-25 04:33:05.023: E/AndroidRuntime(811): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261) 
02-25 04:33:05.023: E/AndroidRuntime(811): at android.app.ActivityThread.access$600(ActivityThread.java:141) 
02-25 04:33:05.023: E/AndroidRuntime(811): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) 
02-25 04:33:05.023: E/AndroidRuntime(811): at android.os.Handler.dispatchMessage(Handler.java:99) 
02-25 04:33:05.023: E/AndroidRuntime(811): at android.os.Looper.loop(Looper.java:137) 
02-25 04:33:05.023: E/AndroidRuntime(811): at android.app.ActivityThread.main(ActivityThread.java:5103) 
02-25 04:33:05.023: E/AndroidRuntime(811): at java.lang.reflect.Method.invokeNative(Native Method) 
02-25 04:33:05.023: E/AndroidRuntime(811): at java.lang.reflect.Method.invoke(Method.java:525) 
02-25 04:33:05.023: E/AndroidRuntime(811): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 
02-25 04:33:05.023: E/AndroidRuntime(811): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
02-25 04:33:05.023: E/AndroidRuntime(811): at dalvik.system.NativeStart.main(Native Method) 
02-25 04:33:05.023: E/AndroidRuntime(811): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.BarcodeScannerSampleApp.BarcodeScannerSampleApp" on path: DexPathList[[zip file "/data/app/com.BarcodeScannerSampleApp-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.BarcodeScannerSampleApp-2, /system/lib]] 
02-25 04:33:05.023: E/AndroidRuntime(811): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53) 
02-25 04:33:05.023: E/AndroidRuntime(811): at java.lang.ClassLoader.loadClass(ClassLoader.java:501) 
02-25 04:33:05.023: E/AndroidRuntime(811): at java.lang.ClassLoader.loadClass(ClassLoader.java:461) 
02-25 04:33:05.023: E/AndroidRuntime(811): at android.app.Instrumentation.newActivity(Instrumentation.java:1061) 
02-25 04:33:05.023: E/AndroidRuntime(811): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128) 
02-25 04:33:05.023: E/AndroidRuntime(811): ... 11 more** 

的AndroidManifest.xml中如下:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.BarcodeScannerSampleApp" android:versionCode="1" android:versionName="1.0"> 
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="14"/> 
<supports-screens android:smallScreens="false" android:normalScreens="true" android:largeScreens="false"/> 
<uses-permission android:name="android.permission.INTERNET"/> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> 
<!-- Push permissions --> 
<permission android:name="com.BarcodeScannerSampleApp.permission.C2D_MESSAGE" android:protectionLevel="signature"/> 
<uses-permission android:name="com.BarcodeScannerSampleApp.permission.C2D_MESSAGE"/> 
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/> 
<uses-permission android:name="android.permission.WAKE_LOCK"/> 
<uses-permission android:name="android.permission.GET_ACCOUNTS"/> 
<uses-permission android:name="android.permission.USE_CREDENTIALS"/> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 


<!-- Adding camera permission here --> 
<uses-permission android:name="android.permission.CAMERA"/> 
<!-- abcdefgh --> 

<application android:label="@string/app_name" android:debuggable="true" android:icon="@drawable/icon"> 
    <activity android:name=".BarcodeScannerSampleApp" android:label="@string/app_name" android:configChanges="orientation|keyboardHidden|screenSize" android:launchMode="singleTask"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN"/> 
      <category android:name="android.intent.category.LAUNCHER"/> 
     </intent-filter> 
     <intent-filter> 
      <action android:name="com.BarcodeScannerSampleApp.BarcodeScannerSampleApp.NOTIFICATION"/> 
      <category android:name="android.intent.category.DEFAULT"/> 
     </intent-filter> 
    </activity> 
    <!-- ADDING CARdova support files here --> 
    <activity android:name="com.google.zxing.client.android.CaptureActivity" android:screenOrientation="landscape" android:configChanges="orientation|keyboardHidden" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateAlwaysHidden"> 
     <intent-filter> 
      <action android:name="com.phonegap.plugins.barcodescanner.SCAN"/> 
       <category android:name="android.intent.category.DEFAULT"/> 
     </intent-filter> 
    </activity> 
    <activity android:name="com.google.zxing.client.android.encode.EncodeActivity" android:label="@string/share_name"> 
     <intent-filter> 
      <action android:name="com.phonegap.plugins.barcodescanner.ENCODE"/> 
      <category android:name="android.intent.category.DEFAULT"/> 
     </intent-filter>    
    </activity> 
    <!-- abcdefgh --> 
    <!-- Preference Activity --> 
    <activity android:name="com.worklight.common.WLPreferences" android:label="Worklight Settings"></activity> 
    <!-- Push service --> 
    <!-- In order to use the c2dm library, an application must declare a class with the name C2DMReceiver, in its own package, extending com.google.android.c2dm.C2DMBaseReceiver 
     It must also include this section in the manifest, replacing "com.google.android.apps.chrometophone" with its package name. --> 
    <service android:name=".GCMIntentService"/> 
    <service android:name=".ForegroundService"/> 
    <!-- Only google service can send data messages for the app. If permission is not set - any other app can generate it --> 
    <receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND"> 
     <!-- Receive the actual message --> 
     <intent-filter> 
      <action android:name="com.google.android.c2dm.intent.RECEIVE"/> 
      <category android:name="com.BarcodeScannerSampleApp"/> 
     </intent-filter> 
     <!-- Receive the registration id --> 
     <intent-filter> 
      <action android:name="com.google.android.c2dm.intent.REGISTRATION"/> 
      <category android:name="com.BarcodeScannerSampleApp"/> 
     </intent-filter> 
    </receiver> 





</application> 

添加以下代碼段config.xml文件

<feature name="BarcodeScanner"> 
    <param name="android-package" value="com.phonegap.plugins.barcodescanner.BarcodeScanner"/> 
</feature> 

index.html文件存在於app/BarcodeScannerSampleApp /普通/

<!DOCTYPE HTML> 
<html> 
     <head> 
      <meta charset="UTF-8"> 
      <title>index</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"> 
      <link rel="shortcut icon" href="images/favicon.png"> 
      <link rel="apple-touch-icon" href="images/apple-touch-icon.png"> 
      <link rel="stylesheet" href="css/main.css"> 
      <script>window.$ = window.jQuery = WLJQ;</script> 
     </head> 
     <body > 

      <!--application UI goes here--> 
      <h1>Barcode scanner</h1> 
      <button type="button" id="scanButton">Scan</button> 

     <script> 
     $('#scanButton').bind('click', doScan); 

     function doScan() 
      { 
       cordova.exec(onScanSuccess, onScanFailure, 'BarcodeScanner', 'scan', []); 
      } 

     function onScanSuccess(result) 
     { 
      alert("We got a barcode\n" + 
       "Result: " + result.text + "\n" + 
       "Format: " + result.format + "\n" + 
       "Cancelled: " + result.cancelled); 
     } 

     function onScanFailure(error) 
     { 
      alert("Scanning failed: " + error); 
     } 
     </script> 
     </body> 
</html> 
+1

怎麼樣config.xml? JS?你在哪裏放置Java文件? –

+0

js在index.html文件中內聯添加,java文件位於project/android/native/src/com/BarcodeScannerSampleApp,project/android/native/src/com/google,project/android/native/src/com/phonegap – user3352510

+0

您可以提供Worklight項目嗎?從Eclipse中導出並上傳到Dropbox或類似的。 –

回答

0

這似乎很奇怪,因爲它是爲工作燈應用程序的默認Java類就是沒有找到,沒有條形碼掃描儀本身。 Android目標環境的簡單應用程序是否正確啓動?

你在這裏沒有提到的另一件事是設置條碼掃描器庫項目。這與添加到Worklight項目中的Java不同。你也設置了嗎? (雖然你會得到一個不同的類沒有找到)我實際上有一個問題,我的Worklight項目沒有拿起圖書館。我想我遇到了一個ADT工具的問題,我無法正確設置庫引用(它一直在忘記設置)。我在一個新的Eclipse工作區中重新創建了這些項目,並且突然間庫正確解析了。