I was setting up a java/kotlin library for my android project in which i was creating a data class (model) with moshi converter. But the issue is the annotation @JsonClass and at other places i am getting this error
Cannot access class ‘java.lang.String’. Check your module classpath for missing or conflicting dependencies
The Data class
The data class image
The error shown by IDE
The library gradle code
plugins {
id 'java-library'
id 'kotlin'
id 'kotlin-kapt'
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation "com.squareup.retrofit2:converter-moshi:2.9.0"
implementation "com.squareup.moshi:moshi:1.12.0"
kapt "com.squareup.moshi:moshi-kotlin-codegen:1.12.0"
}
And the app level build.gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
compose_version = '1.1.0-alpha01'
kotlin_version = '1.5.21'
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app level gradle code
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdk 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.composeappname"
minSdk 23
targetSdk 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.tests.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '1.8'
useIR = true
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion compose_version
kotlinCompilerVersion '1.4.32'
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.3.1'
implementation project(":libmynetworklibrary")
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.tests.ext:junit:1.1.3'
androidTestImplementation 'androidx.tests.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.compose.ui:ui-tests-junit4:$compose_version"
}
**EDIT: solved.**
Apprently my project structure -> platform settings -> sdk -> 11 was pointing to some non-existent jdk 11 in the intellij install directory. Not sure why that wasn’t showing an error. The fix was I edited that setting to point to my local install jdk 11.
So I’m having a strange issue I can’t seem to find a solution for. I have created a small spring boot project using the built in spring initializer in intellij, i chose kotlin and java 11. My build.gradle.kts is setup for java 11 as well.
I can build and run my project just fine. But intellij is showing errors all over my source files. It seems as though intellij itself is confused. It is saying things like: «Cannot access java.lang.String. Check your module classpath for missing of conflicting dependencies»
In file -> project structure -> project -> project sdk: i have java 11 selected (my installed version)
And here is my build.gradle.kts:
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "2.2.0.RELEASE"
id("io.spring.dependency-management") version "1.0.8.RELEASE"
kotlin("jvm") version "1.3.50"
kotlin("plugin.spring") version "1.3.50"
}
group = "com.youwish"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_11
val developmentOnly by configurations.creating
configurations {
runtimeClasspath {
extendsFrom(developmentOnly)
}
}
repositories {
mavenCentral()
maven(url = "http://oss.jfrog.org/artifactory/oss-snapshot-local/")
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
implementation("io.springfox:springfox-swagger2:3.0.0-SNAPSHOT")
implementation("io.springfox:springfox-swagger-ui:3.0.0-SNAPSHOT")
implementation("io.springfox:springfox-spring-webflux:3.0.0-SNAPSHOT")
developmentOnly("org.springframework.boot:spring-boot-devtools")
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
}
testImplementation("io.projectreactor:reactor-test")
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "11"
}
}

cannot resolve method ‘getParameter(java.lang.String)’
Вы столкнулись с этой проблемой?
Изначально использовал Myeclipse, позже перешел на IDEA, различные проблемы не решаются, эта проблема одна из них.
У него также есть проблема с братом:
cannot resolve method ‘println(java.lang.String)’

Рисунок выше — это скриншот кода после решения.
Решение:
1. Очистите кеш
Нажмите «Файл» в верхнем левом углу —-> «Недействительные кеши / перезагрузка».

В появившемся диалоговом окне нажмите «Invalidate».

Если этот метод не работает, обратитесь ко второму способу.
2. Добавьте кота
Нажмите «Файл» в верхнем левом углу ——> Структура проекта

В новом диалоговом окне нажмите «Модули» —-> «+» —-> «Библиотека или зависимость модуля ..»

Появится диалоговое окно, выберите кот ——> нажмите «Добавить выбранное».

Нажмите «Применить» —-> «ОК»

3. Альтернативный метод
Если вы не можете решить эту проблему, попробуйте вернуться к методу 1: «Файл» —-> «Недействительный кеш / перезапуск» —-> во всплывающем диалоговом окне нажмите «Недействительность и перезапуск».

Хорошо, на данный момент моя проблема решена.
заметка:
Операционная система: win7
JDK:1.6
tomcat:1.7
Браузер: Charm
Инструмент программирования: IDEA
Срок решения: два дня
Решение: сначала устраните проблему, чтобы найти причину, а затем слепо измените ее и продолжайте попытки и ошибки. В то же время браузер ищет похожие проблемы и, наконец, решает их.
Hmm.. I have some problems with this new quest system I coded for my RuneScape private server…
My compiler says this:
.palidino76rs2QuestsAfriendoftheKingdom.java:14: cannot find symbol
symbol : constructor Quests(palidino76.rs2.players.Player,java.lang.Integer)
location: class palidino76.rs2.Quests.Quests
super(owner, uid);
^
.palidino76rs2QuestsAfriendoftheKingdom.java:31: setFinalStage(int) in palid
ino76.rs2.Quests.Quests cannot be applied to (java.lang.String)
setFinalStage("7");//Final stage. "setFinalStage" is a string/void I created to
decide in which stage the quest ends.
^
Note: .palidino76rs2QuestsQuestloader.java uses unchecked or unsafe operatio
ns.
Note: Recompile with -Xlint:unchecked for details.
2 errors
Tryk på en vilkårlig tast for at fortsætte . . .
So as you see my errors is in my AfriendoftheKingdom file. (The name of the quest I want to create.)
And my Quest file..
So here is my AfriendoftheKingdom program.
package palidino76.rs2.Quests;
import palidino76.rs2.players.*;
import java.io.*;
import palidino76.rs2.net.SocketListener;
import palidino76.rs2.util.*;
import palidino76.rs2.Server;
import palidino76.rs2.Engine;
import palidino76.rs2.io.*;
public abstract class AfriendoftheKingdom extends Quests {
public AfriendoftheKingdom(Player owner, Integer uid) {
super(owner, uid);
}
protected String name = "A friend of the Kingdom.";
protected int uid = 10;
protected int stage = -1;
protected int finalStage = 7;
/**
*A public void made to define the quest name, and in which stage it ends.
*/
public void define()
{
setName("A knight of Vimsie");//Quest name. "setName" is a string I created to set the name of the quest.
setFinalStage("7");//Final stage. "setFinalStage" is a string/void I created to decide in which stage the quest ends.
}
/**
*This method will be used when the public final int getFinalStage is met.
*Which in this case is 7.
*/
public void completeQuest(Player p)
{
/**
*The Engine shortcut that will be called below here, will be the reward when the quest is completed.
*/
Engine.playerItems.addItem(p, 995, 1000);
sleep(2500);//Like the public void process delays something with 600 milliseconds, this statement (sleep) will delay something with the milliseconds entered in the ().
p.frames.sendMessage(p, "You have completed " + getName() + "and are now a friend of the Kingdom!");
p.frames.sendMessage(p, "@[email protected] You just gained 1 quest point.");
}
}
My compiler says the error is in this line.
super(owner, uid);
and heres the public the super(owner, uid); thing belongs to.
public AfriendoftheKingdom(Player owner, Integer uid) {
super(owner, uid);
}
So that is the cannot find symbol error..
And here is my Quest file where the cannot find symbol (java.lang.String) error is located…
package palidino76.rs2.Quests;
import java.io.*;
import palidino76.rs2.net.SocketListener;
import palidino76.rs2.players.PlayerSave;
import palidino76.rs2.util.Misc;
public abstract class Quests {
// The name of this quest.
protected String name = "";
// The unique ID of this quest (MUST BE UNIQUE!!!)
protected int uid = -1;
// The current 'stage' of this quest.
protected int stage = -1;
// The stage that this quest finishes at.
protected int finalStage = -1;
public abstract void define();
public abstract void completeQuest();
/**
* @return The unique ID of this quest.
*/
public final int getUID()
{
return uid;
}
/**
* Changes the current stage of this quest.
*/
public final void setStage(int stage)
{
this.stage = stage;
if(stage == finalStage)
completeQuest();
if(stage != 1)
System.out.println("Successfully saved quest (stage = " + stage + ").");
}
/**
* Sets the final stage of this quest.
*/
public final void setFinalStage(int stage)
{
this.finalStage = stage;
}
/**
* @return This quest's finishing stage.
*/
public final int getFinalStage()
{
return finalStage;
}
/**
* @return If this quest has been completed.
*/
public final boolean completed()
{
return stage == finalStage;
}
/**
* @return This quest's current stage.
*/
public final int getStage()
{
return stage;
}
/**
* Changes the name of this quest.
*/
public final void setName(String name)
{
this.name = name;
}
public final boolean questStarted()
{
return stage != -1;
}
/**
* @return This quest's name.
*/
public final String getName()
{
return name;
}
/**
* Pauses the current thread.
*/
public final void sleep(long ms)
{
try { Thread.sleep(ms); } catch(InterruptedException ie){}
}
}
That’s the Quest program, I do know what creates this cannot be applied to (java.lang.String) error..
The problem is this line
setFinalStage("7");//Final stage. "setFinalStage" is a void I created to decide in which stage the quest ends.
in my AfriendoftheKingdom program..
But I know what the deal is..
It is the public void setFinalStage(int stage)
{
in my Quest program.. My compiler says that
setFinalStage("7");
cannot be called by a public void, but it needs to be called by a String and not a void..
But that’s where my question comes..
How can it be that this line
setName("A knight of Vimsie");
in AfriendoftheKingdom, can be called by a public void then setFinalStage(«7»); can’t when the public voids in the Quest program is almost the same?????
Here’s the setFinalStage void from the Quest program..
/**
* Sets the final stage of this quest.
*/
public final void setFinalStage(int stage)
{
this.finalStage = stage;
}
And here’s the setName void from the Quest program…
/**
* Changes the name of this quest.
*/
public final void setName(String name)
{
this.name = name;
}
Please answer soon..
.
мне нужна помощь с проектом android внутри NetBeans. Я только что открыл проект, который создан в NetBeans, и у меня есть некоторые проблемы с «не удается получить доступ к java.ленг
Неустранимая ошибка: не удается найти пакет java.lang в пути к классам или bootclasspath»
Это образец одного моего файла, у которого есть проблемы:
package Helpers;
import PreglednikLogika.Clanak;
import android.content.Context;
первая строка package Helpers; подчеркивается и производит "cannot access java.lang
Fatal Error: Unable to find package java.lang in classpath or bootclasspath"
Я новичок в netbeans, и я попробовал некоторые исправления, но не успех. Кто-нибудь может мне помочь ? Я думаю, это добавляет справочную библиотеку или что-то в этом роде… но не уверен.
2 ответов
проект имеет старую Точку доступа, в Netbeans:
- щелкните правой кнопкой мыши на проекте
- свойства
- библиотеки
- обновление «Java Platform»
не только для Android, это произошло со мной при попытке скомпилировать очень старый проект.
Я нашел в чем была проблема.
-
я обновил этот путь до моего правильного пути
sdk.dir=E:ANDROIDEclipse371android-sdkв файле проектаlocal.properties. -
Я
# Project target.target=android-8, к цели 8 у меня было 7 до этого, очевидно, не поддерживается в этой версии SDK.
и я успешно строю свой проект:)