Android 从Google play下载后首次启动时应用程序崩溃(InInitializeRerror除外)

Android 从Google play下载后首次启动时应用程序崩溃(InInitializeRerror除外),android,react-native,gradle,Android,React Native,Gradle,Android有一个问题。我们更新了一些node_模块,并对版本0.55进行了本地响应,一切看起来都正常,但当我们将这个新版本发布到google beta中,然后下载它进行测试时,应用程序总是在第一次运行时崩溃。我们再次运行它,一切正常,应用程序工作正常。我们不知道出了什么问题 我们从fabric.io获得的错误,当我们从play下载该应用程序时,它只会发生一次 RN 0.55.4 Gradle: 2.2.3 这也是同时发生的 Fatal Exception: java.lang.Ex

Android有一个问题。我们更新了一些node_模块,并对版本0.55进行了本地响应,一切看起来都正常,但当我们将这个新版本发布到google beta中,然后下载它进行测试时,应用程序总是在第一次运行时崩溃。我们再次运行它,一切正常,应用程序工作正常。我们不知道出了什么问题 我们从fabric.io获得的错误,当我们从play下载该应用程序时,它只会发生一次

RN 0.55.4
Gradle: 2.2.3 
这也是同时发生的

   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)
我认为我们的梯度设置有问题

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)
应用程序的ProGuard规则

    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'
}
#在此处添加特定于项目的程序规则。
#默认情况下,此文件中的标志附加到指定的标志
#在/usr/local/ceral/android sdk/24.3.3/tools/proguard/proguard-android.txt中
#您可以通过更改文件来编辑包含路径和顺序
#build.gradle中的指令。
#
#有关详细信息,请参阅
#   http://developer.android.com/guide/developing/tools/proguard.html
#在此处添加任何特定于项目的保留选项:
#如果您的项目使用带JS的WebView,请取消注释以下内容
#并为JavaScript接口指定完全限定的类名
#类别:
#-keepclassmembers类fqcn.of.javascript.interface.for.webview{
#公众*;
#}
#如果从生产崩溃中收集堆栈跟踪,则禁用模糊处理非常有用
#(除非您使用的是支持消除堆栈跟踪模糊的系统)。
-顿托夫斯卡特
#自然反应
#保留我们的接口,以便其他ProGuard规则可以使用它们。
#看http://sourceforge.net/p/proguard/bugs/466/
-保留,allowbFusion@interface com.facebook.proguard.annotations.DoNotStrip
-keep,allowFusion@interface com.facebook.proguard.annotations.KeepGetters和setters
-保留,allowbFusion@interface com.facebook.common.internal.DoNotStrip
#不要剥离任何用@DoNotStrip注释的方法/类
-保留@com.facebook.proguard.annotations.DoNotStrip类*
-保持@com.facebook.common.internal.DoNotStrip类*
-keepclassmembers类*{
@com.facebook.proguard.annotations.DoNotStrip*;
@com.facebook.common.internal.DoNotStrip*;
}
-keepclassmembers@com.facebook.proguard.annotations.KeepGettersAndSetters类*{
无效集*(***);
***得到*();
}
-keep class*扩展com.facebook.react.bridge.JavaScriptModule{*;}
-keep class*扩展com.facebook.react.bridge.NativeModule{*;}
-keepclassmembers,includedescriptorclasses类*{native;}
-keepclassmembers类*{@com.facebook.react.uimanager.UIProp;}
-keepclassmembers类*{@com.facebook.react.uimanager.annotations.ReactProp;}
-keepclassmembers类*{@com.facebook.react.uimanager.annotations.ReactPropGroup;}
-dontwarn com.facebook.react**
#TextLayoutBuilder在StaticLayout中使用非公共的Android构造函数。
#有关详细信息,请参见libs/proxy/src/main/java/com/facebook/fui/textlayoutbuilder/proxy。
-dontwarn android.text.StaticLayout
#okhttp
-保留署名
-keepattributes*注释*
-保持类okhttp3.*{*;}
-保持接口okhttp3.*{*;}
-dontwarn okhttp3**
#奥基奥
-保持类sun.misc.Unsafe{*;}
-dontwarn java.nio.file*
-dontwarn org.codehaus.mojo.animal_sniffer.ignorejrrequirement
-唐特沃恩·奥基奥**
#盖德
-keep class*扩展了java.util.ListResourceBundle{
受保护对象[][]getContents();
}
-保持公共类com.google.android.gms.common.internal.safeparcel.SafeParcelable{
公共静态最终***空;
}
-keepnames@com.google.android.gms.common.annotation.KeepName类*
-keepclassmembernames类*{
@com.google.android.gms.common.annotation.KeepName*;
}
-keepnames类*实现android.os.Parcelable{
公共静态最终**创建者;
}
-keepattributes封闭方法
-keepattributes内部类
-dontwarn内部类
-dontoptimize
-保持类com.newrelic.*{*;}
-dontwarn com.newrelic**
-keepattributes异常、签名、内部类
致命异常:java.lang.RuntimeException:无法启动receiver tv.dailyme.android.core.receiver.Autostart:java.lang.NullPointerException

尝试调用虚拟方法“android.database.sqlite.SQLiteDatabase android.content.Context.openOrCreateDatabase(java.lang.String,int,android.database.sqlite.SQLiteDatabase$CursorFactory,android.database.DatabaseErrorHandler)”

关于空对象引用

看起来,您的ProGuard配置可能不足以避免混淆某些内容


您可以添加一个
!=null
检查类
tv.dailyme.android.core.receiver.Autostart
,以便至少不产生该
NPE
的抛出。改进ProGuard
-似乎需要保留
规则。

我有点绝望:(@Lukᚊlek它读的是
-dontobfuscate
,因此这可能不是原因,但是,
上下文
.receiver.Autostart
中是
NULL
。为了解决这个问题,您必须使
发行版
可调试,并在该接收器中设置断点,以便了解
Context
NULL
getApplicationContext()
通常有效,其中
getContext()
失败。
# 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