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."

Xzanderaven commented 1 year ago

Missed the plug-ins part. Oops.

shai-almog commented 1 year ago

If this happens you need to run the install-codenameone target as mentioned here: https://shannah.github.io/codenameone-maven-manual/#_install_codename_one_install_codenameone

Xzanderaven commented 1 year ago

It's not doing that. If there's a way to do it manually it's not making sense to me.

shai-almog commented 1 year ago

Can you provide a screenshot or ideally output from the maven console?

Xzanderaven commented 1 year ago

I try to build or run and just get this error: Could not find artifact com.codenameone:codenameone-buildclient:jar:8.0 at specified path C:\Users[Name]/.codenameone/CodeNameOneBuildClient.jar I don't know if that's what you're looking for. Very new to all this.

shai-almog commented 1 year ago

@shannah the install-codenameone target is missing from the generated start project in maven. I tried to run it manually and it seems that option is gone.

What's the current way to bootstrap a project?

shannah commented 1 year ago

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.

Xzanderaven commented 1 year ago

Compile's probably the wrong term. I basically opened the file and it immediately threw errors. I try to run or build it and get the one up there. I haven't built a server yet, just run it through the simulator. I can build a server and see if that fixes it. Edit: I get the same error trying to run it on an iOS server

shannah commented 1 year ago

Not sure what you mean by "build a server".

Can you provide a screenshot?

Xzanderaven commented 1 year ago

server I've tried running and building the code in the "Run in Simulator" and building a server for the iOS Debug and they both throw the not artifact error.

shannah commented 1 year ago

I see. "Build Server".

So you select "Run in Simulator" and press the "Run" button (green play icon), and it says " not an artifact"?

Could be a java version issue I suppose. If you can, use jdk11. You can specify this in module settings.

Xzanderaven commented 1 year ago

Wrong thing. So I'm looking for "11 - Local variable syntax for lambda parameters"? Changed it to that, same error.

Xzanderaven commented 1 year ago

I have it set to Oracle 17 for the SDK if that makes a difference.

shai-almog commented 1 year ago

We only support JDK 11 and 8 although that's a different error message typically.

@shannah I think the generated readme should be updated with some of these getting started problems.

Xzanderaven commented 1 year ago

I had it set to 8 and changed it to 11. Same error.

shai-almog commented 1 year ago

Can you include screenshots of what you're seeing. Which buttons you're pressing and where?

Xzanderaven commented 1 year ago

I can in the morning. I'm currently away from my computer. But I went to the project structure and changed it on the module tab. There was a myapp folder, a myapp-common, and a myapp-[forgot what the last one's called]. I changed it from 8 to 11 for all of them.

shai-almog commented 1 year ago

I meant how you run the target. It's ok tomorrow, we're here.

Xzanderaven commented 1 year ago

intellij Open IntelliJ, click on the top folder. open file This is the code that's immediately opened. The 8 errors show up with I have it set to JDK 11, only 2 show up when I have it set to JDK 8. issues The errors that appear on the pom file when I have JDK 8 enabled. error 1 error 2 Code block for both errors.

shai-almog commented 1 year ago

Is it possible your user name contains non-latin characters so selecting run in simulator might be failing because the download failed?

Xzanderaven commented 1 year ago

My computer username and my codename username are the same and all latin characters. Only thing that has non-Latin characters is the @ in my email. I've also downloaded it about 4 times various ways for both IntelliJ and Eclipse and neither works. They're both throwing the same errors.

Xzanderaven commented 1 year ago

I logged into the initalizr download (email is listed at the username here) to try and download a new copy of Java Bare-Bones and clicked on my profile in the top corner and got this page: no access

shai-almog commented 1 year ago

I'm stumped. Maybe @shannah has an idea.

Here's a temporary link you can use to download that file: https://www.dropbox.com/s/madepoyhzqtyets/CodeNameOneBuildClient.jar?dl=0

Place it under your home directory under .codenameone. At least it will get you past that error while we try to understand the root cause.

Xzanderaven commented 1 year ago

Ok. Thank you. I'll try that. I'm also trying to see if command line will work at all for me.

Xzanderaven commented 1 year ago

I dropped it in the right folder. It's there. But it's still throwing an error. client jar path not found

shai-almog commented 1 year ago

Is it possible there's a windows permissions problem that's preventing us from writing or reading to that directory?

Xzanderaven commented 1 year ago

There was a Windows security thing that popped up, but I thought I dismissed it as safe. I also set it to not ask again so I can dig around tomorrow and see if that's it.

Xzanderaven commented 1 year ago

So I looked and I can't find the original notification or a history of it but I think it was similar to this: https://youtrack.jetbrains.com/issue/IDEA-247817 I thought I allowed what I needed. It may be a bug on their end from what this is saying but I'll go through the settings and see if I can try to allow it or fix it there. I've allowed the files and I'm still getting the same errors plus this one now: 'dependencyManagement.dependencies.dependency.systemPath' for com.codenameone:codenameone-buildclient:jar refers to a non-existing file C:\Users[Name].codenameone\CodeNameOneBuildClient.jar

shai-almog commented 1 year ago

This is unrelated to IntelliJ. Go to the home directory using the Windows Explorer. Right click on the .codenameone directory and look in the settings. Make sure it allows universal reading and writing to this directory. Also check that when you run the build there are no hidden windows behind it or anything of that sort.

Xzanderaven commented 1 year ago

What do you mean by hidden windows?

shai-almog commented 1 year ago

Sometimes the IDE covers a permission dialog or similar popup and it doesn't show in the windows taskbar which is super annoying. This mostly happens when there are multiple desktops and we're doing several things at once. Just make sure that there's nothing hiding under the IDE window or in another desktop.

Xzanderaven commented 1 year ago

Still there. Also turned off Maven quick import and made sure that the boxes for auto downloading sources was checked. I also checked the link that popped up at the bottom of the build code and it gave me this: https://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException I'm not seeing a settings file in .m2 and I don't know where I'd look for the plugin repositories.

shai-almog commented 1 year ago

This isn't related to the IDE, maven or the .m2 directory. This sounds like this sorry I don't have a Windows machine at the moment.

Xzanderaven commented 1 year ago

The only thing I'm missing on these are the special permissions and I don't see a way to get those added, but otherwise the system and my account have all admin permissions allowed.

shai-almog commented 1 year ago

Is it possible java is running an an unprivileged user or something?

Maybe there's a space in your user name?

I'm out of ideas here... If it can't see the jar file you placed manually in that exact same directory then something is seriously wrong.

Xzanderaven commented 1 year ago

No space in my username, just letters. This is what's showing up for me for both versions I have downloaded. jdk permissions

shai-almog commented 1 year ago

Can you verify that the CodeNameOneBuilder.jar copy you have is indeed a valid zip file?

Does it appear when you run dir from the command line?

Xzanderaven commented 1 year ago

It shows up as a .jar for me. dir

shai-almog commented 1 year ago

Yes I meant can you unzip it. In windows there's no command line unzip so just copy the file to a filename.zip and try unzipping it to make sure it's valid (jar files are technically just zip files). Although in terms of size the file looks good so this might not be necessary.

Also delete the other two files from the directory. Open the task manager and kill all the Java processes in your machine and try building again. Maybe something got botched along the way.

Eric-Chomba commented 1 year ago

intellij Open IntelliJ, click on the top folder. open file This is the code that's immediately opened. The 8 errors show up with I have it set to JDK 11, only 2 show up when I have it set to JDK 8. issues The errors that appear on the pom file when I have JDK 8 enabled. error 1 error 2 Code block for both errors.

Your project path has a white space which could be problematic \Downloads\my app\myapp

try to move the project to a path without white space.

Are you able to successfully run and build a simple Java maven project like Hello world?

Xzanderaven commented 1 year ago

Your project path has a white space which could be problematic \Downloads\my app\myapp

try to move the project to a path without white space.

Are you able to successfully run and build a simple Java maven project like Hello world?

I've tried several other downloads of the same package that don't have the white space and they don't work either. "Hello World!" works if I run it under maven-archetype-quickstart. It doesn't want to work if I open it as maven-archetype-archetype.

shai-almog commented 1 year ago

How do you open it?

Open the root folder of the project. Assuming you generated an IDEA project there should be a play button on the top that should "just work" and run the simulator target as shown in Erics screenshots.

Xzanderaven commented 1 year ago

Those are my screenshots of opening a project. I click the run button and it throws errors because it can't find the file you dropboxed me, even after I added it to the .codename file.

shai-almog commented 1 year ago

In this screenshot: https://user-images.githubusercontent.com/138056993/253070731-a28399e6-0b08-4dc8-8d7e-f47488794a0e.JPG

On the left side there's a tree that isn't shown. Go to the top of the tree where it should show the full log including all the steps. Can you paste that here as code?

Xzanderaven commented 1 year ago

This is the rest of that string of text from the screenshot: 'dependencyManagement.dependencies.dependency.systemPath' for com.codenameone:codenameone-buildclient:jar refers to a non-existing file C:\Users[[Name]].codenameone\CodeNameOneBuildClient.jar

This is the code that's calling the file:

<dependency>
     <groupId>com.codenameone</groupId>
         <artifactId>codenameone-buildclient</artifactId>
                <version>${cn1.version}</version>
                      <scope>system</scope>
                              <systemPath>${user.home}/.codenameone/CodeNameOneBuildClient.jar</systemPath>
</dependency>

But that's the correct path to the file.

shai-almog commented 1 year ago

There should be more there. Can you provide a full screenshot?

Xzanderaven commented 1 year ago

This is my whole pom file. The parts are what's throwing an error.

**<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">**

<modelVersion>4.0.0</modelVersion>

   <groupId>coderad.pack.trybare</groupId>

   <artifactId>myapp</artifactId>

   <version>1.0-SNAPSHOT</version>

   <packaging>pom</packaging>

   <name>myapp</name>

   <description>myapp</description>

   <url>https://www.codenameone.com</url>

   <licenses>

    <license>

    <name>GPL v2 With Classpath Exception</name>

    <url>https://openjdk.java.net/legal/gplv2+ce.html</url>

        <distribution>repo</distribution>

      <comments>A business-friendly OSS license</comments>

    </license>

  </licenses>

  <modules>
<module>common</module>
</modules>

  <properties>

   <cn1.plugin.version>7.0.86</cn1.plugin.version>

    <cn1.version>LATEST</cn1.version>

    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

   <java.version>1.8</java.version>

    <java-tests.version>11</java-tests.version>

    <rhino.version>1.7.11</rhino.version>

    <maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>

   <maven.compiler.source>1.8</maven.compiler.source>

    <maven.compiler.target>1.8</maven.compiler.target>

    <kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>

    <cn1app.name>myapp</cn1app.name>

     </properties>

    <dependencyManagement>

    <dependencies>

      <dependency>

        <groupId>com.codenameone</groupId>

        <artifactId>java-runtime</artifactId>

        <version>${cn1.version}</version>

      </dependency>

     <dependency>

        <groupId>com.codenameone</groupId>

        <artifactId>codenameone-core</artifactId>

        <version>${cn1.version}</version>

       </dependency>

       <dependency>

        <groupId>com.codenameone</groupId>

        <artifactId>codenameone-javase</artifactId>

        <version>${cn1.version}</version>

      </dependency>

     <dependency>

      <groupId>com.codenameone</groupId>

        <artifactId>codenameone-buildclient</artifactId>

        <version>${cn1.version}</version>

       <scope>system</scope>

        **<systemPath>${user.home}/.codenameone/CodeNameOneBuildClient.jar</systemPath>**

      </dependency>

</dependencies>

  </dependencyManagement>

<build>

    <pluginManagement>

     <plugins>

        <plugin>

        <groupId>com.codenameone</groupId>

          <artifactId>codenameone-maven-plugin</artifactId>

          <version>${cn1.plugin.version}</version>

        </plugin>

        <plugin>

          <groupId>org.apache.maven.plugins</groupId>

          <artifactId>maven-compiler-plugin</artifactId>

         <version>${maven-compiler-plugin.version}</version>

        </plugin>

        <plugin>

          <groupId>org.codehaus.mojo</groupId>

         <artifactId>exec-maven-plugin</artifactId>

         <version>3.0.0</version>

        </plugin>

        <plugin>

          <artifactId>maven-antrun-plugin</artifactId>

          <groupId>org.apache.maven.plugins</groupId>

          <version>3.1.0</version>

       </plugin>

    </plugins>

   </pluginManagement>

  <plugins>

    <plugin>

        <!-- Codename One Uses its own test runner currently.
                    This snippet configures Maven Surefire to use Codename One's "dummy"
                    provider so that Surefire doesn't try to run Codename One's tests
                    using its built-in test providers. -->

        <groupId>org.apache.maven.plugins</groupId>

        <artifactId>maven-surefire-plugin</artifactId>

        <version>3.0.0-M5</version>

        <dependencies>

         <dependency>

           <groupId>com.codenameone</groupId>

            <artifactId>codenameone-maven-plugin</artifactId>

            <version>${cn1.plugin.version}</version>

          </dependency>

        </dependencies>

      </plugin>

    </plugins>

  </build>

<repositories>
</repositories>

  <pluginRepositories>

    </pluginRepositories>

  <profiles>

   <profile>

      <id>javascript</id>

      <activation>

        <property>

          <name>codename1.platform</name>

          <value>javascript</value>

        </property>

      </activation>

      <modules>

      <module>javascript</module>

      </modules>

    </profile>

    <profile>

      <id>ios</id>

      <activation>

       <property>

         <name>codename1.platform</name>

         <value>ios</value>

       </property>

      </activation>

      <modules>

        <module>ios</module>

      </modules>

    </profile>

    <profile>

      <id>win</id>

      <activation>

       <property>

       <name>codename1.platform</name>

          <value>win</value>

        </property>

       </activation>

      <modules>

        <module>win</module>

      </modules>

    </profile>

    <profile>

      <id>android</id>

      <activation>

        <property>

          <name>codename1.platform</name>

          <value>android</value>

        </property>

      </activation>

      <modules>

        <module>android</module>

       </modules>

     </profile>

    <profile>

   <id>javase</id>

      <activation>

      <property>

          <name>codename1.platform</name>

         <value>javase</value>

        </property>

        <activeByDefault>true</activeByDefault>

      </activation>

      <modules>

        <module>javase</module>

       </modules>

    </profile>

    <profile>

     <id>cn1libs</id>

      <activation>

        <file>

          <exists>${basedir}/cn1libs/pom.xml</exists>

        </file>

      </activation>

      <modules>

        **<module>cn1libs</module>**

      </modules>

     </profile>

  </profiles>

</project>
shai-almog commented 1 year ago

I don't need to see the POM. I need to see what's in the console and next to the console. If you run this from command line do you get more than just one line of error?

I want to see the whole output. There has to be some information there that will explain what's going on.

Xzanderaven commented 1 year ago

I'm not really sure what part you're asking for, but these are the errors that show up and all the files in the project. The 'cannot find CodeNameOneBuildClient.jar' error isn't showing up here because I told the program to ignore it to see if it would still run but it didn't work.

pom file with errors directories directories 1 directories 2 directories 3

Xzanderaven commented 1 year ago

I downloaded and "other" option of the file to run in the command line a while ago and that's now running in both command line and IntelliJ after i added the file you dropboxed me but others I downloaded for IntelliJ still won't work.