codenameone / CodenameOne

Cross-platform framework for building truly native mobile apps with Java or Kotlin. Write Once Run Anywhere support for iOS, Android, Desktop & Web.
https://www.codenameone.com/
Other
1.71k stars 407 forks source link

Cannot Resolve when trying to load files #3718

Open Xzanderaven opened 1 year ago

Xzanderaven commented 1 year ago

Trying to load a bare-bones java app. Download, unzip, open in IntelliJ, tries to compile and I get two errors for "Cannot resolve file 'CodeNameOneBuildClient.jar'" and "Cannot resolve symbol 'cn1libs'". I don't know what I'm doing wrong or what I need to change. Also have this popping up if that makes a difference: "The imported module settings are stored in the internal storage due to the new fast Maven import. You can change that behavior in Maven Import Settings."

shai-almog commented 1 year ago

In this image https://user-images.githubusercontent.com/138056993/254923697-ec587def-3a69-4c8b-8a40-4c518f30f086.JPG

On the left side there's a button that will switch the error log to show you text. You need to do that and then move along the tree on the left to the root of the text which shows the entire log.

Then copy that text using ctrl-c and paste it as a source block here so it will be readable.

Xzanderaven commented 1 year ago

These are the two things on the left that I see. All the editor button does is open the pom file a second time. And the Structure and Bookmark just opens the whole file tree at the top. left side open editor structure

shai-almog commented 1 year ago

This is how it's supposed to look. Notice the tree on the left is clickable so I can see the build stages and select the top of the tree to see the entire text on the right.

Screenshot 2023-07-24 at 6 05 39
Xzanderaven commented 1 year ago

It will only let me build it, not run it. And that's what it gives me for a build. build no run

Eric-Chomba commented 1 year ago

It will only let me build it, not run it. And that's what it gives me for a build. build no run

Just to confirm if it's IDE problem, have you tried another IDE like netbeans?

shai-almog commented 1 year ago

That's a successful build. Open the run configuration combo box. What are the options there? (It's on the toolbar and say's "Current File" in your screenshot.

Xzanderaven commented 1 year ago

Just to confirm if it's IDE problem, have you tried another IDE like netbeans?

I tried Eclipse and it didn't work. It gave me an error that sent me here: https://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException I downloaded the generic 'other' file for cmd line and finally got that to work in IntelliJ and cmd line once I added the dropboxed file that Shai linked into the right folder. But the IntelliJ specific copy is still giving me trouble. That's the one I've been taking screenshots from.

Xzanderaven commented 1 year ago

That's a successful build. Open the run configuration combo box. What are the options there? (It's on the toolbar and say's "Current File" in your screenshot.

Current File and Edit Configurations. I manually added the CodeNameOne config to run the simulator and it would let me run it, but it threw this error and wouldn't open the simulator: Error running 'Run in Device Simulator': Cannot invoke "com.intellij.openapi.vfs.VirtualFile.getModificationStamp()" because "this.propsVF" is null

shai-almog commented 1 year ago

This is a problem with your IDE installation. This:

 Error running 'Run in Device Simulator': Cannot invoke "com.intellij.openapi.vfs.VirtualFile.getModificationStamp()" because "this.propsVF" is null

Should have an option to open an error dialog which will have an option to report the error but will also show a stack that might help me narrow it down.

This generally means the IDE can't access a file to get its modification date. That means something is broken with the IDE file access which corresponds to the problem you had with the jar file.

Xzanderaven commented 1 year ago

Can I just fix it by downloading a new copy of IntelliJ?

This is the stacktrace: java.lang.NullPointerException: Cannot invoke "com.intellij.openapi.vfs.VirtualFile.getModificationStamp()" because "this.propsVF" is null at com.codename1.plugin.intellij.run.CodenameOneRunConfiguration.refreshProps(CodenameOneRunConfiguration.java:107) at com.codename1.plugin.intellij.run.CodenameOneRunConfiguration.access$100(CodenameOneRunConfiguration.java:57) at com.codename1.plugin.intellij.run.CodenameOneRunConfiguration$1.createJavaParameters(CodenameOneRunConfiguration.java:185) at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:889) at com.intellij.openapi.application.ReadAction.compute(ReadAction.java:69) at com.intellij.execution.configurations.JavaCommandLineState.getJavaParameters(JavaCommandLineState.java:41) at com.intellij.execution.impl.DefaultJavaProgramRunner.patchJavaCommandLineParams(DefaultJavaProgramRunner.java:132) at com.intellij.execution.impl.DefaultJavaProgramRunner.lambda$doExecute$2(DefaultJavaProgramRunner.java:122) at com.intellij.execution.runners.JavaProgramPatcher.lambda$patchJavaCommandLineParamsUnderProgress$2(JavaProgramPatcher.java:41) at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:281) at com.intellij.openapi.progress.impl.CoreProgressManager.startTask(CoreProgressManager.java:429) at com.intellij.openapi.progress.impl.ProgressManagerImpl.startTask(ProgressManagerImpl.java:114) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressSynchronously$9(CoreProgressManager.java:513) at com.intellij.openapi.progress.impl.ProgressRunner.lambda$new$0(ProgressRunner.java:84) at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$3(ProgressRunner.java:252) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:186) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:604) at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:679) at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:635) at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:603) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60) at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:173) at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:252) at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699) at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699) at java.base/java.lang.Thread.run(Thread.java:833)

shai-almog commented 1 year ago

This is an exception from the plugin. We don't support that. This should be a Maven project from https://start.codenameone.com/

uninstall the plugin. It's meant fro legacy project support only.

Xzanderaven commented 1 year ago

I uninstalled the plugin and ran it as a maven project. The run was successful but the simulator window didn't pop up and the 'cn1libs' error is still there. run success run error

Xzanderaven commented 1 year ago

This is what happens with I run the cmd line download with or without the plugin in IntelliJ. cmd line simulator

shai-almog commented 1 year ago

In the IDE you picked the compile target instead of "Run Simulator" which would result in it running similarly to the way it runs in the command line.

Xzanderaven commented 1 year ago

I set up the exact same run settings as the cmd line one, and it gave me a CSS error: An error occurred while compiling the CSS files. Inputs: C:\Users\------\Downloads\MyApp\myapp\common\src\main\css\theme.css, output: C:\Users\------\Downloads\MyApp\myapp\common\target\classes\theme.res merge file: C:\Users\------\Downloads\MyApp\myapp\common\target\css\theme.css

shai-almog commented 1 year ago

I need to see the full error.

Xzanderaven commented 1 year ago

css error

shai-almog commented 1 year ago

You need to switch this to text mode. I think it's done with the eye icon on the left. That way the actual error is shown.

Xzanderaven commented 1 year ago

`"C:\Program Files\Java\jdk-17\bin\java.exe" -Dmaven.multiModuleProjectDirectory=C:\Users------\Downloads\MyApp\myapp -Djansi.passthrough=true -Dmaven.home=C:\Users------.m2\wrapper\dists\apache-maven-3.6.3-bin\1iopthnavndlasol9gbrbg6bf2\apache-maven-3.6.3 "-Dclassworlds.conf=C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.1.2\plugins\maven\lib\maven3\bin\m2.conf" "-Dmaven.ext.class.path=C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.1.2\plugins\maven\lib\maven-event-listener.jar" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.1.2\lib\idea_rt.jar=51841:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.1.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.1.2\plugins\maven\lib\maven3\boot\plexus-classworlds-2.6.0.jar;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.1.2\plugins\maven\lib\maven3\boot\plexus-classworlds.license" org.codehaus.classworlds.Launcher -Didea.version=2023.1.4 -DskipTests=true -Dcodename1.platform=javase verify -e -P idea-simulator [INFO] Error stacktraces are turned on. [INFO] Scanning for projects... [WARNING] [WARNING] Some problems were encountered while building the effective model for coderad.pack.trybare:myapp-javase:jar:1.0-SNAPSHOT [WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.codenameone:codenameone-core:jar -> duplicate declaration of version (?) @ line 60, column 19 [WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.codenameone:codenameone-javase:jar -> duplicate declaration of version (?) @ line 70, column 19 [WARNING] [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build. [WARNING] [WARNING] For this reason, future Maven versions might no longer support building such malformed projects. [WARNING] [INFO] ------------------------------------------------------------------------ [INFO] Reactor Build Order: [INFO] [INFO] myapp [pom] [INFO] myapp-common [jar] [INFO] myapp-javase [jar] [INFO] [INFO] ---------------------< coderad.pack.trybare:myapp >--------------------- [INFO] Building myapp 1.0-SNAPSHOT [1/3] [INFO] --------------------------------[ pom ]--------------------------------- [INFO] [INFO] -----------------< coderad.pack.trybare:myapp-common >------------------ [INFO] Building myapp-common 1.0-SNAPSHOT [2/3] [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-antrun-plugin:3.1.0:run (default) @ myapp-common --- [INFO] Executing tasks [INFO] [get] Destination already exists (skipping): C:\Users-------\UpdateCodenameOne.jar [INFO] [java] Update process in progress lock file exists at: C:\Users-------.codenameone\UpdateStatus.lock [INFO] Executed tasks [INFO] [INFO] --- properties-maven-plugin:1.0.0:read-project-properties (default) @ myapp-common --- [INFO] [INFO] --- codenameone-maven-plugin:7.0.86:generate-gui-sources (generate-gui-sources) @ myapp-common --- Generating GUI sources No GUI Entries available [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ myapp-common --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory C:\Users------\Downloads\MyApp\myapp\common\src\main\resources [INFO] [INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ myapp-common --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- codenameone-maven-plugin:7.0.86:compliance-check (cn1-process-classes) @ myapp-common --- [INFO] Running compliance check against Codename One Java Runtime API [INFO] See https://www.codenameone.com/javadoc/ for supported Classes and Methods [INFO] Sources haven't changed since the last compliance check. Skipping check [INFO] [INFO] --- codenameone-maven-plugin:7.0.86:css (cn1-process-classes) @ myapp-common --- [INFO] Error: Invalid or corrupt jarfile C:\Users--------.m2\repository\com\codenameone\codenameone-designer\7.0.86\codenameone-designer-7.0.86-jar-with-dependencies.jar-extracted\designer_1.jar [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary for myapp 1.0-SNAPSHOT: [INFO] [INFO] myapp .............................................. SUCCESS [ 0.199 s] [INFO] myapp-common ....................................... FAILURE [ 35.761 s] [INFO] myapp-javase ....................................... SKIPPED [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 37.177 s [INFO] Finished at: 2023-07-26T10:19:53-05:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal com.codenameone:codenameone-maven-plugin:7.0.86:css (cn1-process-classes) on project myapp-common: An error occurred while compiling the CSS files. Inputs: C:\Users-------\Downloads\MyApp\myapp\common\src\main\css\theme.css, output: C:\Users-----\Downloads\MyApp\myapp\common\target\classes\theme.res, merge file: C:\Users------\Downloads\MyApp\myapp\common\target\css\theme.css -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.codenameone:codenameone-maven-plugin:7.0.86:css (cn1-process-classes) on project myapp-common: An error occurred while compiling the CSS files. Inputs: C:\Users-------\Downloads\MyApp\myapp\common\src\main\css\theme.css, output: C:\Users-------\Downloads\MyApp\myapp\common\target\classes\theme.res, merge file: C:\Users------\Downloads\MyApp\myapp\common\target\css\theme.css at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289) at org.apache.maven.cli.MavenCli.main (MavenCli.java:193) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:568) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) at org.codehaus.classworlds.Launcher.main (Launcher.java:47) Caused by: org.apache.maven.plugin.MojoExecutionException: An error occurred while compiling the CSS files. Inputs: C:\Users-------\Downloads\MyApp\myapp\common\src\main\css\theme.css, output: C:\Users------\Downloads\MyApp\myapp\common\target\classes\theme.res, merge file: C:\Users-------\Downloads\MyApp\myapp\common\target\css\theme.css at com.codename1.maven.CompileCSSMojo.executeImpl (CompileCSSMojo.java:206) at com.codename1.maven.CompileCSSMojo.executeImpl (CompileCSSMojo.java:55) at com.codename1.maven.AbstractCN1Mojo.execute (AbstractCN1Mojo.java:195) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289) at org.apache.maven.cli.MavenCli.main (MavenCli.java:193) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:568) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) at org.codehaus.classworlds.Launcher.main (Launcher.java:47) [ERROR] [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn -rf :myapp-common

Process finished with exit code 1 `

shai-almog commented 1 year ago

Try running the following commands (obviously fix the home path):

cd C:\Users-------\.codenameone
java -Dcli=true -Dcef.dir=C:\Users-------\.codenameone\cef -jar designer_1.jar -css -input C:\Users-------\Downloads\MyApp\myapp\common\src\main\css\theme.css -output C:\Users------\Downloads\MyApp\myapp\common\target\classes\theme.res -merge C:\Users-------\Downloads\MyApp\myapp\common\target\css\theme.css

If it fails, what's the error?

Xzanderaven commented 1 year ago

Error: Unable to access jarfile designer_1.jar It's in C:\Users-------.m2\repository\com\codenameone\codenameone-designer\7.0.86\codenameone-designer-7.0.86-jar-with-dependencies.jar-extracted

shai-almog commented 1 year ago

It should also be there. Either way did you try running that command with the jar? Did that work?

Xzanderaven commented 1 year ago

The error at the top is the output I got from running that code in cmd line. But that's the only place I found the designer file. Where do I need to move or copy it or what do I need to do to make it accessible?

shai-almog commented 1 year ago

Delete the file C:\Users-------\.codenameone\UpdateStatus.lock. Then run update via maven mvn cn1:update or via the IDE. It should set up the designer in place. If you're behind a proxy or similar make sure to set it up globally for Java first.

ola-sk commented 1 year ago

The designer file is in C:\Users\-------\.codenameone\ directory for me. I too stumbled upon this error briefly once I started setting up the project, I have one request: make sure you “run in Simulator” as shannah mentioned in one of the comments:

When you say "tried to compile" can you describe your steps? Which build target? I would start by choosing the simulator build target and run that.

Trying to reproduce the error I removed directory C:\Users\-------\.codenameone\ from my system (I am on Windows 10), then I cleaned with maven clean and I "Run in Simulator" or maven compile both get rid of the error (meaning that resolves the file 'CodeNameOneBuildClient.jar' and the 'designer_1.jar') . I do not know if this helps in any way. Naturally replace the directory after C:\Users\... with the username you use on your system.

Also @Xzanderaven in your post from Jul 20 with screenshots it seems to me that you may be using java 17 since it is in your external libraries in IntelliJ. CodenameOne I believe supports Java 1.8 and for testing Java 11 in this project, and despite Java should be backwards compatible, sometimes compatibility may be a problem.