2016-01-06 33 views
5

nie mogę uaktualnić mojego projektu Gradle 1.5:Dostęp do zadania dex jest teraz niemożliwe, począwszy od 1.4.0

build.gradle (root) projekt odświeżania nie powiodło się: Dostęp do zadania dex jest teraz niemożliwe, począwszy z 1.4.0. Błąd: 1.4.0 wprowadza nowy interfejs Transform API umożliwiający manipulowanie plikami .class.

Jakieś sugestie?

korzeń 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) {} 
} 

aplikacja 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:[email protected]' 
compile 'com.koushikdutta.ion:ion:[email protected]' 
compile 'com.path:android-priority-jobqueue:1.1.2' 
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3' 
compile 'com.soundcloud.android:android-crop:[email protected]' 

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()}" 
    } 
} 

Im po https://codelabs.developers.google.com/codelabs/android-testing/ dostać test działa na moim projekcie (Mokito na przykład), ale nie robi praca.

+0

Czy kiedykolwiek rozwiązałeś? – Radu

Odpowiedz

15

Może ten numer dotyczy nowej wersji. Próbowałem zainstalować najnowszą wersję newrelic i pomyślnie.

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

compile 'com.newrelic.agent.android:android-agent:5.5.0'

+0

try 5. + (wiem, że to nie jest poprawne moralnie, ale hej to jest integracja API analytics, o której mówimy.) Jeśli 5 + działa dobrze, spróbuj wrócić do nowszej wersji. – beerBear

0

Aby rozwiązać problem, wykonaj następujące kroki. (Access to the Dex is now impossible, starting with 1.4.0)

  1. zaktualizować wszystkie biblioteki (zależności od usługi Google Play i bibliotek Pomocy wraz z innymi SDK używany) do maksymalnej dostępnej wersji. Jeśli używasz NewRelic, następnie aktualizację do najnowszej wersji.
  2. Dodaj multiDexEnabled true do defaultConfig w /app/build.gradle.

    defaultConfig { 
        minSdkVersion 16 
        targetSdkVersion 23 
        versionCode 1 
        multiDexEnabled true 
    } 
    
  3. Usuń cały uprzednio napisany kod, aby MultiDexing działał. Przykładowo

    • wyjąć blok afterEvaluate do MultiDex

      afterEvaluate { 
          tasks.matching { 
           it.name.startsWith('dex') 
          }.each { dx -> 
           if (dx.additionalParameters == null) { 
            dx.additionalParameters = [] 
          } 
          dx.additionalParameters += '--multi-dex' 
      
          // this is optional 
          // dx.additionalParameters += "--main-dex-list=$projectDir/multidex-classes.txt".toString() 
          } 
      } 
      
    • usunąć zależność

      dependencies { 
          ... 
          compile 'com.android.support:multidex:1.0.1' 
      } 
      
    • usunąć kod AndroidManifest.xml

      <?xml version="1.0" encoding="utf-8"?> 
      <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
           package="com.example.pcsalt.multidex"> 
          <application 
            ... 
           android:name="android.support.multidex.MultiDexApplication"> 
            ... 
          </application> 
      </manifest> 
      
    • Jeśli używasz niestandardowej klasy Application rozszerzając android.app.Application, a następnie usunąć MultiDex.install(base);

      @Override 
      protected void attachBaseContext(Context base) { 
           super.attachBaseContext(base); 
           MultiDex.install(base); 
      } 
      
  4. Aktualizacja wersji build narzędzie do 2.1.2 (najwyższa stabilna wersja dostępna w czasie pisanie) w/kompilacji.Gradle

    classpath 'com.android.tools.build:gradle:2.1.2' 
    
  5. Gradle Sync projekt, klikając Synchronizuj teraz

nadzieję, że to pomaga.

http://www.pcsalt.com/android/solution-access-dex-task-now-impossible-starting-1-4-0

Powiązane problemy