当前位置:  开发笔记 > 编程语言 > 正文

现在无法访问dex任务,从1.4.0开始

如何解决《现在无法访问dex任务,从1.4.0开始》经验,为你挑选了1个好方法。

我不能将我的项目升级为gradle 1.5:

build.gradle(root)项目刷新失败:从1.4.0开始,现在无法访问dex任务.错误:1.4.0引入了一个新的Transform API,允许操作.class文件.

有什么建议吗?

root build.gradle:

buildscript {
    repositories {
        jcenter()
    }
dependencies {
    classpath 'com.android.tools.build:gradle:1.5.0'
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

subprojects {
    task allDependencies(type: DependencyReportTask) {}
}

app build.gradle:

buildscript {
repositories {
    mavenCentral()
    maven { url 'http://download.crashlytics.com/maven' }
}

dependencies {
    classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.14.7'
    classpath "com.newrelic.agent.android:agent-gradle-plugin:4.244.0"
}
}

repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url 'http://download.crashlytics.com/maven' }
}

task wrapper(type: Wrapper) {
gradleVersion = '2.7'
}

apply plugin: 'com.android.application'

 android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

signingConfigs {
    release
}

testBuildType "debug"

defaultConfig {
    targetSdkVersion 23
    minSdkVersion 14

    multiDexEnabled true

    applicationId "com.freelancer.android.messenger"
    versionCode versionMajor * 10000 + versionMinor * 1000 + versionPatch * 100 + versionBuild
    versionName "${versionMajor}.${versionMinor}.${versionPatch}"
    testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'

    renderscriptTargetApi 21
    renderscriptSupportModeEnabled true

}

sourceSets {
    production {
        java.srcDir 'src/common/java'
    }

    develop {
        java.srcDir 'src/common/java'
    }

    staging {
        java.srcDir 'src/common/java'
    }
}

buildTypes {
    release {
        signingConfig signingConfigs.release
        minifyEnabled true
        proguardFile 'proguard.cfg'
        buildConfigField "String", "CONTENT_PROVIDER_AUTHORITY",
                "\"com.freelancer.android.messenger.content_provider\""
    }
    debug {
        applicationIdSuffix '.debug'
        versionNameSuffix '.' + versionBuild + '-debug' + gitSha
        buildConfigField "String", "CONTENT_PROVIDER_AUTHORITY",
                "\"com.freelancer.android.messenger.content_provider.\" + BUILD_TYPE.toLowerCase()"
        debuggable true
        testCoverageEnabled = true
    }

    staging {
        applicationIdSuffix '.staging'
        versionNameSuffix '-staging-' + gitSha

        buildConfigField "String", "BASE_URL_API", "\"${rootProject.ext.stagingApiServer}\""
        buildConfigField "String", "BASE_URL_AUTH", "\"${rootProject.ext.stagingAuthServer}\""
        buildConfigField "String", "BASE_URL_WSS", "\"${rootProject.ext.stagingWsServer}\""
        buildConfigField "String", "BASE_URL_GAF", "\"${rootProject.ext.stagingGafUrl}\""
    }
}


productFlavors {
    // Define separate dev and prod product flavors.
    develop {
        // dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
        // to pre-dex each module and produce an APK that can be tested on
        // Android Lollipop without time consuming dex merging processes.
        minSdkVersion 21
    }
    production {
        // The actual minSdkVersion for the application.
    }
    mock {

    }

}

// from android 6 apache its been deprecated: refer to ->
// http://developer.android.com/about/versions/marshmallow/android-6.0-changes.html
 //    useLibrary 'org.apache.http.legacy'

}


dependencies {

compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:support-v4:22.2.0'
compile 'com.android.support:cardview-v7:22.2.0'
compile 'com.android.support:palette-v7:22.2.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'com.android.support:design:22.2.0'

compile 'com.google.android.gms:play-services-gcm:7.5.0'
compile 'com.google.android.gms:play-services-maps:7.5.0'
compile 'com.google.android.gms:play-services-location:7.5.0'
compile 'com.google.android.gms:play-services-analytics:7.5.0'

compile 'com.google.maps.android:android-maps-utils:0.3.4'
compile 'com.google.code.gson:gson:2.3'

// extension for popular dashclock app
compile 'com.google.android.apps.dashclock:dashclock-api:2.0.0'

compile 'com.jakewharton:butterknife:4.0.1'
compile 'com.squareup:otto:1.3.5'
compile 'com.squareup.dagger:dagger:1.2.2'
compile 'com.squareup.dagger:dagger-compiler:1.2.2'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0'
compile 'com.squareup.okhttp:okhttp:2.5.0'

compile ('com.facebook.android:facebook-android-sdk:3.23.0') {
    exclude group: 'com.google.android'
}

compile 'com.newrelic.agent.android:android-agent:4.244.0'
compile "com.mixpanel.android:mixpanel-android:4.5.3"
compile 'com.crashlytics.android:crashlytics:1.1.13'

compile 'com.github.kevinsawicki:http-request:6.0' // TODO deprecate and replace methods with okhttp

compile 'com.koushikdutta.async:androidasync:1.2.9@jar'
compile 'com.koushikdutta.ion:ion:1.2.9@jar'
compile 'com.path:android-priority-jobqueue:1.1.2'
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
compile 'com.soundcloud.android:android-crop:0.9.10@aar'

compile project(':libs:stickylistheaders:library')
compile project(':libs:android-core:android-core-library')
compile project(':libs:viewpagerindicator:library')
compile project(':libs:PagerSlidingTabStrip')

compile "org.mockito:mockito-core:1.10.19"
compile 'com.google.dexmaker:dexmaker:1.2'
compile 'com.google.dexmaker:dexmaker-mockito:1.2'

compile 'com.bartoszlipinski.flippablestackview:library:1.2.1'
compile 'com.edmodo:rangebar:1.0.0'
compile 'com.github.clans:fab:1.6.1'

compile fileTree(dir: '../libs', include: '*.jar')

testCompile('org.robolectric:robolectric:3.0') {
    exclude group: 'commons-logging', module: 'commons-logging'
    exclude group: 'org.apache.httpcomponents', module: 'httpclient'
    exclude group: 'com.android.support', module: 'appcompat'
    exclude group: 'com.android.support', module: 'support-v4'
    exclude group: 'com.android.support', module: 'recyclerview-v7'
}
testCompile "org.robolectric:shadows-multidex:3.0" // this is needed to avoid multidex

// Dependencies for local unit tests
//    testCompile "org.assertj:assertj-core:$rootProject.ext.assertjCore"
testCompile "org.hamcrest:hamcrest-all:$rootProject.ext.hamcrestVersion"
testCompile "junit:junit:$rootProject.ext.junitVersion"
testCompile "org.mockito:mockito-all:$rootProject.ext.mockitoVersion"
testCompile "org.powermock:powermock-module-junit4:$rootProject.ext.powerMockito"
testCompile "org.powermock:powermock-api-mockito:$rootProject.ext.powerMockito"

// Android Testing Support Library's runner and rules
androidTestCompile "com.android.support.test:runner:$rootProject.ext.runnerVersion"
androidTestCompile "com.android.support.test:rules:$rootProject.ext.runnerVersion"

// Espresso UI Testing dependencies.
androidTestCompile "com.android.support.test.espresso:espresso-core:$rootProject.ext.espressoVersion"
androidTestCompile "com.android.support.test.espresso:espresso-contrib:$rootProject.ext.espressoVersion"
androidTestCompile "com.android.support.test.espresso:espresso-intents:$rootProject.ext.espressoVersion"

// dependencies added after dex split
//    compile 'com.jakewharton.timber:timber:3.1.0'
 }


 configurations.all {
     resolutionStrategy.force "com.android.support:support-   annotations:$rootProject.supportLibraryVersion"
     resolutionStrategy.force "org.hamcrest:hamcrest-core:$rootProject.hamcrestVersion"
     resolutionStrategy.force "com.squareup:javawriter:2.5.0"
}

 configurations.compile.dependencies.each { compileDependency ->
     println "Excluding compile dependency: ${compileDependency.getName()}"
     configurations.androidTestCompile.dependencies.each { androidTestCompileDependency ->
         configurations.androidTestCompile.exclude module:    "${compileDependency.getName()}"
    }
 }

我按照https://codelabs.developers.google.com/codelabs/android-testing/来测试我的项目(例如mokito),但它不起作用.



1> thanhnd..:

也许这个问题与newrelic版本有关.我试图安装最新版本的newrelic并成功.

classpath"com.newrelic.agent.android:agent-gradle-plugin:5.5.0"

编译'com.newrelic.agent.android:android-agent:5.5.0'

推荐阅读
mylvfamily
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有