Having your own mobile software toolbox is a very meaningful thing. In the current domestic Android ecological environment, chaos can no longer mess. Because we can not login to the official Website App Store, the software will have to be in the domestic variety of software market download. Because these markets are poorly regulated, what kind of software have, take QR code scanning software, a lot of the same kind of dogskin plaster advertising plugin, it is really annoying.
There are a lot of good software in the open source world, zxing is a very good Android code tool software. We can use that as well. We can also learn the internal mechanism, and then do some customized personalization. You can enjoy it yourself and share it with everyone. That's good.
Zxing in Github:https://github.com/zxing/zxing
zxing-master$ lsandroid android-integration AUTHORS CONTRIBUTING.md core javase pom.xml src zxingorgandroid-core androidtest CHANGES COPYING glass NOTICE README.md zxing.appspot.com
A lot of source code, inside the pom.xml tell us need to use Maven compile. Unfortunately this build tool I use and skilled, everything must be groped.
MAVEN Official website: https://maven.apache.org
The installation under Ubuntu is very simple, download Apache-maven-3.3.1-bin.zip unzip (unzip) to your favorite directory like/OPT/APACHE-MAVEN-3.3.1/. and set the environment variable, ~/.BASHRC the following content:
#Maven export PATH="$PATH:/opt/apache-maven-3.3.1/bin"export MAVEN_OPTS="-Xms256m -Xmx512m"
The premise is that your JAVA7 environment is already well-equipped. Please refer to Android Combat Skill eight: Switch jdk version under Ubuntu
Here is my MVN environment:
$ Mvn-vapache Maven3.3. 1(CAB6659F9874FA96462AFEF40FCF6BC033D58C1C; --Geneva- -T04:Ten: -+ ,:xx) Maven Home:/opt/apache-maven-3.3. 1Javaversion:1.7. 0_71, Vendor:oracle Corporationjava home:/OPT/JDK/JDK1. 7. 0_71/jredefault Locale:en_us,Platformencoding:utf-8OS Name:"Linux",version:"3.13.0-49-generic", Arch:"AMD64", Family:"UNIX"
For the compilation of Zxing, I did not find the relevant documents, so it is my maven new constantly groping, although not particularly formal, but to achieve my purpose is true.
First in the zxing root directory execution mvn compile, the guy, kept download the dependency package, said this first time the compilation needs to download a large number of packages, if I did not do proxy or library changes, then need a long wait.
I ran for almost one hours at night and thought I'd come back and compile. But I was disappointed, although the package is finished, but the compilation has a problem. Execute again, this compile no error, but I searched the directory did not find the jar package. This is a problem, I still have to follow my own pace to work.
Android Directory is an Eclipse project, I converted directly to as project and then compiled found a lot less zxing classes.
The Pom under the Android-core is this:
<artifactId>android-core</artifactId> <version>3.2.1-SNAPSHOT</version> <packaging>jar</packaging>
No other dependencies are compiled directly into jars. I executed the MVN package, and after a long wait the jar pack was compiled.
$ ls android-core/target/android-core-3.2.1-SNAPSHOT.jar
I introduced this jar and found that there was only one class Com.google.zxing.client.android.camera.CameraConfigurationUtils
This is obviously not enough.
The core catalog is the focus, and the same MVN package waits, if it encounters a jar that relies on other directories to compile it.
$ ls core/target/core-3.2.1-SNAPSHOT.jar
Then put it into Android project, compile successfully!
Android 27: Maven compiled open source QR Code scan project zxing