gpt4 book ai didi

android - 找不到 Gradle DSL 方法 : 'resValue()' error

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:54:02 32 4
gpt4 key购买 nike

我在 gradle sync 时遇到这个错误。我在 android defaultConfig block 中调用该方法。我用com.android.tools.build:gradle:1.3.0com.neenbedankt.gradle.plugins:android-apt:1.4

构建.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()
}
}

构建.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 - 找不到 Gradle DSL 方法 : 'resValue()' error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33751782/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com