Practical Android skills: Maven compilation of open-source QR code scanning projects zxing and mavenzxing

Source: Internet
Author: User

Practical Android skills: Maven compilation of open-source QR code scanning projects zxing and mavenzxing

Having your own mobile phone software toolbox is very meaningful. For the current domestic Android ecosystem, Chaos cannot be disrupted. Because we can't log on to the App store on the official website, we have to download the software from various Chinese software markets. Due to the ineffective supervision of these markets, there are all kinds of software. Taking the QR code scanning software for example, many advertisement plug-ins with the same dog skin plaster are really annoying.
There are many excellent software in the open-source world. zxing is a very good Android scanning tool. We can use it out-of-the-box, learn internal mechanisms, and then customize the features. You can enjoy it on your own and share it with you. Really good.

Zxing At 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

There are a lot of source code. The pom. xml in it tells us that we need to compile with maven. Unfortunately, I am familiar with this build tool and want to explore everything.

Maven Official Website: https://maven.apache.org
The installation in Ubuntu is very simple, download apache-maven-3.3.1-bin.zip unzip (unzip) to your favorite directory such as/opt/apache-maven-3.3.1 /. Set the environment variables ,~ /. Enter the following content under bashrc:

#Maven export PATH="$PATH:/opt/apache-maven-3.3.1/bin"export MAVEN_OPTS="-Xms256m -Xmx512m"

The premise is that your Java 7 environment has been configured. Refer to practical Android skills: Switch JDK under Ubuntu

The following is my mvn environment:

$ mvn -vApache Maven 3.3.1 (cab6659f9874fa96462afef40fcf6bc033d58c1c; 2015-03-14T04:10:27+08:00)Maven home: /opt/apache-maven-3.3.1Java version: 1.7.0_71, vendor: Oracle CorporationJava home: /opt/jdk/jdk1.7.0_71/jreDefault locale: en_US, platform encoding: UTF-8OS name: "linux", version: "3.13.0-49-generic", arch: "amd64", family: "unix"

I have not found any relevant documents for zxing compilation. This is why I am a new maven developer. Although it is not very formal, it is true to achieve my goal.

Execute mvn compile in the root directory of zxing. Good guy, a lot of dependent packages need to be downloaded during the first compilation. If I have not made any changes to the proxy or library, it takes a long wait.

I ran for nearly an hour in the evening and thought I had compiled it back. However, I was disappointed that, although the package was completed, there was a problem with the compilation. Run the command again. No error is returned for this compilation, but the jar package is not found in the directory I searched. This is a problem. I should work at my own pace.

The android directory is an eclipse project. I directly converted it to an AS project and then compiled it to find that a lot of zxing classes are missing.

The pom in android-core is as follows:

  <artifactId>android-core</artifactId>  <version>3.2.1-SNAPSHOT</version>  <packaging>jar</packaging>

Without other dependencies, directly compile it into jar. I executed the mvn package. After a long wait, the jar package was compiled.

$ ls android-core/target/android-core-3.2.1-SNAPSHOT.jar

I introduced this jar and found that there is only one class com. google. zxing. client. android. camera. CameraConfigurationUtils.
This is obviously not enough.
The core directory is the focus, and the mvn package waits again. If you encounter a jar dependent on other directories in the middle, compile it.

$ ls core/target/core-3.2.1-SNAPSHOT.jar

Introduce it to the android project and compile it successfully!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.