相关疑难解决方法(0)

Gradle中的实现和编译之间有什么区别?

在更新到Android Studio 3.0并创建一个新项目后,我注意到build.gradle有一种新方法可以添加新的依赖项,而不是compile存在implementation而不是testCompile存在testImplementation.

例:

 implementation 'com.android.support:appcompat-v7:25.0.0'
 testImplementation 'junit:junit:4.12'
Run Code Online (Sandbox Code Playgroud)

代替

 compile 'com.android.support:appcompat-v7:25.0.0'
 testCompile 'junit:junit:4.12'
Run Code Online (Sandbox Code Playgroud)

它们之间有什么区别,我应该使用什么?

dependency-management gradle transitive-dependency build.gradle gradle-plugin

899
推荐指数
10
解决办法
27万
查看次数

Android:强制gradle只包含一个版本的库

'com.android.support:support-v4:23.3.0'在使用我的build.gradle但是在探索外部库时,我看到了两个版本的support-v4库(23.3.0和24.0.0).如何找到哪个依赖项使用support-v4:24.0.0库?如何强制gradle只添加版本23.3.0?

外部图书馆图像

这是我在build.gradle中的依赖列表:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.android.support:support-v4:23.3.0'
    compile 'com.android.support:design:23.3.0'
    compile 'com.android.support:recyclerview-v7:23.3.0'
    compile 'com.android.support:cardview-v7:23.3.0'
    compile ('com.nightonke:wowoviewpager:1.0.2') {
        exclude group: 'com.android.support', module:'support-v4'
    }
    compile ('com.j256.ormlite:ormlite-android:5.0'){
        exclude group: 'com.android.support', module:'support-v4'
    }
    compile files('libs/picasso-2.5.2.jar')
    compile files('libs/easyandroidanimationslibrary-v0.5.jar')
    compile files('libs/apache-httpcomponents-httpclient.jar')
    compile files('libs/apache-httpcomponents-httpcore.jar')
    compile 'co.ronash.android:pushe-base:1.2.0'
    compile 'com.google.android.gms:play-services-gcm:9.4.0'
    compile('com.github.ozodrukh:CircularReveal:2.0.1@aar') {
        transitive = true;
    }
    compile files('libs/btsdk.jar')
    compile project(':zxing_barcode') // this project include the same version of support-v4 library
    compile project(':cropper')// this project include the same version of support-v4 …
Run Code Online (Sandbox Code Playgroud)

android gradle android-studio support-v4 gradle-dependencies

18
推荐指数
1
解决办法
2万
查看次数

您应该通过DependencyResolution手动设置相同的版本

错误:任务':app:preDebugBuild'的执行失败.

Android依赖项"com.google.android.gms:play-services-ads"具有不同版本的编译(11.8.0)和运行时(11.0.4)类路径.您应该通过DependencyResolution手动设置相同的版本

我的项目是:

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:3.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

我的模块gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId 'com.bezets.cityappar'
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 4
        versionName '1.3.0'
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes { …
Run Code Online (Sandbox Code Playgroud)

android android-studio android-gradle-plugin

14
推荐指数
2
解决办法
2万
查看次数