Flex Compilier says source-path and package definition mismatch
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 开发者_JAVA百科in advance for any help you can give!
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.
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.
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.
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.
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!
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:
精彩评论