Proper way to use System environment variables in gradle using Android Studio

前端 未结 2 1668
我在风中等你
我在风中等你 2021-01-01 10:36

I am using Android Studio to build my project on an Ubuntu 14.04 system.

I wrote the following in my build.gradle files to avoid hardcoding storeFile, storePassword,

2条回答
  •  悲哀的现实
    2021-01-01 10:58

    I also like having my keystore information on my environment variables, rather than having it inside the project. Your code seems fine, but I was having the same issue with the file path. I solved it by converting that value to string before passing it to file():

    signingConfigs {
     debug {
        storeFile file(String.valueOf(System.getenv("KEYSTORE")))
        storePassword System.getenv("KEYSTORE_PASSWORD")
        keyAlias System.getenv("KEY_ALIAS")
        keyPassword System.getenv("KEY_PASSWORD")        
     }
    

    Hope this helps.

提交回复
热议问题