PhoneGap BarcodeScanner - ClassNotFound

我的未来我决定 提交于 2019-12-10 15:11:54

问题


UPDATE 2

I posted an answer that fixes my original problem. See that for more information.

UPDATE FYI for anyone wondering, in the end I found this: http://github.com/commonsguy/zxingdemo/tree/master Exactly what I needed to get it rolling was a simple demo that worked! Also, thanks to Sean for pointing me in the right direction for my googling.


I am currently trying to build a simple android app that can scan in a barcode. I have looked through multiple tutorials, tried everything to a T, and re-tried and re-tried. Nothing worked. So now I am going to ask for assistance to see where I went wrong.

To list the tutorials I have followed:

  • https://github.com/phonegap/phonegap-plugins/tree/master/Android/BarcodeScanner Tried this one first.
  • http://www.mobiledevelopersolutions.com/home/start/twominutetutorials/tmt3
  • http://simonmacdonald.blogspot.com/2011/12/installing-barcode-plugin-for-phonegap.html

Plus a couple others, but more or less hit the point to the same process. Some key points, when I add the LibraryProject to my project as a Library, the app will not compile until I create an AndroidManifest.xml I tried using the one found in the LibraryProject and tried creating a bare mininmal one, both would allow to compile, but the app ForceCloses.

When I load up the App and click "Scan" it ForceCloses and in the debug log of LogCat in Eclipse I get:

java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.myapp/com.google.zxing.client.android.CaptureActivity}: java.lang.ClassNotFoundException:
com.google.com.zxing.client.android.CaptureActivity in loader dalvik.system.PathClassLoader[/data/app/com.myapp-1.apk]

I have tried googling, found a few issues, but no real clear or solid answers, most just point to the tutorials above. I am not sure if the tutorials are just outdated or I am being stupid and am missing something key. Been working on this for a few days now and am at my wits end.

If you can help I would appreciate it. To avoid answers regarding if I have done X or X, here is what I have done.

When I test the application, I do briefly see it trying to load BarcodeScanner, but right after I see that it ForceCloses. I am not sure what I am missing, but for references I will post the code I currently have setup to test:

AndroidManifest.xml - http://pastebin.com/qq9q0ZU7

Plugins.xml - http://pastebin.com/dZ5eKPSU

index.html - http://pastebin.com/wvht4ken

If I need to post any other items let me know.


回答1:


On Android, it is much much simpler than all this you're trying to do. Throw this out and restart from http://code.google.com/p/zxing/wiki/ScanningViaIntent




回答2:


Ok, so for anyone having this problem, you have two choices. You can use the ScanningViaIntent, as Sean pointed out. It works great, if you need an example look at CommonsGuy. As for the tutorials I posted above to get this working with PhoneGap, my whole problem was, after I imported the LibraryProject I did not go back through and add the files. I am not sure if a setting in my Eclipse is bad. But I basically just right clicked on the LibraryProject, went to Import -> File Structure -> Library Project's original project path, and loaded all of it back in there.

There is probably something wrong with my Eclipse setup, but yea. I now have the BarcodeScanner plugin for PhoneGap working!



来源:https://stackoverflow.com/questions/9523278/phonegap-barcodescanner-classnotfound

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!