Yet another Android problem: "Could not find class 'com.google.zxing.EncodeHintType' ...."

172 views
Skip to first unread message

Joshua C

unread,
Oct 20, 2014, 10:23:30 AM10/20/14
to zx...@googlegroups.com
Please forgive me if this is a duplicate ... I've tried searching around here and read through several Android/JDK1.7 related posts but none seemed to help resolve my problem.

I'm writing a POC to embed ZXing into an Android app. I created a Worklight Hybrid project which referenced ZXing Core lib (since only encoding is needed), and then created a Cordova plugin to invoke ZXing encoding functions. The logic is very simple. In the Android Project Properties, I set:

Android Target: Android 4.4.2 (API Level 19)
JDK compliance level: 1.6

The app worked perfectly when I compiled the project in and launched from Worklight on Windows XP, but failed on MacBook Pro with LogCat error message like "Could not find class 'com.google.zxing.EncodeHintType' ….” at run time (although build still passed). I was using the same test Android device (LG Nexus 5).

My environment:
OS X v10.9.5
Eclipse Kepler v20130614-0229
Worklight v6.1.0.01
ADT v22.3.0.v20131024
JDK 1.7.0
ZXing lib: core-3.1.0.jar

Something else I’ve tried:

1. Instead of referencing core-3.1.0.jar file directly, I tried to add Java source code files of ZXing Core lib to my project, but Worklight project couldn’t pass build, because ZXing Core uses a lot of JDK 1.7 features while my project’s "JDK compliance level" is 1.6.

2. Tried to change "JDK compliance level” to 1.7 instead of 1.6, but then the Worklight Android project failed build because "Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead."

Any help is very appreciated!

Sean Owen

unread,
Oct 21, 2014, 12:57:34 PM10/21/14
to zx...@googlegroups.com
Android supports Java 7 bytecode, and the project uses Java 7. You should try to change your tools to use Java 7. I don't know if it's possible with whatever framework you're using, but it's perfectly possible with Maven / Android SDK tools.

Joshua C

unread,
Oct 22, 2014, 9:53:56 AM10/22/14
to zx...@googlegroups.com
On Tuesday, October 21, 2014 12:57:34 PM UTC-4, Sean Owen wrote:
> Android supports Java 7 bytecode, and the project uses Java 7. You should try to change your tools to use Java 7. I don't know if it's possible with whatever framework you're using, but it's perfectly possible with Maven / Android SDK tools.

Thanks Sean! The thing is that my POC eventually will be integrated into a large corp app which is being built in Worklight 6.1. Worklight is IBM's framework for hybrid Mobile app development and becomes more and more popular these days. It actually uses ADT for Android projects, and as you can see the ADT version (v22.3.0.v20131024) in my env is not very out of date.

I've been also very suspicious on this "JDK compliance level"=1.6 thing, but it turned out that the app built from Windows XP machine with the same settings worked fine on the same device. That made me think that this project setting might not matter since "Android supports Java 7 BYTECODE". But if so what's wrong with the build from Mac?

I examined the .apk file and did find the core.3.1.0.jar file in it.

This may be more a question to Android. I'll probably post it to some Android dev communities too, but hopefully can get some clue here since it should be common for ZXing to be used on Android and there might be folks here came across the same issue.

Thanks!

Reply all
Reply to author
Forward
0 new messages