整理Zxing遇到的问题

整理二维码开源Z性项目时时候

环境 1 :

Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: C:\maven
Java version: 1.8.0_341, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk1.8.0_341\jre 
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Apache Ant(TM) version 1.10.12 compiled on October 13 2021

 源码下载:https://github.com/zxing/zxing

zxing官网说明:https://github.com/zxing/zxing/wiki/Getting-Started-Developing(最好看看)

在windows的命令窗口:

配置Android_HOME,Ant_home,Maven_HOme(全大写),要不执行命令会找不到jar包;

编译Zxing的核心Core包,直接在主目录下mvn install 就完成了。

为了想使用他们扫码程序,编译android模块时候出现下面错误:


[ERRR] Failed to execute goal on project android-core: Could not resolve dependencies for project com.google.zxing:android-core:jar:3.5.0: Could not find artifact com.google.android:android:jar:22 at specified path D:\android20\android-sdk_r24.4.1-windows\android-sdk-windows\platforms\android-22\android.jar -> [Help 1]O
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

 告诉我是没有找到android-22 SDK 的jar包, 我的机器

 没有22版本,难道我还要下载个低版本??

回头想想Maven结构,在主项目下有个默认全局文件pom.xml,每个模块下也有,查了一下,模块下面的文件没有去找sdk的语句。再看全局的pom.xml文件,其中

<profiles>

   <profile>
      <id>android-release</id>
      <build> 
          .......
                <option>-libraryjars</option>
                <option>${android.home}/platforms/android-${android.platform}/android.jar</option>
            .......
      </build>
    </profile>

</profiles>

${android.platform} 是定义的变量,查一查这个变量的值是什么??

就在本文件里查找到了:

<properties>

  .......
    <java.version>1.8</java.version>
    <android.home>${env.ANDROID_HOME}</android.home>
    <proguard.plugin.version>2.5.3</proguard.plugin.version>
    <!-- This can't reference project.version as some subprojects version differently -->
    <zxing.version>3.5.0</zxing.version>
    <!--改为你自己系统上有的android版-->
    <android.platform>28</android.platform>

  </properties>

回到andriod目录下mvn install 就出来了,当然这是没有签名的,签名的命令如下:

mvn -Pandroid-release -Djarsigner.storepass=... -Djarsigner.keypass=... clean package android:apk

上粗体ANDROID_HOME必须在环境里定义,当然你也可以直接写你的绝对路径。

安装部署到手机上:

android/

  1. Build android/
  2. Connect your device via USB
  3. If you already have the standard version of Barcode Scanner installed, uninstall it
  4. Make sure your device is set to allow apps from untrusted sources
  5. Run mvn android:deploy.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值