Reputation: 91
previous code is(this is the public-xml.gradle that for public.xml fixed resources id)
afterEvaluate {
for (variant in android.applicationVariants) {
def scope = variant.getVariantData().getScope()
String mergeTaskName = scope.getMergeResourcesTask().name
def mergeTask = tasks.getByName(mergeTaskName)
mergeTask.doLast {
copy {
int i=0
from(android.sourceSets.main.res.srcDirs) {
include 'values/public.xml'
rename 'public.xml', (i++ == 0? "public.xml": "public_${i}.xml")
}
into(mergeTask.outputDir)
}
}
}
}
now the error is
No signature of method: com.android.build.gradle.internal.scope.VariantScopeImpl.getMergeResourcesTask()is applicable for argument types: () values: []
Possible solutions: getMergeJavaResourcesTask()
I check the code for VariantScopeImp.java,find that in 3.0.1 the code is
@Nullable private AndroidTask<MergeResources> mergeResourcesTask;
in 3.1.0 the code is
@Nullable private MergeResources mergeResourcesTask;
when I chage the public-xml.gradle code to
def scope = variant.getVariantData().getScope()
def mergeTask = scope.mergeResourcesTask
the new error is
Cannot invoke method doLast() on null object
What should I do for it? thanks
Upvotes: 1
Views: 884