Android Studio could not find or load main class of “Scratch” file

孤人 提交于 2019-12-04 01:38:16

Update

I just noticed that this issue was fixed in Android Studio 3.5!


The only way I got this to work (in Android Studio 3.4.1) is this very dirty approach:

  1. Go to Run > Edit Configurations > Scratch
  2. In Before launch at the bottom add (+) Run External tool
  3. In External Tools popup press + and fill in the following Tool Settings

    Name: Compile Scratch

    Program: javac

    Arguments: $FileName$

    Working Directory: your scratch file directory

  4. Press OK
  5. Again in External Tools popup press + and fill in the following Tool Settings

    Name: Run Scratch

    Program: java

    Arguments: $FileClass$

    Working Directory: your scratch file directory

  6. Press OK and Apply in Run/Debug Configurations

Weirdly this works only if you use the green arrows beside the class/main declaration. If you use the Run button in the menu this also fails.

You will still get the not found error in the Scratch tab of the run window. But two additional tabs will pop up (one for each external tool). In the Run Scratch tab you will get your output.

I personally don't like this, But it's the best workaround I came up with.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!