Flex Compilier says source-path and package definition mismatch
Asked Answered
E

6

5

Here's the issue:

I have three files in the same package: com.foobar

The directory to these files is:

C:..\mylibrary\src\com\foobar\

then inside I have foo.as and bar.as

When I try to run mxmlc C:..\mylibrary\src\com\foobar\foo.as I get the error:

A file found in a source-path must have the same package structure ' ', as the definition's package, 'com.foobar'.

To that I say: it does. The package is com.foobar. The structure goes ../com/foobar/foo.as

I've found a few other forum posts on the web about this error, and it seemed like the user had to make the directory matching the package name, which I already have. What am I missing?

Thanks in advance for any help you can give!

Excessive answered 7/10, 2010 at 18:56 Comment(2)
Can you post the exact package specification as you have it listed for all three of your classes?Outthink
package com.foobar { //imports public class Foo { } } The others look the same except the class name is Bar and TestExcessive
E
9

A co-worker helped me for quite some time on this. Turns out I had to use the following command:

(in the directory x which holds \src\com\foobar\foo.as)

mxmlc -compiler.source-path=.\src -static-link-runtime-shared-libraries=true .\src\com\foobar\foo.as -output .\test.swf

For whatever reason, the -source-path command I tried wasn't satisfactory.

I'm not exactly sure why it works like this, but hey it works now. Hope this helps others that are lost trying to compile an actionscript package.

Excessive answered 7/10, 2010 at 20:33 Comment(0)
W
1

i can't be bothered to work out if it is the reason for your problem but i found that i got that error when the file.mxml referenced a file.as for a class and the file.mxml was in the wrong directory in relation to it's class naming within the .mxml file.

so the general example if the .mxml file references

  • import MyPackage.Util.MyClass;

then the .as file contianing the class should be in a relative position

  • \howto\MyFile.mxml

  • \howto\MyPackage\Util\MyClass.as

you for example then call the compiler, ..\bin\mxmlc MyFile.mxml

I suspect that if you try using source-path directives in the scenario above it will complain that subdirectories are already included anyway.

Walkin answered 1/12, 2011 at 19:54 Comment(0)
A
0

You've mentioned 3 different packages here: com.foo, com.foobar and com.plupload, and it sounds like you have one directory path for all 3: \com\foobar. If these classes are in the directory \com\foobar\ then they all need to declare the package as com.foobar. The package name and the directory path needs to match otherwise you will get the mismatch error you described. Bottom line: package names and directory paths are effectively synonymous.

Aletaaletha answered 7/10, 2010 at 19:5 Comment(4)
Whoops, sorry with the slip up there. All three have the package declaration: package com.foobar and they all reside in the directory \com\foobar. I edited the original post to correct the errors.Excessive
Yikes. With those corrections I don't see anything wrong with your code. Sorry I can't help.Aletaaletha
I guess I don't understand why it says the package structure is ' '. Shouldn't the error reflect the folders in which foo.as lies?Excessive
My guess is that it has to do with using mxmlc at the command line and that it is assuming that your package is actually the source root, hence it thinks the package is '' rather than 'com.foobar'. That's just a guess though.Aletaaletha
A
0

Aside from having the correct folder structure, you also need to match the file name and the name of the class verbatim. This means foo.as should be Foo.as if your classname is indeed Foo.

Acidify answered 2/6, 2011 at 23:46 Comment(0)
B
0

Flash Builder quick hint.

If you have changed your air/flex or any other background packages, or even added a new sdk and had to do some file re-arranging to get it to work then you may have had to re-compile or have flash builder update its file atlases.

The most common issue if your src folder or default package are full of errors is that Flash Builder just moved their references.

if you right click on your default package file (.as or mxml etc.) and choose the Set As Defualt Application then this may fix your issue. If that doesn't work you need to go to:

Project > Properties > ActionScript Build Path 

At the bottom it will have a Main Source Folder box. If that is empty then just type in 'src' or which ever name you call your source folder that contains all your package files (.as or whatever).

If your default package/file is still showing errors (i.e. A file found in a source-path must have the same package structure 'src', as the definition's package)

go to Project > Properties > ActionScript Compiler

and look at what Flex SDK version you are using. If the 'default' button is selected then try selecting the Use a specific SDK and see what it lists. Usually it will only list one and it will read something like Flex 4.6.0 , or something similar. Make a note of that name and search your hard drive for flex-sdk-description.xml This will usually be in your:

Adobe > Adobe Flash Builder 4.6(or your current version) > sdks > Flex 4.6.0 (same name as in flash builder).

Open that file and you will see the flex-sdk-description.xml Right click or highlight it and choose to open it with notepad (windows). It will have a long line of desciptors. find <name>Something written here</name> this must have the same name as your flash builder Flex SDK selection (that we just discovered a second ago). Sometimes you will have to change this <name> to use a specific sdk or extension in Flash Builder. This is where I can't help you and you need to ensure that this <name> is Flex 4.6.0 or what ever version of flex you are using. If it is Flex 4.6.0(Air3.6) or has anything else you may need to contact adobe or the sdk/extension creator to see what you can do.

Lastly check your Output section in Project > Properties > ActionScript Build Path as the default Output is bin-debug. If you did not specifically change this before hand then it will by default be: bin-debug

Good luck!

Babbie answered 21/2, 2013 at 21:14 Comment(0)
T
0

please verify all the tags in your '.actionScriptProperties' file. In case you have copied and moved the folder, this is the place where it has to be verified. In my case I changed From:

Tincture answered 14/5, 2015 at 12:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.