Trinity CLI provides an easy way to run and debug your capsule from your development station.
Enter your capsule folder.
Make sure your phone and your computer are on the same network (ex: same wifi, same sub-network, no VPN).
Android specific:
Make sure the native elastOS browser is installed on your device.
Inside elastOS, go to the settings app and enable developer mode.
Run the following command:
# To deploy and run on android - check the CLI help for other options.
$ trinity-cli run -p android|ios --nodebug
What happens in background:
ionic serve
is called to start a simple server that the capsule will contact to get your capsule files.Note that if you’re running without --nodebug
as soon as your device stops being on the same network as your computer, or if the trinity-cli run
command is stopped, your capsule in
elastOS
will show a network error with an empty page.
On Android:
Open the Chrome browser on your computer and visit chrome://inspect
to inspect your capsule pages.
You need to be running a debug build of elastOS
and not the production builds or the version from Play Store suggested by some basic guides.
See: https://github.com/elastos/Elastos.Trinity/releases and get a daily .apk file.
adb logcat
to view the device logs for certain error messages.On iOS:
Open safari, development menu, find your device, and select then capsule in the list. Sometimes all capsules will look like “localhost”. In this case, while your capsule is running, move the mouse over each “localhost” entry and check when some blue overlay shows on your device. That will be the right item.
Safari doesn’t show logs history if you start the debug panel after starting your capsule. You can choose to restart your app manually using ctrl+r or cmd+r in the debugguer, to get all startup logs.
After your capsule is published, some users may face issues, including fatal exceptions, that you haven’t seen during development and tests.
We recommend integrating a tool like sentry.io to your capsule in order to get exception reports remotely and therefore being able to debug most of end users issues.
For our built-in apps at the Elastos foundation, we use the following error handler, that you can use as a reference if needed:
@Injectable()
export class SentryErrorHandler implements ErrorHandler {
constructor() {}
handleError(error) {
console.error("Globally catched exception:", error);
// Only send reports to sentry if we are not debugging.
if (document.URL.includes('localhost')) {
Sentry.captureException(error.originalError || error);
}
}
}