是否可以在 Chromebook 上开发和调试 android 应用程序?

Is it possible to both develop and debug android app's on a chromebook?

我正在使用面包丁在我的 Chromebook 上创建一个 linux 桌面。我在这里安装了 Android Studio 并开始开发一个简单的 android 应用程序。我可以构建一个 apk,将其移动到下载文件夹,然后从 linux 切换到 ChromeOS 和 运行 应用程序。 (我使用 APK 安装程序 - 工作正常)。

我希望能够从我的应用程序中看到 logcat(实际上我希望看​​到在 运行 中的模拟器中获得的所有诊断信息17=] Studio - 但我会满足于 logcat).

我读到的关于使用 adb 的所有内容都希望您拥有一台 Android Studio 所在的开发机器和一台 运行ning 您的应用程序所在的目标机器。使用 crouton,linux 桌面和 ChromeOS 在同一台机器上,并且一次只能 运行ning 一个,因为它们共享相同的资源等。 我尝试了一些应用程序,但 none 能够在 chromebook 上显示我的应用程序 运行ning 中的 logcat - 他们甚至不认识它是 运行ning。有人知道如何查看此特定设置的 logcat 吗?

到目前为止,我已经找到了获得 logcat 的方法,并且正在为此安顿下来......现在

在主ActivityonCreate中调用此方法;

    public static void saveLogcatToFile(Context context) {
            File outputFile = new File(context.getFilesDir(), "logcat.txt");

            try {
                @SuppressWarnings("unused")
                Process process = Runtime.getRuntime().exec("logcat -df " + outputFile.getAbsolutePath());
            } catch (IOException e) {...

在另一个 Activity 的 onCreate 中,使用 logcat 填充 TextView;

    public static String readLogcatFromFile(Context context) {
            File logFile = new File(context.getFilesDir(), "logcat.txt");
            if (logFile.exists() == false) { ...

            String logContents = context.getString(R.string.EMPTY_STRING);
            FileInputStream fileInStream = null;
            try {
                fileInStream = new FileInputStream(logFile);
                logContents = convertStreamToString(fileInStream);
            } catch (Exception e) { ...
            } finally { ...
                fileInStream.close();
            }
            return logContents;
    }

    private static String convertStreamToString(InputStream is) throws IOException {
            BufferedReader reader = new BufferedReader(new InputStreamReader(is));
            StringBuilder sb = new StringBuilder();
            String line = null;
            while ((line = reader.readLine()) != null) {
                sb.append(line).append("\n");
            }
            reader.close();
            return sb.toString();
    }

日志会为每个 运行 继续追加,直到您卸载(这会删除日志文件)。 我发现它在我破坏某些东西并且我的应用程序在启动时死机时特别有用,因为我可以恢复到之前的提交并查看日志以查看发生了什么