You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android TV应用发布后启动崩溃遭拒,CrashHandler未触发求助

Android TV应用发布后启动崩溃,CrashHandler未触发排查求助

问题背景

  • 本地真机和模拟器测试Android TV应用时无任何报错,但发布新版本后收到Google「启动后崩溃」的拒审提示,多次修复仍未通过
  • 自定义的CrashHandler类未触发,无法远程获取崩溃日志

Google拒审邮件内容

App Status: Rejected
Your app has been rejected and wasn't published due to the policy issue(s) listed below. If you submitted an update, the previous version of your app is still available on Google Play.

Issue found: Crashing after launch
Your app crashes after launch, which means we cannot review your app for Android TV inclusion. Please refer to our TV Activity documentation for details.

Issue details
We found an issue in the following area(s):
Version code 156: In-app experience

About the Android TV App Quality Guidelines
We do not accept apps into Android TV that don't adhere to Android TV App Quality Guidelines.

相关代码

启动Activity代码

// CrashHandler代码放在启动Activity中
public class TvActivity extends FragmentActivity {
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tv);

        Thread.setDefaultUncaughtExceptionHandler(new CrashHandler());

        // ...其他业务代码
    }
}

CrashHandler类实现代码

public class CrashHandler implements UncaughtExceptionHandler {

    private static final String TAG = "CrashHandler";
    private boolean _enableRemoteLog = true;

    private UncaughtExceptionHandler defaultUEH;

    public CrashHandler() {
        this.defaultUEH = Thread.getDefaultUncaughtExceptionHandler();
    }

    @Override
    public void uncaughtException(Thread thread, Throwable ex) {
        final Writer result = new StringWriter();
        final PrintWriter printWriter = new PrintWriter(result);

        // 注入设备和系统版本信息,补充开发者控制台缺失的内容
        StackTraceElement[] trace = ex.getStackTrace();
        StackTraceElement[] trace2 = new StackTraceElement[trace.length + 3];
        System.arraycopy(trace, 0, trace2, 0, trace.length);
        trace2[trace.length + 0] = new StackTraceElement("Android", "MODEL", android.os.Build.MODEL, -1);
        trace2[trace.length + 1] = new StackTraceElement("Android", "VERSION", android.os.Build.VERSION.RELEASE, -1);
        trace2[trace.length + 2] = new StackTraceElement("Android", "FINGERPRINT", android.os.Build.FINGERPRINT, -1);
        ex.setStackTrace(trace2);

        ex.printStackTrace(printWriter);
        String stacktrace = result.toString();
        printWriter.close();
        Log.e(TAG, stacktrace);

        if (_enableRemoteLog) {
            remoteLog(stacktrace);
        }

        defaultUEH.uncaughtException(thread, ex);
    }

    private void remoteLog(String content) {
        String url = "https://xxx/log?msg=" + content;
        LogHelper loader = new LogHelper();
        String[] args = new String[2];
        args[0] = url;
        args[1] = "90";
        loader.execute(args);
        Log.d(TAG, "remoteLog: " + content);
    }
}

Manifest中Activity配置

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="xxxx">
    <activity
        android:name=".ui.TvActivity"
        android:theme="@style/LightBgBrowse"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <action android:name="android.intent.action.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION"/>
            <action android:name="android.intent.action.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION"/>
            <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
        </intent-filter>
    </activity>
</manifest>

需要排查的问题

  1. 为什么应用在Google测试环境中启动后崩溃,但本地测试无问题?
  2. 自定义的CrashHandler为什么没有触发,无法捕获崩溃日志?

内容的提问来源于stack exchange,提问作者Hoa Tran

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 05:54:55