小编Dur*_*tel的帖子

带有 UncaughtExceptionHandler 的 Firebase Crashlytics

我已经集成了 Firebase Crashlytics 版本 2.9.1 来挖掘崩溃以涵盖我的应用程序的性能和稳定性。

如果应用程序有自己的 UncaughtExceptionHandler,则不会在 Firebase crashlytics 控制台上记录崩溃。

我的应用程序中有 BaseActivity。在 onCreate() 方法中,我根据项目要求注册了自定义 UncaughtExceptionHandler。

每当应用程序因任何原因崩溃时,都应将用户重定向到启动画面 ( MainActivity.java) 。

public class BaseActivity extends FragmentActivity{ 

@Override 
protected void onCreate(Bundle arg0) { 
   // Enable global crash handler. 
   Thread.setDefaultUncaughtExceptionHandler(handleAppCrash); 
} 

/*** 
* @Purpose Called when any crash occurs in the application. 
***/ 
private Thread.UncaughtExceptionHandler handleAppCrash = new Thread.UncaughtExceptionHandler() { 
@Override 
public void uncaughtException(Thread thread, Throwable ex) { 

   Intent intent = new Intent(context, MainActivity.class); //redirect to Splash screen
   intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
   context.startActivity(intent); 
   System.exit(0); 
  } …
Run Code Online (Sandbox Code Playgroud)

android firebase crashlytics

12
推荐指数
4
解决办法
3946
查看次数

Android 应用程序崩溃 okhttp3 HTTP FAILED:javax.net.ssl.SSLException:读取错误:系统调用期间出现 I/O 错误,软件导致连接中止

我正在研究 android 原生 kotlin 项目。
我正在使用Android 版本 10 的android real Oneplus 6设备测试应用程序。 请从 build.gradle 文件中找到以下详细信息,了解我用于项目的最新 okhttp 和改造依赖项。 好http

implementation "com.squareup.okhttp3:okhttp:4.9.0"
implementation "com.squareup.okhttp3:logging-interceptor:4.9.0"` 
Run Code Online (Sandbox Code Playgroud)

改造

implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
Run Code Online (Sandbox Code Playgroud)

我已经为 okhttpclient 设置了相关超时。

.connectTimeout(HTTP_CONNECT_TIMEOUT, TimeUnit.SECONDS)
.readTimeout(HTTP_READ_TIMEOUT, TimeUnit.SECONDS)
.writeTimeout(HTTP_WRITE_TIMEOUT, TimeUnit.SECONDS)
Run Code Online (Sandbox Code Playgroud)

我正在使用okhttp3.Interceptor。请在下面找到实现。

import okhttp3.Interceptor
import okhttp3.Request
import okhttp3.Response

class AuthorizationInterceptor(private val sharedPreferenceService: SharedPreferenceService) :
    Interceptor {

    override fun intercept(chain: Interceptor.Chain): Response {
        val requestBuilder = chain.request().newBuilder()
            .addHeader("Content-Type", "application/json")
            .addHeader("Accept", "application/json")

        return chain.proceed(requestBuilder.build())
    }
  }
Run Code Online (Sandbox Code Playgroud)

观察/问题

  1. 如果 API 调用正在进行中,并且我们尝试更改或禁用网络/互联网,则只要从上面的代码片段执行以下行,okhttp3 本身就会在内部崩溃,因此 App …

android interceptor kotlin okhttp retrofit2

7
推荐指数
1
解决办法
2213
查看次数

shadowOf()在Robolectric-3.0-rc3.jar中未定义

我正在使用Eclipse IDE与Robolectric单元测试用例框架(robolectric-3.0-rc3.jar)在android应用程序测试项目中编写单元测试用例.

MainActivity activity = Robolectric.setupActivity(MainActivity.class);
activity.findViewById(R.id.myvideoview).performClick();

Intent expectedIntent = new Intent(activity, CategoryActivity.class);
assertThat(shadowOf(activity).getNextStartedActivity()).isEqualTo(expectedIntent);
Run Code Online (Sandbox Code Playgroud)

android robolectric

5
推荐指数
1
解决办法
2382
查看次数