question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't set main package

See original GitHub issue

Hi, I’ve a project where my uniquely mentioned source file in asconfig.json defines the main class in a named package.

package com.hydroper.dsterminal
{
  public class TmView extends Sprite implements IView
  {
    /* ... */
  }
}

So, building the project as follows:

  • Goto Run build task & ActionScript: compile debug build.

Just fails with the message:

Error: Unable to resolve root class of SWF: TmView

The project (FlashDevelop version) already built fine. So I wonder if it’s right now possible to set the main package w/ AS & MXML? I read the entire asconfig.json wiki, btw, but most related options serve only for setting library and source paths, andn’t the main namespace. Including classes won’t work, either (totally unrelated to “files”: […]).

Truth

I forgot I could use the source-path option. It just made my build.

{
  /* ... */

  "compilerOptions": {
    "source-path": [ "src" ],
    "output": ".build/target/terminal.swf"
  },

  /* ... */
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
joshtynjalacommented, Mar 6, 2019

Some more info about your folder structure would be helpful. Is everything under a main src folder? Or is platforms a sibling of src? Does either of the classes have a package?

Ultimately, you’ll need exactly one entry in files, but you may need one or two entries in source-path too. What goes in source-path depends on your folder structure.

0reactions
joshtynjalacommented, Mar 6, 2019

As I mentioned, files should almost always contain one file. In your case, for iOS, you’ll want this:

"files": [
    "platforms/iOS/MainiOS.as"
]

Then, since you have multiple source paths, you’ll want source-path to look like this:

"source-path": [
    "platforms/iOS",
    "."
]

However, I would recommend moving your core classes into a src folder, that is a sibling of platforms. Right now, you have two overlapping source paths (platforms/iOS is inside .), which could lead to unexpected issues (potentially including IDEs, or even the compiler, getting confused).

Read more comments on GitHub >

github_iconTop Results From Across the Web

go run: cannot run non-main package - Stack Overflow
I am getting "go run: cannot run non-main package" error, if I run following code. package zsdfsdf import ( "fmt" ) func Main()...
Read more >
"Cannot set package name for compiled files" when moving a ...
"Cannot set package name for compiled files" when moving a file to a package · Right click on a top-level declaration in the...
Read more >
Cannot import main: a Go Module gotcha - Applied Go
The problem is that the test driver (_testmain.go) needs to import the package and if the import path is “main”, gc will refuse...
Read more >
Java Guide: How to Fix "Could not find or load main class"
The Java “Could not find or load main class” error is thrown when the JVM fails to find or load the main class...
Read more >
Fixing the “Declared package does not match the expected ...
In this article, we'll investigate the “Declared package does not match the expected package” error in a java project.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found