में एक बूलियन बदलने के लिए गड़बड़ी का कार्य मैं एक बहुत ही सरल कार्य बनाना चाहता हूं जो मेरे ग्रेडल कॉन्फ़िगरेशन में बूलियन बदलता है।बिल्ड कॉन्फ़िगरेशन
मैं एक एंड्रॉइड एप्लिकेशन पर काम करता हूं जिसे कई प्रोफाइल के साथ चलाया जा सकता है, और प्रत्येक के लिए यह निर्दिष्ट करने की आवश्यकता है कि मेरे कोड में ऐप को ब्लूटूथ नकली होना चाहिए या नहीं।
मेरे Gradle (प्रासंगिक कोड):
if (BuildConfig.fakeBluetooth) {
processFictiveBluetoothService();
} else {
// other case
}
कमांड लाइन में उपयोग के उदाहरण::
def fakeBluetooth = "true"
buildTypes {
debug {
minifyEnabled false
signingConfig android.signingConfigs.debug
buildConfigField "boolean", "fakeBluetooth", fakeBluetooth
}
release {
minifyEnabled true
signingConfig android.signingConfigs.release
buildConfigField "boolean", "fakeBluetooth", fakeBluetooth
}
}
task noFakeBluetooth {
fakeBluetooth = "false"
}
मेरी जावा कोड में उपयोग का उदाहरण
./gradlew iDebug noFakeBluetooth
और
./gradlew iDebug
समस्या: दोनों मामलों में नकली ब्लूटूथ का मान हमेशा "सत्य" होता है (cmd लाइन में "नोफैकब्लूटूथ" के साथ या बिना)।
धन्यवाद यह क्या मैं – psv