应用程序的onCreate不被调用生产版本

自从我升级到gradle 3.0以来,我们的主Application的onCreate不是从生产风味的应用程序发射。 然而,当为我们的分级风格建设,应用程序的onCreate被称为很好。

由于应用程序的onCreate永远不会被调用,所以我们的Realm永远不会被初始化,并且在稍后尝试访问Realm时应用程序会崩溃。

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" 

….

不知道我们对gradle 3.0的改变是不是罪魁祸首,但是一切正常,直到我升级。