简体   繁体   English

从Google Play下载后,应用首次启动时会崩溃(ExceptionInInitializerError)

[英]App crash at first start after downloaded from Google play (ExceptionInInitializerError)

RN 0.55.4
Gradle: 2.2.3 

There is one issue on Android. Android上有一个问题。 We updated some node_modules and react native to version 0.55 and everything looks ok but when we release this new version into google beta and then we download it for testing the app always crash at first run. 我们更新了一些node_modules,并对0.55版做出了本机反应,一切看起来都还不错,但是当我们将此新版本发布到Google Beta中时,然后下载它进行测试,该应用始终在首次运行时崩溃。 And we run it once again and everything is ok app works fine. 我们再次运行它,一切正常,应用程序正常运行。 And we have no idea whats wrong Errors what we get from fabric.io and its happen only once when we download that app from play. 而且我们不知道出什么毛病了。从fabric.io得到的错误只有在从游戏中下载该应用程序时才会发生。

   Fatal Exception: java.lang.ExceptionInInitializerError
       at tv.dailyme.android.util.ServerConfig.getUrlRegisterWithoutPhonenr(Unknown Source)
       at tv.dailyme.android.util.UserRegistration.setInstallReferrer(Unknown Source)
       at tv.dailyme.android.core.receiver.InstallReceiver.onReceive(Unknown Source)
       at android.app.ActivityThread.handleReceiver(ActivityThread.java:3102)
       at android.app.ActivityThread.-wrap18(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1598)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:173)
       at android.app.ActivityThread.main(ActivityThread.java:6459)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:938)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:828)

and this happened too at same time 而且这也是同时发生的

Fatal Exception: java.lang.RuntimeException: Unable to start receiver tv.dailyme.android.core.receiver.Autostart: java.lang.NullPointerException: Attempt to invoke virtual method 'android.database.sqlite.SQLiteDatabase android.content.Context.openOrCreateDatabase(java.lang.String, int, android.database.sqlite.SQLiteDatabase$CursorFactory, android.database.DatabaseErrorHandler)' on a null object reference
       at android.app.ActivityThread.handleReceiver(ActivityThread.java:3116)
       at android.app.ActivityThread.-wrap18(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1598)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:173)
       at android.app.ActivityThread.main(ActivityThread.java:6459)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:938)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:828)

I think there is something wrong in our gradle settings 我认为我们的gradle设置有问题

    def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

// NOTE LSA: if you change this value, You will have to change same value in "Project: Awe" => build.gradle
def googlePlayServiceVersion  = '11.0.4'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.3"

    defaultConfig {
        applicationId "com.awesome.app"
        minSdkVersion 17
        targetSdkVersion 25
        versionCode 1007138
        versionName "6.6.0"
        renderscriptTargetApi 23
        renderscriptSupportModeEnabled true
        jackOptions {
            enabled true
        }
        vectorDrawables.useSupportLibrary = true
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
        multiDexEnabled true
        manifestPlaceholders = [manifestApplicationId: "${applicationId}",
                                onesignal_app_id: "7xxxxxxxxxxxxxxxxxxxDDc",
                                onesignal_google_project_number: "9999999999"]
    }
    compileOptions {
      sourceCompatibility JavaVersion.VERSION_1_8
      targetCompatibility JavaVersion.VERSION_1_8
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
    lintOptions {
        abortOnError false
    }
    signingConfigs {
        release {
            storeFile file(MYAPP_RELEASE_STORE_FILE)
            storePassword MYAPP_RELEASE_STORE_PASSWORD
            keyAlias MYAPP_RELEASE_KEY_ALIAS
            keyPassword MYAPP_RELEASE_KEY_PASSWORD
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {

        debug {
            manifestPlaceholders = [excludeSystemAlertWindowPermission: "false"]
        }

        release {
            manifestPlaceholders = [excludeSystemAlertWindowPermission: "true"]
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }

    }
    packagingOptions {
        exclude 'META-INF/license.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/notice.txt'
        exclude 'jsr305_annotations/Jsr305_annotations.gwt.xml'
        exclude 'META-INF/DEPENDENCIES'

        exclude 'error_prone/Annotations.gwt.xml'
        exclude 'third_party/java_src/error_prone/project/annotations/Annotations.gwt.xml'
        exclude 'third_party/java_src/error_prone/project/annotations/Google_internal.gwt.xml'
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a": 1, "x86": 2]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

repositories {
    jcenter()
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    compile project(':react-native-social-share')
    compile project(':react-native-device-info')
    compile project(':react-native-fetch-blob')
    compile project(':react-native-blur')
    compile project(':react-native-admob')
    compile project(':react-native-vector-icons')
    compile project(':react-native-orientation')
    compile project(':react-native-spinkit')
    compile project(':react-native-i18n')
    compile project(':react-native-share')
    compile project(':react-native-cookies')
    compile fileTree(dir: "libs", include: ["*.jar"])
    // TODO LSA when we upgrade RN to 0.56 and gradle 3 we will have to remove all FORCE = TRUE and update com.android.support libs
    compile "com.android.support:appcompat-v7:26.1.0"
    compile "com.android.support:palette-v7:26.1.0"
    compile("com.facebook.react:react-native:0.55.4") { force = true }

    compile project(':react-native-onesignal')

    compile 'tv.nexx:nexxplay-android:3.2.1'

    compile(name: 'library-release', ext: 'aar')

    compile('org.simpleframework:simple-xml:2.7.1') {
        exclude group: 'stax', module: 'stax-api'
        exclude group: 'xpp3', module: 'xpp3'
    }

    compile project(":react-native-device-info")
    compile fileTree(dir: "node_modules/react-native-device-info/android/libs", include: ["*.jar"])
    compile 'org.apache.mina:mina-statemachine:2.0.9'

    compile("com.google.android.gms:play-services-analytics:${googlePlayServiceVersion}") {
        force = true;
    }

    compile("com.google.android.gms:play-services-ads:${googlePlayServiceVersion}") {
        force = true;
    }

    compile("com.google.android.gms:play-services-gcm:${googlePlayServiceVersion}") {
        force = true;
    }

    compile("com.google.android.gms:play-services-location:${googlePlayServiceVersion}") {
        force = true;
    }

    compile("com.google.android.gms:play-services-base:${googlePlayServiceVersion}") {
        force = true;
    }

    compile(name: 'infonlinelib_1.1.5.1', ext: 'aar')
    compile(name: 'IRSurveyLib-1.4.0', ext:'aar')

    compile 'com.android.support:multidex:1.0.1'

    compile group: 'com.alibaba', name: 'fastjson', version: '1.1.25'
    compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
        transitive = true;
    }
    compile project(':react-native-fabric')
    compile 'com.alibaba:fastjson:1.1.25'
    compile 'com.adjust.sdk:adjust-android:4.7.0'
    compile 'ad.nugg.android:sdk:3.2.2'
}

Our ProGuard rules for app 我们针对应用的ProGuard规则

# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}

# Disabling obfuscation is useful if you collect stack traces from production crashes
# (unless you are using a system that supports de-obfuscate the stack traces).
-dontobfuscate

# React Native

# Keep our interfaces so they can be used by other ProGuard rules.
# See http://sourceforge.net/p/proguard/bugs/466/
-keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip
-keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters
-keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip

# Do not strip any method/class that is annotated with @DoNotStrip
-keep @com.facebook.proguard.annotations.DoNotStrip class *
-keep @com.facebook.common.internal.DoNotStrip class *
-keepclassmembers class * {
    @com.facebook.proguard.annotations.DoNotStrip *;
    @com.facebook.common.internal.DoNotStrip *;
}

-keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * {
  void set*(***);
  *** get*();
}

-keep class * extends com.facebook.react.bridge.JavaScriptModule { *; }
-keep class * extends com.facebook.react.bridge.NativeModule { *; }
-keepclassmembers,includedescriptorclasses class * { native <methods>; }
-keepclassmembers class *  { @com.facebook.react.uimanager.UIProp <fields>; }
-keepclassmembers class *  { @com.facebook.react.uimanager.annotations.ReactProp <methods>; }
-keepclassmembers class *  { @com.facebook.react.uimanager.annotations.ReactPropGroup <methods>; }

-dontwarn com.facebook.react.**

# TextLayoutBuilder uses a non-public Android constructor within StaticLayout.
# See libs/proxy/src/main/java/com/facebook/fbui/textlayoutbuilder/proxy for details.
-dontwarn android.text.StaticLayout

# okhttp

-keepattributes Signature
-keepattributes *Annotation*
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-dontwarn okhttp3.**

# okio

-keep class sun.misc.Unsafe { *; }
-dontwarn java.nio.file.*
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
-dontwarn okio.**


#GAID
-keep class * extends java.util.ListResourceBundle {
  protected Object[][] getContents();
}

-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
  public static final *** NULL;
}

-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
  @com.google.android.gms.common.annotation.KeepName *;
}

-keepnames class * implements android.os.Parcelable {
  public static final ** CREATOR;
}

-keepattributes EnclosingMethod
-keepattributes InnerClasses
-dontwarn InnerClasses
-dontoptimize
-keep class com.newrelic.** { *; }
-dontwarn com.newrelic.**
-keepattributes Exceptions, Signature, InnerClasses

Fatal Exception: java.lang.RuntimeException: Unable to start receiver tv.dailyme.android.core.receiver.Autostart: java.lang. 致命异常:java.lang.RuntimeException:无法启动接收器tv.dailyme.android.core.receiver.Autostart:java.lang。 NullPointerException : NullPointerException

Attempt to invoke virtual method 'android.database.sqlite.SQLiteDatabase android.content.Context. 尝试调用虚拟方法'android.database.sqlite.SQLiteDatabase android.content.Context。 openOrCreateDatabase (java.lang.String, int, android.database.sqlite.SQLiteDatabase$CursorFactory, android.database.DatabaseErrorHandler)' openOrCreateDatabase (java.lang.String,int,android.database.sqlite.SQLiteDatabase $ CursorFactory,android.database.DatabaseErrorHandler)'

on a null object reference 在空对象引用上

it appears, as if your ProGuard configuration might not suffice not to obfuscate something. 似乎您的ProGuard配置可能不足以混淆某些内容。

you could add a != null check into class tv.dailyme.android.core.receiver.Autostart , in order to at least not produce throw that NPE . 您可以在类tv.dailyme.android.core.receiver.Autostart添加!= null检查,以便至少不产生该NPE抛出。 improving the ProGuard -keep rules seems required. 完善的ProGuard -keep规则似乎需要。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 用户从 Google Play 下载时应用崩溃 - App crash with user downloaded from Google Play Android应用程序仅在首次打开后从Google Play下载时才会停留在启动画面上 - Android App Stuck on Splash Screen only after first open when downloaded from Google Play 从 Play 控制台安装应用程序后,Google Places API 崩溃 - Google Places API crash after installing app from play console cordova检测应用程序是否从Google Play下载 - cordova detect if app was downloaded from Google Play 如何知道该应用是从Google Play下载的? - How to know the app is downloaded from Google Play? 从 Google Play 下载时应用程序崩溃 - App crashes when downloaded from Google Play 从Play商店下载后,应用程序崩溃了吗? - App crashes after downloaded from Play Store? 即使不是使用Play应用下载的,Android也会将崩溃/冻结报告发送到Google的Play商店吗? - Does Android send crash/freeze reports to Google's Play Store even if the app was not downloaded using the Play app? 从Google Play下载应用后,如何自动提示用户进行操作? - How to automatically prompt the user for an action after app is downloaded from google play? 如果从Google Play下载应用,则android facebook登录将停止工作 - android facebook login stops working if app is downloaded from google play
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM