2015-09-09 18 views
7

Provo a migrare il mio progetto Android in un nuovo plug-in sperimentale gradle. Ho seguito le istruzioni alla pagina this. Ho apportato modifiche ai file richiesti, ma ho un errore quando provo a sincronizzare il progetto con i file gradle.Migrazione del progetto al nuovo plug-in gradle sperimentale

Error:Unable to load class 'com.android.build.gradle.managed.ProductFlavor_Impl'. Possible causes for this unexpected error include:

  • Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network)
  • The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build processes (requires restart)
  • Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

build.gradle nella mia cartella app è molto simile a questo:

apply plugin: 'com.android.model.application' 
apply plugin: 'maven' 

repositories { 
    maven { 
     url = getBaseRepository() 
     credentials { 
      username = NEXUS_USERNAME 
      password = NEXUS_PASSWORD 
     } 
    } 
    mavenCentral() 
} 

def int CACHE_LIMIT = CACHE_CHANGING_MODULES_FOR_SECONDS.toInteger() 

configurations.all { 
    resolutionStrategy.cacheChangingModulesFor CACHE_LIMIT, 'seconds' 
} 

model { 
    android { 
     compileSdkVersion = 23 
     buildToolsVersion = "23.0.0" 

     defaultConfig.with { 
      applicationId = "<myRealAppIdIsHere>" 
      minSdkVersion.apiLevel = 14 
      targetSdkVersion.apiLevel = 18 

      multiDexEnabled = true 
     } 
    } 

    android.buildTypes { 
     debug { 
      /*buildConfigField.with { 
       create() { 
        type = "boolean" 
        name = "DEBUG_BUILD" 
        value = rootProject.ext.debugBuild 
       } 
      }*/ 
     } 
     release { 
      minifyEnabled = false 
      proguardFiles += 'proguard-rules.pro' 
      /*buildConfigField.with { 
       create() { 
        type = "boolean" 
        name = "DEBUG_BUILD" 
        value = rootProject.ext.releaseBuild 
       } 
      }*/ 
     } 
    } 
} 


dependencies { 
    // my dependencies are here... 
} 

Qualcuno sa dove è il problema? Non so il motivo per cui il messaggio di errore contiene problema circa ProductFlavor, perché il mio progetto non ha sapori ...

UPDATE

ho cercato di pulire il mio progetto - pulita non è riuscita, ma il messaggio di errore durante la pulizia è più specifico:

Error:(10, 1) A problem occurred configuring project ':app'. Exception thrown while executing model rule: com.android.build.gradle.model.BaseComponentModelPlugin$Rules#createVariantData(org.gradle.model.ModelMap, org.gradle.model.ModelMap, com.android.build.gradle.internal.TaskManager) > afterEach() Could not resolve all dependencies for configuration ':app:_debugCompile'. Exception thrown while executing model rule: model.android Cannot set readonly property: minSdkVersion for class: com.android.build.gradle.managed.ProductFlavor_Impl

Ma ancora non so come posso risolvere il problema.

+0

Ciò può accadere in un progetto a più moduli. Hai più di un modulo nel tuo progetto? –

+0

abbiamo lo stesso problema. il nostro progetto contiene un modulo. come possiamo risolvere questo problema? –

risposta

6

Nel caso in cui questo non è il vero file nel progetto, assicurarsi di avere:

minSdkVersion.apiLevel 
targetSdkVersion.apiLevel 

invece di:

minSdkVersion 
targetSdkVersion 

Ho avuto lo stesso problema e questo riparato.

+1

Com'è associato all'errore ** createVariantData **? –

Problemi correlati