kenglxn / QRGen

a simple QRCode generation api for java built on top ZXING
http://glxn.net/2012/03/10/qrgen-a-small-wrapper-on-top-of-zxing-for-generating-qrcodes-in-java
1.49k stars 300 forks source link

Generating QR code #22

Closed YeeSuannn closed 10 years ago

YeeSuannn commented 10 years ago

Hi. I imported android-2.0-20140713.143342-8.jar to my project from "https://oss.sonatype.org/content/repositories/snapshots/net/glxn/qrgen/android/2.0-SNAPSHOT/" and then according to your README.md usage, i wrote this code on my activity: File file = QRCode.from("Hello World").file(); // override the image type to be JPG QRCode.from("Hello World").to(ImageType.JPG).file(); QRCode.from("Hello World").file("QRCode");

However, it crashed the application. the logcat stated that "java.lang.NoClassDefFoundError: com.google.zxing.qrcode.QRCodeWriter." May i know how should i solve this?

atomfrede commented 10 years ago

I'll see what's the problem tomorrow. What is the target Android version?

YeeSuannn commented 10 years ago

The target Android version is 19. Min Sdk version is 14.

atomfrede commented 10 years ago

Just to make sure. Are you using maven or gradle as build system? Or did you just added the single jar as dependency to your project in eclipse?

gmarizy commented 10 years ago

I experience same problem.

By the way before using jar I tried in my build.gradle:

repositories {
    maven {
        url "https://oss.sonatype.org/content/repositories/snapshots/"
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile ("net.glxn.qrgen:android:2.0-SNAPSHPOT")
}

But get: Error:Failed to find: net.glxn.qrgen:android:2.0-SNAPSHPOT

Then I tried jars. I added android-2.0-20140713.143342-8.jar and core-2.0-20140713.143320-9.jar in libs with this build.gradle:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

After syncing I get the error mentionned above. From my understanding (I just begin with gradle and maven repo), because I provided myself QRGen I have to provide the dependencies too (zxing).

atomfrede commented 10 years ago

@gmarizy Sorry there was a typo in the readme. It is net.glxn.qrgen:android:2.0-SNAPSHOT and not SNAPSHPOT this may help in your case. I've also setup a small sample application.

@CelestialMilky In case you are trying to setup all dependencies without maven or gradle you need to add at least the core from QRGen and zxing core artifact, otherwise required classes can't be found.

gmarizy commented 10 years ago

Thank you ! The sample is an helpful addition.

YeeSuannn commented 10 years ago

Yes, i setup all the dependencies. i added core and android from QRGen and core from zxing. Then i got this error "java.lang.NoClassDefFoundError: com.google.zxing.qrcode.QRCodeWriter." Im trying to use gradle. quite new to me >.<

kenglxn commented 10 years ago

Is this issue resolved then?

Den 17. aug. 2014 kl. 15:13 skrev gmarizy notifications@github.com:

Thank you ! The sample is an helpful addition.

— Reply to this email directly or view it on GitHub.

YeeSuannn commented 10 years ago

Can i just use the dependencies instead of gradle or maven?

atomfrede commented 10 years ago

It should be possible. Are you using eclipse or android studio? But I would highly recommend to get familiar with gradle as it is (resp. will become) the new standard build system for android applications.

I'll try to figure out what jars you exactly require as dependencies.

YeeSuannn commented 10 years ago

I'm using eclipse. Okayy, i will try to understand on how to use gradle and maven since i have been seeing quite a number of people been mentioning it as well.

Thank you for trying to help me figure out what jars i need :)

atomfrede commented 10 years ago

Just try downlowding android studio and create a new project, it will setup all required gradle files as required for you.

Edit: It should be sufficient to add these jars to your eclipse project:

At least these are the only ones required.

YeeSuannn commented 10 years ago

Will it affect my partner? cos currently both of us are using eclipse. if i started to use android studio and my partner continue to use eclipse, will it affect the compilation in the end?

atomfrede commented 10 years ago

Yes. You must convert your eclipse android project to a gradle project (function provided by the android development tools). But just try adding the three jars mentioned before, it should work.

YeeSuannn commented 10 years ago

Is it possible if i stick with eclipse android and use gradle ?

atomfrede commented 10 years ago

not sure. Eclipse supports gradle via an external plugin very well, but I don't know how it works with the android development tools for eclipse. So I suggest either switch to android studio + gradle or stick with eclipse and eclipse tooling for now.

YeeSuannn commented 10 years ago

I would love to stick with eclipse and eclipse tooling for now.. Sorry for being stubborn. It is still possible to do QRGen without using gradle or maven,right?

atomfrede commented 10 years ago

Yes definitely possible.

YeeSuannn commented 10 years ago

Glad to hear this. thank you! :)

kenglxn commented 10 years ago

Closing this issue, as it is not a bug.

atomfrede commented 10 years ago

Yes not a bug.

@CelestialMilky for your information: I've setup a new android project in eclipse and put all three jars into the libs folder. They are automatically added to the build path and creating the qrcode works as expected.

YeeSuannn commented 10 years ago

Okay. thank you so much !

YeeSuannn commented 10 years ago

I tried it in a new android project but it doesnt work.

atomfrede commented 10 years ago

What version of android development tools are you using? The libraries must be part of the build path (see attached screenshot) bildschirmfoto - 17 08 2014 - 19 44 43

YeeSuannn commented 10 years ago

I solved the problem already. It is working now !! :))