I launched the Android TV app on real device and emulator but I didn’t get any error
When I make a new release and got a message ‘Crashing after launch’, i fixed it many times and got same message and rejected status.
Here is mail content from goolge, i don’t know how to fix it!
`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.`
I wrote class to log error message to remote and crashHanlder wasn’t hit
I put crashHandler code in launcher activity
public class TvActivity extends FragmentActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tv);
Thread.setDefaultUncaughtExceptionHandler(new CrashHandler());
...do stuff
}
}
public class CrashHandler implements UncaughtExceptionHandler {
private static final String TAG = "CrashHandler";
private boolean _enableRemoteLog = true;
private UncaughtExceptionHandler defaultUEH;
public TKCrashHandler() {
this.defaultUEH = Thread.getDefaultUncaughtExceptionHandler();
}
@Override
public void uncaughtException(Thread thread, Throwable ex) {
final Writer result = new StringWriter();
final PrintWriter printWriter = new PrintWriter(result);
// Inject some info about android version and the device, since google can't provide them in the developer console
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 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>