admin管理员组文章数量:1414947
I'm trying to use VSCode to create an android application using gradle 8.12.1 and jdk 23.0.1 but I got the following problem:
MainActivity.java is not on the classpath of project app, only syntax errors are reported
The Gradle for Java Plugin says:
Class References There are cases where Gradle tasks will generate Java classes. To ensure these Java classes > are indexed correctly by the Java language server, you need to ensure the paths are added to > the .classpath, and this is typically achieved using Gradle sourceSets.
Once you've configured your sourceSets correctly, follow these steps:
Generate your classes by running the relevant Gradle Task Force the Language Server to index the generated classes by right-clicking on build.gradle and selecting Update project configuration. At this point the Gradle sourceSet paths will be added to the .classpath and the Language Server will automatically update references when those classes change.
sourceSets
are configurated on build.gradle
inside android{}
in app dir.
sourceSets {
// Código principal
main {
// Códigos em java
java {
srcDir 'src/main/java' // declaração explicita do diretório java
}
// Recursos do código
res {
srcDir 'src/main/resources' // androidx entende "res", porém o gradle cria "resources"
}
}
// Códigos de teste
test {
// Códigos em java dos testes
java {
srcDir 'src/test/java' // declaração explicita do diretório java
}
// Recursos dod códigos de teste
res {
srcDir 'src/test/resources' // androidx entende "res", porém o gradle cria "resoures"
}
}
}
There is no "Update project configuration" when I righ-click build.gradle in app dir.
optionsBuildGradle
本文标签: javaConfigure Classpath in VSCode for Android with GradleStack Overflow
版权声明:本文标题:java - Configure Classpath in VSCode for Android with Gradle - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745171501a2646002.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论