在真实设备上(Nexus 5,Leeco,Xiaomi,…).observe方法有效,但是当我在Firebase测试实验室中开始测试时,应用程序在许多设备上以异常启动时崩溃(例如,具有22 API的虚拟Nexus 10) ):
java.lang.RuntimeException: Unable to start activity ComponentInfo ...Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'androID.arch.lifecycle.lifecycle$State androID.arch.lifecycle.lifecycle.getCurrentState()' on a null object reference at androID.arch.lifecycle.liveData.observe(liveData.java:188)
在活动中:
public class ActivityCabinet extends AppCompatActivity { @OverrIDe protected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_cabinet); vmCabinet = viewmodelProvIDers.of(this).get(VmActivityCabinet.class); vmCabinet.enumSIDeNavigationMode.setValue(EnumSIDeNavigationMode.MAIN_List); // crash happens here in Test Lab vmCabinet.enumSIDeNavigationMode.observe(this, enumSIDeNavigationMode -> { ... } }}
在gradle中:
dependencIEs {implementation filetree(include: ['*.jar'], dir: 'libs')implementation 'com.androID.support:appcompat-v7:27.0.0'implementation 'com.androID.support:customtabs:27.0.0'implementation 'com.androID.support:cardvIEw-v7:27.0.0'implementation 'com.androID.support:recyclervIEw-v7:27.0.0'implementation 'com.androID.support:design:27.0.0'implementation 'com.androID.support:support-v4:27.0.0'implementation 'com.androID.support:Transition:27.0.0'implementation 'com.androID.support.constraint:constraint-layout:1.0.2'implementation 'androID.arch.lifecycle:extensions:1.0.0-rc1'implementation 'androID.arch.persistence.room:runtime:1.0.0-rc1'annotationProcessor "androID.arch.persistence.room:compiler:1.0.0-rc1"implementation 'com.androID.support:multIDex:1.0.2'implementation 'me.relex:circleindicator:1.2.2@aar'implementation 'com.Google.androID.exoplayer:exoplayer:r2.5.0-beta1'implementation 'com.Google.code.gson:gson:2.8.0'implementation 'com.squareup.retrofit2:retrofit:2.3.0'implementation 'com.squareup.retrofit2:converter-scalars:2.3.0'implementation 'com.squareup.retrofit2:converter-gson:2.3.0'implementation 'com.squareup.okhttp3:logging-interceptor:3.8.1'implementation 'com.squareup.picasso:picasso:2.5.2'implementation 'com.thoughtbot:expandablerecyclervIEw:1.3'implementation 'com.facebook.androID:facebook-android-sdk:4.25.0'implementation 'com.appsflyer:af-androID-sdk:4.8.3@aar'implementation 'com.Google.firebase:firebase-core:11.4.2'implementation 'com.Google.androID.gms:play-services-ads:11.4.2'implementation('com.crashlytics.sdk.androID:crashlytics:2.7.1@aar') { transitive = true}}apply plugin: 'com.Google.gms.Google-services'
主要的
buildscript { repositorIEs { Google() jcenter() mavenLocal() mavenCentral() maven { url 'https://maven.Google.com' } maven { url 'https://maven.fabric.io/public'} maven { url 'https://oss.sonatype.org/content/repositorIEs/snapshots'} } dependencIEs { classpath 'com.androID.tools.build:gradle:3.1.0-Alpha01' classpath 'com.Google.gms:Google-services:3.1.1' classpath 'io.fabric.tools:gradle:1.24.1' }}allprojects { repositorIEs { Google() jcenter() mavenLocal() mavenCentral() maven { url 'https://maven.fabric.io/public'} maven { url 'https://oss.sonatype.org/content/repositorIEs/snapshots'} maven { url "https://maven.Google.com"} }}
我无法理解测试实验室中设备异常的原因.
解决方法:
同样在这里.互联网上会显示多个报告.似乎是在10月27日左右开始的.我通过选择退出Google Play控制台中的新功能“发布前报告版本”(发布管理 – > Pre laucnh报告 – >设置 – >发布前报告版本)解决了这个问题
总结以上是内存溢出为你收集整理的尝试在Firebase测试实验室中调用虚拟方法android.arch.lifecycle.Lifecycle全部内容,希望文章能够帮你解决尝试在Firebase测试实验室中调用虚拟方法android.arch.lifecycle.Lifecycle所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)