Zxing library cannot be resolved

十年热恋 提交于 2019-12-07 16:06:48

问题


I am developing app with zxing library. I imported the zxing project into my work place. When i importing there were some problems i faced.

  1. Compile the project by java 1.7. I done it.
  2. CameraConfigurationUtils was missing. I copied from the library source.
  3. Resource id's cannot be used to check in the switch case. I changed it to if else.

But finally there is a broblem in the 1. emailResult.getTos() was not resolved in EmailAddressResultHandler 2. Then i built the project there comes the problem R.java cannot be resolved throughout my application.

What i am doing wrong?


回答1:


I think you used the 3.10 or older pre-built jar, but your ZXing project is from GitHub which should use 3.1.1-snapshot.jar build with maven. The APIs had been modified last month according https://github.com/zxing/zxing/commit/8158984458f6db59b462ef2b4dd270321c66f203

I just build the core-3.1.1-SNAPSHOT and test it, it works. You can get it and replace your core.jar and try it :). I put them on my GitHub. https://github.com/voyagewu/ZXing_library/tree/master/core-3.1.1-SNAPSHOT




回答2:


Lots wrong here.

CameraConfigurationUtils is not missing: https://github.com/zxing/zxing/blob/master/android-core/src/main/java/com/google/zxing/client/android/camera/CameraConfigurationUtils.java

EmailAddressResultHandler has those methods: https://github.com/zxing/zxing/blob/master/android/src/com/google/zxing/client/android/result/EmailAddressResultHandler.java I suspect you are adding several versions of the library to your project somehow.

You are trying to use android/ as a library project if you see that error about switch. It is not a library, and is not supposed to be used that way.

R.java is generated by your build. You haven't set up your Android project correctly.

I suggest that if you're struggling with using Maven and Android projects, that you should not be copying project code into your project. I think you are headed towards using the project in a way inconsistent with the license: https://github.com/zxing/zxing/wiki/License-Questions It would be far easier for you to start by integrating by Intent: https://github.com/zxing/zxing/wiki/Scanning-Via-Intent




回答3:


Update the pre-built jar library: download recent snapshot/nightly builds from https://oss.sonatype.org/content/repositories/snapshots/com/google/zxing/core/




回答4:


Simply copy CameraConfigurationUtils from: https://github.com/zxing/zxing/blob/master/android-core/src/main/java/com/google/zxing/client/android/camera/CameraConfigurationUtils.java

and paste file into android project's com.google.zxing.client.android.camera package..

error gone for me.



来源:https://stackoverflow.com/questions/25197401/zxing-library-cannot-be-resolved

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