After i added an Android library module in to my project, the app has stopped communicating with the API's and Android studio is completely frozen and unable to debug too so there is no error message.
I am guessing the way I have implemented the Build types and Product flavours in Library should be changed.
I am trying to run on StagingDebug build variant
This is how my app build.gradle looks like
buildTypes {
debug {
debuggable true
}
debugProxy {
initWith debug
buildConfigField "String", "LOCAL_DEV_PROXY_IP", "\"${getIP()}\""
buildConfigField "Integer", "LOCAL_DEV_PROXY_PORT", '8888'
buildConfigField "Boolean", "LOCAL_DEV_PROXY_ENABLED", 'true'
}
release {
debuggable false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
if (keystoreProperties) signingConfig signingConfigs.config
firebaseAppDistribution {
serviceCredentialsFile = rootProject.file("google-credentials.json").path
groups = "qa" // QA tester group defined in Firebase console
}
}
}
productFlavors {
dev { // local dev environment
dimension "environment"
applicationIdSuffix ".dev"
testApplicationId "com.xx.xx.dev.test"
versionName android.defaultConfig.versionName + "-dev"
buildConfigField "Boolean", "LOCAL_DEV_MODE_ENABLED", 'true'
}
dump { // local dev "dump" environment, for debugging with production database dumps
dimension "environment"
applicationIdSuffix ".dev"
testApplicationId "com.xx.xxx.dev.test"
versionName android.defaultConfig.versionName + "-dev-dump"
buildConfigField "Boolean", "LOCAL_DEV_MODE_ENABLED", 'true'
}
staging {
dimension "environment"
applicationIdSuffix ".staging"
testApplicationId "com.xx.xxx.staging.test"
versionName android.defaultConfig.versionName + "-staging"
}
qa {
dimension "environment"
applicationIdSuffix ".qa"
testApplicationId "com.xx.xxx.qa.test"
versionName android.defaultConfig.versionName + "-qa"
}
production {
dimension "environment"
}
}
Library only has build types
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debugProxy {
initWith debug
buildConfigField "String", "LOCAL_DEV_PROXY_IP", "\"${getIP()}\""
buildConfigField "Integer", "LOCAL_DEV_PROXY_PORT", '8888'
buildConfigField "Boolean", "LOCAL_DEV_PROXY_ENABLED", 'true'
}
}
How should Library buildTypes and productflavours be changed to.
Thanks
R
EDIT
`getIP` function is added into both app and library
/**
* Attempt to find local network address for use with web proxy
*
* Inspired/copied from: http://jeremie-martinez.com/2015/05/05/inject-host-gradle/
*
* @return String with IP address of local network address, or empty string if none found
*/
def getIP() {
// Print found local IP address fallback used if no network interface with valid address is found (useful for debugging)
// println("Local IP Address fallback will be: " + InetAddress.getLocalHost() != null ? InetAddress.getLocalHost().getHostAddress() : "unknown")
InetAddress result = null
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces()
while (interfaces.hasMoreElements()) {
NetworkInterface anInterface = interfaces.nextElement()
// println("Interface name: " + anInterface.displayName);
Enumeration<InetAddress> addresses = anInterface.getInetAddresses()
while ((anInterface.displayName.length() < 4 || anInterface.displayName.substring(0, 4) != "vbox") && addresses.hasMoreElements()) {
InetAddress address = addresses.nextElement()
// Print found IP addresses (useful for debugging)
// println("Possible IP Address discovered: " + address.getHostAddress())
// Ensure no loopback address gets used
if (!address.isLoopbackAddress()) {
// Try to use an IPv4 site local address, but not in the 172.x.x.x range (docker subnets)
if (address.isSiteLocalAddress() && address.getHostAddress().substring(0, 4) != "172.") {
println("IP Address of local machine found: " + address.getHostAddress())
return address.getHostAddress()
}
}
}
}
return result != null ? result.getHostAddress() : "" /*InetAddress.getLocalHost().getHostAddress()*/
}