CastleLab / COMP3021-2021Fall-PA1-Student-Version

HKUST - COMP3021 - 2021Fall - Programming Assignment 1 - Student Version.
0 stars 2 forks source link

some workarounds for tons of problems after importing the project #2

Open chanjeff2 opened 2 years ago

chanjeff2 commented 2 years ago

if there is any better solution, please let me know

1. classnotfoundexception/cannot find declaration to go to

image

mark .../src/main/java as Sources Root

2. Gradle not linked to project/cannot resolve org.jetbrains.annotations

image

click "Load Script Configuration" (or whatever there) on the blue alert message "bar".

if there are multiple "bars", just click them all.

3. output path not specified

image

goto File/Project Structure

Module not specified/"cross" on Main

image

open "Edit Configuration"

image

set "Use Classpath of module" to ...app.main

Derppening commented 2 years ago

Thanks for sharing your solutions. However, there are really only 2 things that you need to do:

  1. Check whether your project's Gradle is linked.

    Go to settings.gradle.kts, and there is a blue bar saying "Code insight unavailable (related Gradle project not linked)", click on "Link Gradle Project" at the other side of the bar.

image

Press "Trust Project" if it prompts whether you want to trust the Gradle project.

  1. Reload the Gradle project.

    Go to the Gradle panel (either at your right hand side, or View > Tool Windows > Gradle), and click the refresh button (top-left corner of the panel, looks like a reload button).

image

After that, your project should be successfully linked to Gradle.

You may also check whether the Gradle settings of IntelliJ is configured properly by going to File > Settings and navigating to Build, Execution, Deployment > Build Tools > Gradle and check the following items:

image