I try to migrate my Android project to new experimental gradle plugin. I followed instructions at this page. I made changes in required files, but I have an error when I trying to Sync project with gradle files.
Error:Unable to load class 'com.android.build.gradle.managed.ProductFlavor_Impl'. Possible causes for this unexpected error include:
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
- 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.
build.gradle
in my app
folder is very similar to this:
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...
}
Does anybody know where the problem is? I do not know why error message contains problem about ProductFlavor, because my project has no flavors...
UPDATE
I tried to clean my project - clean was not successful, but the error message during clean is more specific:
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
But still I do not know how can I fix it.
Import as a module: xml file and click Ok. Modify the module name if desired, and click Next. The import process prompts you to migrate any library and project dependencies to Android Studio, and add the dependency declarations to the build. gradle file.
In case this is not the real file in your project, make sure you have:
minSdkVersion.apiLevel
targetSdkVersion.apiLevel
instead of:
minSdkVersion
targetSdkVersion
I had the same issue and this fixed it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With