在buildConfigFied中动态设置令牌值

时间:2018-06-27 09:21:05

标签: android build.gradle

我想在build.gradle的buildConfigFied中动态设置TWILIO_ACCESS_TOKEN值。     在video-quickstart-android-master示例应用程序(https://github.com/twilio/video-quickstart-android)中,据说“将从控制台复制的访问令牌字符串添加到local.properties文件中名为TWILIO_ACCESS_TOKEN的变量中。”但是我必须动态添加值吗?

local.propertise

ndk.dir=C\:\\Users\\Santanu\\AppData\\Local\\Android\\sdk\\ndk-bundle
sdk.dir=C\:\\Users\\Santanu\\AppData\\Local\\Android\\sdk
TWILIO_ACCESS_TOKEN=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImN0eSI6InR3aWxpby1mcGE7dj0xIn0.eyJqdGkiOiJTSzA2MTcwN2UxNzg5ZWEzMzM3ODcyZTA5MjQyODM3YmI5LTE1MzAwODI3NTAiLCJpc3MiOiJTSzA2MTcwN2UxNzg5ZWEzMzM3ODcyZTA5MjQyODM3YmI5Iiwic3ViIjoiQUNjOTIyOWVlYjkyOWU5MTgxM2ZjMDMwYTg5Y2I5ODViYyIsImV4cCI6MTUzMDA4NjM1MCwiZ3JhbnRzIjp7ImlkZW50aXR5IjoiTXVzaHlOYXRlRGF2ZW5wb3J0IiwidmlkZW8iOnt9LCJkYXRhX3N5bmMiOnsic2VydmljZV9zaWQiOiJkZWZhdWx0In19fQ.53J0CJPUjEQpHai_itc0FBbXCyiPQNdMo5NV0eYv1J0

我说的这个TWILIO_ACCESS_TOKEN我添加了硬代码值。我需要该值来动态添加。怎么可能?

build.gradle

buildConfigField("String",
            "TWILIO_ACCESS_TOKEN",
            "\"${getSecretProperty("TWILIO_ACCESS_TOKEN", "TWILIO_ACCESS_TOKEN")}\"")
    buildConfigField("String",
            "TWILIO_ACCESS_TOKEN_SERVER",
            "\"${getSecretProperty("TWILIO_ACCESS_TOKEN_SERVER", "http://localhost:3000")}\"")
    buildConfigField("boolean",
            "USE_TOKEN_SERVER",
            "${getSecretProperty("USE_TOKEN_SERVER", true)}")

0 个答案:

没有答案