@@ -16,26 +16,40 @@ versionProperties.load(new FileInputStream(versionsPropertiesFile))
1616android {
1717 signingConfigs {
1818 def localPropertiesFile = rootProject. file(" local.properties" )
19- def localProperties = new Properties ()
20- localProperties. load(new FileInputStream (localPropertiesFile))
2119
22- if (localProperties[' storeFile' ] && localProperties[' keyAlias' ] &&
23- localProperties[' storePassword' ] && localProperties[' keyPassword' ]) {
24-
25- debug {
26- keyAlias = localProperties[' keyAlias' ]
27- storeFile = new File (localProperties[' storeFile' ])
28- storePassword = localProperties[' storePassword' ]
29- keyPassword = localProperties[' keyPassword' ]
30- }
31- release {
32- keyAlias = localProperties[' keyAlias' ]
33- storeFile = new File (localProperties[' storeFile' ])
34- storePassword = localProperties[' storePassword' ]
35- keyPassword = localProperties[' keyPassword' ]
20+ // 🔑 Check if the file exists before proceeding
21+ if (localPropertiesFile. exists()) {
22+ def localProperties = new Properties ()
23+
24+ // Note: It's safer to use 'new FileInputStream(localPropertiesFile)' within 'try-catch'
25+ // or use the file's 'withInputStream' method, but for a simple check,
26+ // the 'exists()' guard is the primary requirement.
27+ localProperties. load(new FileInputStream (localPropertiesFile))
28+
29+ if (localProperties[' storeFile' ] && localProperties[' keyAlias' ] &&
30+ localProperties[' storePassword' ] && localProperties[' keyPassword' ]) {
31+
32+ // Configuration logic remains the same
33+ debug {
34+ keyAlias = localProperties[' keyAlias' ]
35+ storeFile = new File (localProperties[' storeFile' ])
36+ storePassword = localProperties[' storePassword' ]
37+ keyPassword = localProperties[' keyPassword' ]
38+ }
39+ release {
40+ keyAlias = localProperties[' keyAlias' ]
41+ storeFile = new File (localProperties[' storeFile' ])
42+ storePassword = localProperties[' storePassword' ]
43+ keyPassword = localProperties[' keyPassword' ]
44+ }
45+ } else {
46+ // Optional: Print a warning if the file exists but is missing required properties
47+ println (" ⚠️ Warning: local.properties file exists, but is missing one or more required signing properties." )
3648 }
49+ } else {
50+ // Optional: Print a warning if the file doesn't exist
51+ println (" ⚠️ Warning: local.properties file not found. Signing configurations will not be applied." )
3752 }
38-
3953 }
4054 compileSdk 36
4155
0 commit comments