【问题标题】:Error:Execution failed for task :app:transformJackWithJackForDebug - Android?错误:任务执行失败:app:transformJackWithJackForDebug - Android?
【发布时间】:2017-07-12 06:52:34
【问题描述】:

我的gradle 如下所示:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "26.0.0"
    defaultConfig {
        applicationId "xx.xx.xx"
        minSdkVersion 17
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        jackOptions {
            enabled true
        }
    }
    dataBinding {
        enabled = true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    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:recyclerview-v7:25.3.1'
    compile 'com.android.support:cardview-v7:25.3.1'
    testCompile 'junit:junit:4.12'
    //Slider
    compile 'com.squareup.picasso:picasso:2.3.2'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.daimajia.slider:library:1.1.5@aar'
    //Rx
    compile 'io.reactivex.rxjava2:rxjava:2.0.1'
    compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
    compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
    // Web Libs
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.google.code.gson:gson:2.8.0'
    compile 'com.squareup.okhttp3:okhttp:3.6.0'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'

}

这里:

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

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        //Slider
        classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.10.+'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

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

但是当我运行我的项目时,说我 BUILD FAILED 并向我显示以下消息:

【问题讨论】:

    标签: android android-studio gradle android-gradle-plugin android-jack-and-jill


    【解决方案1】:

    从 build.gradle 中的 defaultConfig 中移除 jackOption

    在 Application gradle 中添加以下行

    dependencies {
    
    classpath 'com.android.tools.build:gradle:2.3.1'
    
    classpath 'me.tatarka:gradle-retrolambda:3.2.3'
    
    }
    

    并在 build.gradle 中添加如下行:

    apply plugin: 'me.tatarka.retrolambda'
    

    希望这会有所帮助。

    【讨论】:

      【解决方案2】:

      我解决了我的问题:

      模块分级:

      apply plugin: 'com.android.application'
      apply plugin: 'me.tatarka.retrolambda'
      
      android {
          compileSdkVersion 25
          buildToolsVersion "26.0.0"
          defaultConfig {
              applicationId "xx.xxx.xxx"
              minSdkVersion 17
              targetSdkVersion 25
              versionCode 1
              versionName "1.0"
              testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
      
          }
      
          dataBinding {
              enabled = true
          }
      
          buildTypes {
              release {
                  minifyEnabled false
                  proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
              }
          }
      
          compileOptions {
              sourceCompatibility JavaVersion.VERSION_1_8
              targetCompatibility JavaVersion.VERSION_1_8
          }
      }
      
      dependencies {
          compile fileTree(include: ['*.jar'], dir: 'libs')
          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:recyclerview-v7:25.3.1'
          compile 'com.android.support:cardview-v7:25.3.1'
          testCompile 'junit:junit:4.12'
          //Slider
          compile 'com.squareup.picasso:picasso:2.3.2'
          compile 'com.nineoldandroids:library:2.4.0'
          compile 'com.daimajia.slider:library:1.1.5@aar'
          // Web Libs
          compile 'com.github.bumptech.glide:glide:3.7.0'
          compile 'com.google.code.gson:gson:2.8.0'
          compile 'com.squareup.okhttp3:okhttp:3.6.0'
          compile 'com.squareup.retrofit2:retrofit:2.1.0'
          compile 'com.squareup.retrofit2:converter-gson:2.1.0'
          //Rx
          compile 'io.reactivex.rxjava2:rxjava:2.0.1'
          compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
          compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
          compile 'com.netflix.rxjava:rxjava-android:0.16.1'
      
      }
      

      项目等级:

      // Top-level build file where you can add configuration options common to all sub-projects/modules.
      
      buildscript {
          repositories {
              jcenter()
          }
      
          dependencies {
              classpath 'com.android.tools.build:gradle:2.3.3'
              //Slider
              classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.10.+'
              //Lambda
              classpath 'me.tatarka:gradle-retrolambda:3.2.3'
              // NOTE: Do not place your application dependencies here; they belong
              // in the individual module build.gradle files
          }
      }
      
      allprojects {
          repositories {
              jcenter()
          }
      }
      
      task clean(type: Delete) {
          delete rootProject.buildDir
      }
      

      【讨论】:

      • 你能解释一下你做了什么改变吗?
      猜你喜欢
      • 2015-05-13
      • 2016-09-02
      • 2017-09-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-01
      相关资源
      最近更新 更多