android – 找不到Gradle DSL方法:’resValue()’错误
作者:互联网
在gradle sync时我有这个错误.我调用android defaultConfig块中的方法.
我用
com.android.tools.build:gradle:1.3.0
com.neenbedankt.gradle.plugins:Android的贴切:1.4
的build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply from: 'config.gradle'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
allprojects {
repositories {
jcenter()
}
}
的build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
plugins {
id "me.tatarka.retrolambda" version "3.2.2"
}
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
repositories {
jcenter()
mavenCentral()
}
def googlePlayServiceVersion = "8.1.0"
def supportVersion = "23.1.1"
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:'+supportVersion
compile 'com.android.support:appcompat-v7:'+supportVersion
compile 'com.android.support:design:'+supportVersion
compile 'com.android.support:cardview-v7:'+supportVersion
compile 'com.android.support:recyclerview-v7:'+supportVersion
compile 'com.android.support:gridlayout-v7:'+supportVersion
compile 'com.google.android.gms:play-services-base:'+googlePlayServiceVersion
compile 'com.google.android.gms:play-services-analytics:'+googlePlayServiceVersion
compile 'com.google.android.gms:play-services-maps:'+googlePlayServiceVersion
compile 'com.google.android.gms:play-services-location:'+googlePlayServiceVersion
//ui
compile 'org.sufficientlysecure:html-textview:1.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.commit451:PhotoView:1.2.4'
compile 'org.solovyev.android.views:linear-layout-manager:0.5@aar'
//utils
compile 'me.dm7.barcodescanner:zbar:1.7'
compile 'org.parceler:parceler-api:1.0.3'
apt 'org.parceler:parceler:1.0.3'
compile 'com.anupcowkur:reservoir:2.0'//кеш
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.annimon:stream:1.0.3'
//networking
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.google.code.gson:gson:2.3.1'
//dagger
apt 'com.squareup.dagger:dagger-compiler:1.2.2'
compile 'com.squareup.dagger:dagger:1.2.2'
}
android {
String appPackageName = rootProject.ext.basePackageName
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
compileSdkVersion 23
buildToolsVersion "23.0.2"
lintOptions {
checkReleaseBuilds false
abortOnError false
disable 'InvalidPackage'
}
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
versionCode 6
versionName "6.0"
applicationId appPackageName
resValue 'string' 'appId' appPackageName
// strings.each { entry ->
// resValue 'string', entry.key, entry.value
// }
//
// colors.each { entry ->
// resValue 'color', entry.key, entry.value
// }
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
applicationIdSuffix ".test"
// minifyEnabled true
// shrinkResources true
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
错误:
Caused by: org.gradle.api.internal.MissingMethodException: Could not find method resValue() for arguments [string] on ProductFlavor_Decorated{name=main, dimension=null, minSdkVersion=ApiVersionImpl{mApiLevel=16, mCodename='null'}, targetSdkVersion=ApiVersionImpl{mApiLevel=22, mCodename='null'}, renderscriptTargetApi=null, renderscriptSupportModeEnabled=null, renderscriptNdkModeEnabled=null, versionCode=6, versionName=6.0, applicationId=com.my.pocket, testApplicationId=null, testInstrumentationRunner=null, testInstrumentationRunnerArguments={}, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfig=null, mBuildConfigFields={}, mResValues={}, mProguardFiles=[], mConsumerProguardFiles=[], mManifestPlaceholders={}}.
at org.gradle.api.internal.AbstractDynamicObject.methodMissingException(AbstractDynamicObject.java:68)
at org.gradle.api.internal.AbstractDynamicObject.invokeMethod(AbstractDynamicObject.java:56)
at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:172)
at com.android.build.gradle.internal.dsl.ProductFlavor_Decorated.invokeMethod(Unknown Source)
at build_cdgdo5tni0sgiyuqwlawpgfo8$_run_closure3_closure6.doCall(***/app/build.gradle:95)
at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:63)
at org.gradle.api.Action$execute.call(Unknown Source)
at com.android.build.gradle.BaseExtension.defaultConfig(BaseExtension.groovy:373)
at com.android.build.gradle.AppExtension_Decorated.defaultConfig(Unknown Source)
at build_cdgdo5tni0sgiyuqwlawpgfo8$_run_closure3.doCall(***/app/build.gradle:86)
at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:63)
at org.gradle.api.internal.plugins.ExtensionsStorage$ExtensionHolder.configure(ExtensionsStorage.java:145)
at org.gradle.api.internal.plugins.ExtensionsStorage.configureExtension(ExtensionsStorage.java:69)
at org.gradle.api.internal.plugins.DefaultConvention$ExtensionsDynamicObject.invokeMethod(DefaultConvention.java:207)
at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:147)
at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:79)
at build_cdgdo5tni0sgiyuqwlawpgfo8.run(***/app/build.gradle:69)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
解决方法:
根据你的异常堆栈,你应该尝试用逗号分隔你的参数,就像我在评论中写的那样,因为在你的情况下,gradle试图找到一个只有一个输入参数的方法,但它没有这样的方法.
defaultConfig {
...
resValue 'string', 'appId', appPackageName //here is what I mean
}
标签:android,build-process,gradle 来源: https://codeday.me/bug/20190628/1314155.html