Android 4.4上的OneSignal崩溃

时间:2019-04-02 09:20:25

标签: android unity3d gradle onesignal multidex

我将OneSignal集成到Unity中并将其构建到Android平台中。我在Crashlytics中收到一些有关OneSignal的崩溃日志。我做了一些研究,发现此错误是在OS 4.4中触发的。我的应用有两个人触发它,他们正在使用OS 4.4设备。我看到一些参考,他们说我需要启用multiDex选项。但是我已经启用了它。所以我不知道如何解决它。有人知道如何解决吗?谢谢。

下面是我在Crashlytics中收到的崩溃日志。

Caused by java.lang.VerifyError: com/onesignal/LocationGMS
       at com.onesignal.OneSignal.onAppLostFocus(OneSignal.java:1062)
       at com.onesignal.ActivityLifecycleHandler$AppFocusRunnable.run(ActivityLifecycleHandler.java:171)
       at android.os.Handler.handleCallback(Handler.java:733)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:136)
       at android.os.HandlerThread.run(HandlerThread.java:61)

这是我的礼物

// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0'
    }
}

allprojects {
   repositories {
      flatDir {
        dirs 'libs'
      }
   }
}

apply plugin: 'com.android.application'

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:multidex:1.0.1'
    compile project(':fabric-init')
    compile project(':fabric')
    compile project(':crashlytics')
    compile project(':crashlytics-wrapper')
    compile project(':answers')
    compile project(':beta')
    compile project(':OneSignalConfig')
    compile project(':SuperAwesome_lib')
    compile project(':unity-android-resources')
    compile files('libs/unity-classes.jar')
    compile(name: 'common', ext: 'aar')
    compile(name: 'GoogleAIDL', ext: 'aar')
    compile(name: 'GooglePlay', ext: 'aar')
    compile(name: 'Helpshift', ext: 'aar')
    compile(name: 'com.android.support.animated-vector-drawable-27.1.1', ext: 'aar')
    compile(name: 'com.android.support.appcompat-v7-27.1.1', ext: 'aar')
    compile(name: 'com.android.support.cardview-v7-27.1.1', ext: 'aar')
    compile(name: 'com.android.support.customtabs-27.1.1', ext: 'aar')
    compile(name: 'com.android.support.design-27.1.1', ext: 'aar')
    compile(name: 'com.android.support.recyclerview-v7-27.1.1', ext: 'aar')
    compile(name: 'com.android.support.support-compat-27.1.1', ext: 'aar')
    compile(name: 'com.android.support.support-core-ui-27.1.1', ext: 'aar')
    compile(name: 'com.android.support.support-core-utils-27.1.1', ext: 'aar')
    compile(name: 'com.android.support.support-fragment-27.1.1', ext: 'aar')
    compile(name: 'com.android.support.support-media-compat-27.1.1', ext: 'aar')
    compile(name: 'com.android.support.support-v4-27.1.1', ext: 'aar')
    compile(name: 'com.android.support.support-vector-drawable-27.1.1', ext: 'aar')
    compile(name: 'com.android.support.transition-27.1.1', ext: 'aar')
    compile(name: 'android.arch.core.runtime-1.1.0', ext: 'aar')
    compile(name: 'android.arch.lifecycle.livedata-core-1.1.0', ext: 'aar')
    compile(name: 'android.arch.lifecycle.runtime-1.1.0', ext: 'aar')
    compile(name: 'android.arch.lifecycle.viewmodel-1.1.0', ext: 'aar')
    compile(name: 'UnityAds', ext: 'aar')
    compile(name: 'com.google.firebase.firebase-iid-12.0.1', ext: 'aar')
    compile(name: 'installreferrer-1.0', ext: 'aar')
    compile(name: 'onesignal-unity', ext: 'aar')
    compile(name: 'com.google.android.gms.play-services-iid-12.0.1', ext: 'aar')
}

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.1'

    defaultConfig {
        targetSdkVersion 26
        applicationId 'com.xxxxx.xxxxx'
        multiDexEnabled true
        versionCode 41
        versionName "1.0.30"
        minSdkVersion 16
    }

    lintOptions {
        abortOnError false
    }

    aaptOptions {
        noCompress '.unity3d', '.ress', '.resource', '.obb'
    }

    dexOptions{
        javaMaxHeapSize "2g"
    }

    buildTypes {
            debug {
                jniDebuggable true
            }
            release {
                // Set minifyEnabled to true if you want to run ProGuard on your project
                // minifyEnabled true
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'
                signingConfig signingConfigs.release
            }
        }
}

1 个答案:

答案 0 :(得分:0)

设置multidex的步骤很多,您可能错过了一个重要的步骤,这是由于您在{{1}中的android:name标签中看到的<application>错误}

AndroidManifest.xml

下面有详细的指南,我建议您仔细阅读以确保在Unity项目中使用multiDex正确设置了所有设置 https://appmediation.com/unity-enable-multidex/