Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't resolve classpath for anything in app/src #3313

Closed
skylon07 opened this issue Sep 20, 2023 · 2 comments
Closed

Can't resolve classpath for anything in app/src #3313

skylon07 opened this issue Sep 20, 2023 · 2 comments

Comments

@skylon07
Copy link

skylon07 commented Sep 20, 2023

I have an android project I'm working on. For some reason, every .java file in app/src gives me this warning:
Screen Shot 2023-09-20 at 12 24 06

I've searched quite a bit online and have already tried things like:

  • "Java: Clean Java Language Server Workspace"
  • Modified .vscode/settings.json to include "app/src" in "java.project.sourcePaths"
  • Modifying "sourceSets.main.java.srcDirs" in root build.gradle

None of this has worked for me. Everything (in my actual project -- screenshot was from test project) builds/runs in Android Studio, so I'm fairly certain the gradle build files are set up correctly.

I'm not sure if this is necessarily an issue with the extension (probably just configuration -- I'm a gradle noob after all), but I've exhausted all the troubleshooting information I could find on this topic.

Environment
  • Operating System: macOS 12.6.8
  • JDK version: 20.0.2
  • Visual Studio Code version: 1.82.1
  • Java extension version: 1.22.1
Steps To Reproduce
  1. Create a new Android Project
  2. Convert the MainActivity.kt file to a java file
    package com.example.myapplication;
    
    // import android.os.Bundle
    import androidx.activity.ComponentActivity;
    // import androidx.activity.compose.setContent
    // import androidx.compose.foundation.layout.fillMaxSize
    // import androidx.compose.material3.MaterialTheme
    // import androidx.compose.material3.Surface
    // import androidx.compose.material3.Text
    // import androidx.compose.runtime.Composable
    // import androidx.compose.ui.Modifier
    // import androidx.compose.ui.tooling.preview.Preview
    // import com.example.myapplication.ui.theme.MyApplicationTheme
    
    class MainActivity extends ComponentActivity {
        // fun onCreate(savedInstanceState: Bundle?) {
        //     super.onCreate(savedInstanceState)
        //     setContent {
        //         MyApplicationTheme {
        //             // A surface container using the 'background' color from the theme
        //             Surface(
        //                 modifier = Modifier.fillMaxSize(),
        //                 color = MaterialTheme.colorScheme.background
        //             ) {
        //                 Greeting("Android")
        //             }
        //         }
        //     }
        // }
    }
    
  3. Observe the "...not on classpath..." warning

Test Project.zip

Current Result

The warning displays despite gradle being able to build it

Expected Result

Packages resolve correctly in app/src and this warning is not displayed

@skylon07 skylon07 changed the title Can't resolve app package for anything in app/src Can't resolve classpath for anything in app/src Sep 20, 2023
@skylon07
Copy link
Author

I see this is a duplicate of #396; closing this for reasons mentioned there...

@laheller
Copy link

I have the same problem. Sad that it's not working...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants