Ever since I upgraded to gradle 3.0 our main Application
's onCreate is not firing from a production-flavour app. When building for our staging flavour however, the Application's onCreate is called just fine.
Since the Application's onCreate is never called, our Realm
is never initialized, and the app crashes when trying to access Realm
later.
AndroidManifest.xml:
<application
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
....
App.kt:
class App : Application() {
override fun onCreate() {
super.onCreate()
Realm.init(this)
println("This is never called")
}
}
build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'realm-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.github.triplet.play'
....
android {
flavorDimensions "testing"
productFlavors {
production {
dimension "testing"
applicationId "com.imerso.app"
}
staging {
dimension "testing"
applicationId "com.imerso.app.staging"
externalNativeBuild {
cmake {
targets 'cpp_scan_app', 'unittests'
}
}
}
}
compileSdkVersion 25
buildToolsVersion '26.0.2'
dexOptions {
// Sets the maximum number of DEX processes
// that can be started concurrently.
maxProcessCount 8
// Sets the maximum memory allocation pool size
// for the dex operation.
javaMaxHeapSize "2g"
....
not sure if our change to gradle 3.0 is the culprit here, but everything worked fine until I did the upgrade.