问题
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.
- Compile the project by
java 1.7
. I done it. CameraConfigurationUtils
was missing. I copied from thelibrary source
.Resource id's
cannot be used to check in theswitch case
. I changed it toif 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