Zxing 的集成 ---- Maven 對應 Gradle 的寫法


Zxing 的集成 ---- Maven 對應 Gradle 的寫法

剛剛想耍耍二維碼,想到了zxingzbar,又想到zxingGoogle老爹的,想想就算了吧,雖然zbar快但是識別錯誤率也高不少.隨手Google了下*zxing 集成*好像都是說什么拷貝項目到自己的工程中,我不信Gradle集成這么方便了為何不用.於是我來到zxing的 Github 主頁 https://github.com/zxing/zxing,在README的引導下來到Get Start頁面,里面有如下說明:

Maven

core/, javase/, android-integration and zxingorg can be used directly in a Maven-based project without any download or installation. Instead, add as dependencies from groupID com.google.zxing artifactIDs core, javase, android-integration or zxingorg:

<dependencies>
  ...
  <dependency>
    <groupId>com.google.zxing</groupId>
    <artifactId>core</artifactId>
    <version>(the current version)</version>
  </dependency>
</dependencies>

雖然沒說明 Gradle 如何集成,但是發布過lib到jcenter的應該知道,mavenGradle的關系.

上面maven倉庫信息對應的Gradle為:

compile 'com.google.zxing:core:3.3.0'

compile '<groupId>:<artifactId>:<version>'

記起來也很簡單,就是把上面三個參數用:連接即可.

其中 version對應版本有很多,建議使用最新的,我現在看到最新的Release版本為3.3.0.

所以在 Android studio 的工程 Modulebuild.gradle下添加一行依賴即可:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    //添加 zxing
    compile 'com.google.zxing:core:3.3.0'
}

其他的項目集成以此類推.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM