Can't resolve DefaultManifestParser after gradle plugin update
I am trying to compile an AndroidCaldavSyncAdapter project in Android Studio. He even worked before, but after the upgrade from version gradle com.android.tools.build:gradle:1.5.0
until com.android.tools.build:gradle:2.3.0
it stops working. Now I am getting this error:
Error:(34, 0) A problem occurred evaluating project ':ACalDAV'.
and cannot resolve symbol 'builder'
in
import com.android.builder.core.DefaultManifestParser
Here is the file build.grade
:
import com.android.builder.core.DefaultManifestParser
apply plugin: 'com.android.application'
apply from: '../config/quality/quality.gradle'
android {
compileSdkVersion 22
buildToolsVersion '25.0.3'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
defaultConfig {
applicationId "de.we.acaldav"
minSdkVersion 14
targetSdkVersion 20
multiDexEnabled true
def manifestParser = new DefaultManifestParser()
versionName = manifestParser.getVersionName(android.sourceSets.main.manifest.srcFile)
}
signingConfigs {
//noinspection GroovyMissingReturnStatement
release {
if (project.hasProperty('myKeyAlias') &&
project.hasProperty('myStoreFile') &&
project.hasProperty('myStorePassword') &&
project.hasProperty('myKeyPassword')) {
keyAlias = myKeyAlias
storeFile = file(myStoreFile)
storePassword = myStorePassword
keyPassword = myKeyPassword
}
}
}
buildTypes {
release {
minifyEnabled true
signingConfig signingConfigs.release
proguardFile 'proguard-project.txt'
}
debug {
//noinspection GroovyAssignabilityCheck
applicationIdSuffix = ".debug"
//noinspection GroovyAssignabilityCheck
versionNameSuffix = "-DEBUG"
}
//noinspection GroovyAssignabilityCheck
applicationVariants.all { variant ->
variant.outputs.each { output ->
output.outputFile = new File(output.outputFile.parent, output.outputFile.name.replace(".apk", "-" + defaultConfig.versionName + ".apk"))
}
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile 'com.android.support:support-v4:22.0.0'
compile 'backport-util-concurrent:backport-util-concurrent:3.1'
compile 'commons-codec:commons-codec:1.10'
compile 'org.apache.commons:commons-lang3:3.3.2'
compile 'org.mnode.ical4j:ical4j:1.0.6'
repositories {
mavenCentral()
}
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
}
}
I tried to invalidate the caches, but that didn't change anything.
source to share
This happens because the signature DefaultManifestParser
has changed: it now expects manifestFile
as an argument.
Android Gradle Plugin version 1.5.0 does not explicitly provide a constructor for DefaultManifestParser
, which means there is an empty constructor. This expression expression def manifestParser = new DefaultManifestParser()
should run fine.
In Android Gradle Plugin version 2.2.0, the constructor signature has changed to the following:
public DefaultManifestParser(@NonNull File manifestFile)
This means that the following changes to the file build.gradle
must be performed:
def manifestParser = new DefaultManifestParser(android.sourceSets.main.manifest.srcFile)
versionName = manifestParser.getVersionName()
source to share