无法获取未知属性“ CLIENT_ACCESS_TOKEN”

时间:2018-12-27 22:28:42

标签: android android-gradle dialogflow

我下载了以下github文件:https://github.com/abhi007tyagi/DialogflowChat 我想用我的Dialogflow帐户连接API v2 。我的英语不太好,因此阅读文档时我听不懂。 我已经可以在API v1上运行,但是需要跳到API v2 。需要您的帮助。

当我尝试在Android Studio上构建该项目时,遇到以下错误

Could not get unknown property 'CLIENT_ACCESS_TOKEN' for BuildType_Decorated{name=release, debuggable=false, testCoverageEnabled=false, jniDebuggable=false, pseudoLocalesEnabled=false, renderscriptDebuggable=false, renderscriptOptimLevel=3, minifyEnabled=true, zipAlignEnabled=true, signingConfig=null, embedMicroApp=true, mBuildConfigFields={}, mResValues={}, mProguardFiles=[D:\Yeni inenler\Check\DialogflowChat-master2\DialogflowChat-master\build\intermediates\proguard-files\proguard-android.txt-3.2.1, D:\Yeni inenler\Check\DialogflowChat-master2\DialogflowChat-master\app\proguard-rules.pro], mConsumerProguardFiles=[], mManifestPlaceholders={}} of type com.android.build.gradle.internal.dsl.BuildType.

这是build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.tyagiabhinav.dialogflowchat"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            buildConfigField 'String', "ClientAccessToken", CLIENT_ACCESS_TOKEN
            resValue 'string', "ClientAccessToken", CLIENT_ACCESS_TOKEN
        }
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            buildConfigField 'String', "ClientAccessToken", CLIENT_ACCESS_TOKEN
            resValue 'string', "ClientAccessToken", CLIENT_ACCESS_TOKEN
        }
    }


    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    // Java V2
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/INDEX.LIST'
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    // Dialogflow SDK dependencies
    implementation 'ai.api:sdk:2.0.7@aar'
    implementation 'ai.api:libai:1.6.12'

    // Java V2
    implementation 'com.google.cloud:google-cloud-dialogflow:0.67.0-alpha'
    // for Remote Procedure Call to avoid "No functional channel service provider found" error while creating SessionsClient
    implementation 'io.grpc:grpc-okhttp:1.15.1'
}

2 个答案:

答案 0 :(得分:0)

在项目中与local.properties相同的位置创建一个新文件。 并在其中添加以下两行:-

org.gradle.jvmargs=-Xmx1536m
CLIENT_ACCESS_TOKEN="enter_your_dialogflow_client_access_token"

答案 1 :(得分:0)

在项目中创建gradle.properties新文件,然后添加

CLIENT_ACCESS_TOKEN="key"