【问题标题】:The problem with the addition .jar file to project将 .jar 文件添加到项目的问题
【发布时间】:2019-08-16 01:18:13
【问题描述】:

添加了两个自定义 zxing 和 zbar 库,用于通过 File>New 读取和生成条形码更长而不是它的实现和api如何正确添加它们?

build.gradle(应用程序)

apply plugin: 'com.android.application'
check.dependsOn 'assembleDebugAndroidTest'

android {
compileSdkVersion 28
flavorDimensions "minSdkVersion"

defaultConfig {

    minSdkVersion 16
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner 
'android.support.test.runner.AndroidJUnitRunner'
}

buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 
'proguard-rules.pro'
    }
}

compileOptions {
    sourceCompatibility 1.8
    targetCompatibility 1.8
}
}

configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:28.0.0'
}

dependencies {
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:animated-vector-drawable:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
// Firebase Authentication
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-auth:16.2.0'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'com.google.firebase:firebase-database:16.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso- 
   core:3.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
implementation project(':zbar')
implementation project(':zxing_core')
}

apply plugin: 'com.google.gms.google-services'

build.gradle(项目)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
    jcenter()
    mavenLocal()
    google()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.3.2'
    classpath 'com.google.gms:google-services:4.2.0'
}
  }

allprojects {
repositories {
    mavenLocal()
    jcenter()
    google()
    maven { url 'https://maven.fabric.io/public' }
}
  }

  task clean(type: Delete) {
delete rootProject.buildDir
 }

【问题讨论】:

    标签: java android zxing zbar libs


    【解决方案1】:

    我建议使用 https://mvnrepository.com/artifact/com.google.zxing 这里的依赖项,但在你的情况下(只要你添加 jars),你可以通过 implementation fileTree(include: ['*.jar'], dir: 'libs') 在 build.gradle 中插入它们(libs 可以替换为任何他们登陆的文件夹)。

    【讨论】:

    • 我在库中有 2 个 .jar 文件,但是当我使用你给出的行时,我仍然得到同样的错误
    • 您可能必须删除这些implementation project(':zbar') implementation project(':zxing_core') - 您的解决方案中有这些模块吗?如果没有,您应该删除。
    • 然后他们走了
    猜你喜欢
    • 2011-07-06
    • 1970-01-01
    • 2014-08-09
    • 2019-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-02
    • 2012-06-28
    相关资源
    最近更新 更多