Why it compiles with different type? - unity3d

Error:
IL2CPP error for type 'Namespace.SubNamespace.MyClass/<MyIEnumeratorFunc>d__20' in assembly 'Path\MyUnityProject\Temp\StagingArea\Data\Managed\VisualStudioSolutionName.dll'
Additional information: Interface System.Collections.Generic.IEnumerator`1<System.Object> method T System.Collections.Generic.IEnumerator`1<System.Object>::get_Current() not implemented on non-abstract class Namespace.SubNamespace.MyClass/<MyIEnumeratorFunc>d__20
Unity expect System.Collections.IEnumerator and I try to use IEnumerator:
I tried to write directly
private System.Collections.IEnumerator MyIEnumeratorFunc(){}
I tried to remove
using System.Collections.Generics;
and append it to each List/Dictionary entry
Everything works in Editor, but I get error I described above:
Seems like it tries to use System.Collections.GENERICS.IEnumerator.
Also, the error disappears if I use source code (not .dll)
Also, you can reproduce it by creating .dll with any IEnumerator/async function (even empty) and build for iOS.

The problem was in Project name.
Solution is
Right mouse click on Project name (not solution name) in Solution Explorer.
Properties
"Application" tab
Assembly name -> set to the same to .dll file name (without ".dll")

Related

Xcode build error - Multiple commands produce .o, Target 'ProjectCoreData' has compile command for Swift source files listed twice

I am running xCode Version 10.1 (10B61), Mojave 10.14 (18A391)
Searching shows similar issue in Xcode 10 greater than a year ago, but no issues since then. The solution from last year seemed to be switching to legacy mode, but that doesn't work now. It appears the source code that is stored on my desktop is conflicting with code that is in 'DerivedData', I'm not sure why this would suddenly pop up so randomly.
I see this problem go away if I remove the last model added in Core Data. It seems to trigger when I add a relationship to another object. It's apparently random.
Any advice on how to fix this issue so I can develop?
Multiple commands produce '//Library/Developer/Xcode/DerivedData/ProjectCoreData-ehjvvgovpitmbcegzopwciptfafr/Build/Intermediates.noindex/ProjectCoreData.build/Debug-iphonesimulator/ProjectCoreData.build/Objects-normal/x86_64/Contact+CoreDataClass.o':
Target 'ProjectCoreData' (project 'ProjectCoreData') has compile command for Swift source files
Target 'ProjectCoreData' (project 'ProjectCoreData') has compile command for Swift source files
from the logs:
<unknown>:0: error: filename "Contact+CoreDataClass.swift" used twice: '/Users/<user>/Desktop/ProjectCoreData/Contact+CoreDataClass.swift' and '/Users/<user>/Library/Developer/Xcode/DerivedData/ProjectCoreData-ehjvvgovpitmbcegzopwciptfafr/Build/Intermediates.noindex/ProjectCoreData.build/Debug-iphonesimulator/ProjectCoreData.build/DerivedSources/CoreDataGenerated/ProjectCoreData/Contact+CoreDataClass.swift'
<unknown>:0: note: filenames are used to distinguish private declarations with the same name
<unknown>:0: error: filename "Contact+CoreDataProperties.swift" used twice: '/Users/<user>/Desktop/ProjectCoreData/Contact+CoreDataProperties.swift' and '/Users/<user>/Library/Developer/Xcode/DerivedData/ProjectCoreData-ehjvvgovpitmbcegzopwciptfafr/Build/Intermediates.noindex/ProjectCoreData.build/Debug-iphonesimulator/ProjectCoreData.build/DerivedSources/CoreDataGenerated/ProjectCoreData/Contact+CoreDataProperties.swift'
<unknown>:0: note: filenames are used to distinguish private declarations with the same name
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1
The reason you see this error is because Core Data creates these files by default, but you can't see them in Project Navigator. Then you create a duplicate (in Editor/Create NSManagedObject Subclass). As a result you have your error.
According to What's new in Core Data here is a picture with the solution:
For future users :
If you are using core data and If you copied entity using option+drag, then ensure that entity name and class name must be same.
None of the solutions mentioned over internet worked for me.
It happened to me after I dragged the coredata model and classes from another project, which generated duplicate files. If this is your case, go to TARGETS->Build Phases->Compile Sources, remove the duplicate files and it should be working again.
for me it was simple problem,
i had 2 source files of the exact same name,
just renamed one of them (only the swift file name) and the problem was gone
To fix this I've to open the .xcdatamodeld using finder/show package content
This image
and then repeat this operation with the .xcdatamodel.
This option
After this I've opened the file (I use Sublime) Sublime Text locate the duplicate class name Duplicate Class Name, change it, save the file and build again. Like this

Unity Can't Find C# Script

I can't seem to compile on Unity because all of my scripts have errors. The error messages keep on repeating, "The associated script cannot be loaded. Please fix any compile errors and assign a valid script." I have checked all of my scripts on Visual Studio 2017 and have not found any errors.
The image below shows the error showing on the inspector view of the unity engine:
If there are really no compiler errors as you say the reason might be incorrect file names or class types.
Make sure that the file names and the class names match!
If your class is called
public class Player_Collision1 : MonoBehaviour
{
...
}
the script/file must exactly be called
Player_Collision1.cs
and the other way round.
Attention: The Unity project view (Assets) strips of the file endings so there it should only display as
Player_Collision1
Another reason for a script to be not valid is e.g. if your class doesn't inherit from MonoBehaviour at all.
Unity would usually prevent you from adding those "invalid" scripts to an object but it might happen that you renamed them or changed their type afterwards. In this case you will see the error you currently have.
Check you log and see if any compiler error has happened.If no have a look at your class name and file name are same.
I see that you are (relatively) new here. welcome to Stack Overflow! ^^
what unity is trying to say is that it can't compile your scripts because there is one or more another script(s) that have errors in them.
in the Console, you will find your errors and by double left clicking on one of then, you will be taken to the script and the location of its error.
by selecting (left click) an error you will be able to read more a more detailed description of the error.

Eclipse is not showing method parameters properly

In my eclipse, when i check for method help with ctrl+space i see the method parameters are showing like strings, int as arguments. Not showing like, string name/int id .
getAttribute(String arg0)
How can i make the eclipse to show the method as getAttribute(String name)
This is really difficult to me identify which param i should pass fro a method.
Any idea, where should i set the settings?
This problem happens when eclipse can't find the source or attached Javadoc, since java argument names are usually not present in the .class files (it would only be present in debug, and not for the interfaces).
You can check if a source or a documentation is attached using the helper F3.
You can increase the timeout eclipse uses for fetching a parameter name from attached Javadoc in the settings.
You can also attach the corresponding documentation jar or source jar as a dependency in order to allow eclipse to look-up the corresponding source.

Why eclipse is generating argument names as arg0,arg1,arg2.... for methods?

When I try to access some class's method; eclipse gets that method but arguments inside that method are replaced by arg0, arg1, arg2...
Example:-
Suppose I have this method in some class named ReadFile.java
#Override
public int readXXX(int start, int end, String xxx) throws IOException {
return 0;
}
When I try to access that method from an instance of class it shows me as follows:
readFile.readXXX(arg0, arg1, arg2);
It becomes hard to identify what I should pass in argument. The same thing also happens for java methods. i.e. when I implement interface all method under that will be generated but arguments in that methods are arg0, arg1.....
Is there any setting I can do prevent this?
I'm using Eclipse Galelio.
Eclipse can't work out the arguments because it can't find the source or javadoc attachments.
Make sure your source is attached.
To check, click on the method call readXXX and press F3 which should open the method declaration. If the source is not attached, Eclipse will say "Source not found" and will allow you to "Attach Source...".
Anyone having the same issue, try performing a Project > Clean, this will delete the old class files, and Eclipse will recompile them in debug mode this time. Worked for me in Indigo 3.7.2
The problem is that your class files lacks debug information embedded in them. JDT doesn't reparse the source files or the javadoc for dependencies, when building the AST for your project, so it doesn't have idea what the name of the parameter is, even when you are able to open the class and clearly see what are the method names.
In order to correct this, you need to recompile your class files with debug information enabled, which makes the class file considerably larger, but unless you are developing for memory-constraint devices, you should be fine.
for those like me who tried to apply one of our colleagues suggestions and unfortunately hasn't worked, please, give a try to check the option "Add variable attributes to generated class files (used by the debugger)" within Window -> Preferences -> Java + Compiler.
Once you've done that, try to build the project again.
Cheers.
I solved this by going to preferences
Java / Content Assist
On this page under "Sorting and Filtering" I unchecked "Hide proposals not visible in the invocation context" now instead of seeing (arg0, arg1, arg2) etc in autocomplete I see (catalog, schemaPattern, tableNamePattern...)
I am using Spring Tools Suite 3.7.2 which runs on the Eclipse Mars 4.5.1 platform.
This link helped me to solve this problem.
1) Right click on your android.jar and select Properties.
2) Select Java Source Attachment. Enter the source directory location (you can also use External Folder… to browse to the directory) and click on “Apply“.
The code names match the following version numbers, along with API levels and NDK releases provided for convenience:

Netbeans - class does not have a main method

My program is just a simple System.out.println("");
But netbeans cannot find the main method.
Is netbeans 6.7.1 conflict with WIN7?
Any possible error?
This happens when you move your main class location manually because Netbeans doesn't refresh one of its property files.
Open nbproject/project.properties and change the value of main.class to the correct package location.
Sometimes passing parameters in the main method causes this problem eg. public static void main(String[] args,int a). If you declare the variable outside the main method, it might help :)
Exceute the program by pressing SHIFT+F6, instead of clicking the RUN button on the window.
This might be silly, bt the error main class not found is not occurring, the project is executing well...
It was most likely that you capitalized 'm' in 'main' to 'Main'
This happened to me this instant but I fixed it thanks to the various source code examples given by all those that responded. Thank you.
This destroyed me for a while.... I knew that there HAD to be an easier way with a world class IDE like Netbeans.
The easiest method is to press Shift+F11 (Clean and Build Project), then hit F6 to run it.
It refreshes Netbeans appropriately and finds your main without all the manual labor; and if you have multiple mains, it will give you the option to select the correct one.
Make sure it is
public static void main(String[] argv)
No other signature will do.
in Project window right click on your project and select properties go to Run and set Main Class ( you can brows it) . this manual work if you have static main in some class :
public class Someclass
{
/**
* #param args the command line arguments
*/
public static void main(String[] args)
{
//your code
}
}
Netbeans doesn't have any conflict with W7 and you can use version 6.8 .
If you named your class with the keyword in Java, your program wouldn't be recognized that it had the main method.
I had this issue as well (Error: Could not find or load main class test.Test). I'll explain this relatively basically since I know I would have appreciated someone doing that when I was looking for my answer.
When I right-clicked on the project (left hand side of the screen unless you got rid of the projects tab) and went to properties and then run, the main class had the projectname.classname, which is what confused me.
For example, I created a project "test" to test this out, and when I went to
(right-click) test or Source Packages -> properties -> run -> main class
had Test.test in that field, which is what the problem was. the class is test, not Test.test, so I clicked browse to its right, and the only thing in the list to select from was test, and when I selected that and tried rerunning it, it finally worked.
Additionally, I found that when you create a new project in Netbeans, one of the things it originally gives you (in my case of the project named test) is package test;. If you are having this problem, then like me, you probably originally got rid of that line seeing it as just another line of code you didn't need. That line of code is what enabled your main class which in my case was Test.test to find the main class *test from that.
My situation was different I believe because non of the above solutions di work for me. Let me share my situation.
I am importing an existing project (NewProject->Java->Import Existing Projects)
I name the project to xyz. The 'main' function exists in Main.class.
I try to run the code I modified in the main function but the error pops out. I tried the shift_f6, specifically rebuild. Nothing works.
Solution: I took the project properties and saw the 'Source Package Folder' mappings in the Sources branch was blank. I mapped it and voila it worked.
Now anyone might think that was very silly of me. Although I am new to Java and Netbeans this is not the first time I am importing sample projects and I saw all of them had the properties similar. The only difference I saw was that the main class was not having the name as the project which I believe is a java convention. I am using JDK7u51 (latest till date), is it causing the issue? I have no idea. But I am happy the project is running fine now.
Check for correct method declaration
public static void main(String [ ] args)
Check netbeans project properties in Run > main Class
While this may be an old question, the problem is still occurring these days, and the exact question is still not answered properly.
It is important to note that some projects have multiple classes with a main method.
In my case, I could run the project via the main class, but I could not run a particular other class that had a main method.
The only thing that helped me was refactoring the class and renaming it.
I've tried:
restart NetBeans
re-open the project
clear NetBeans cache
delete the file and create a new one with same name and contents
delete the file and create a new one with same name but very simple contents with only main method and print out message
rename the class (refactor) so a temp name and back
delete the project and create a new one with the same sources
The only thing that let me run this class is renaming it permanently. I think this must be some kind of a NetBeans bug.
Edit: Another thing that did help was completely uninstall Netbeans, wipe cache and any configuration files. It so happened that a newer Netbeans version was available so I installed it. But the old one would have probably worked too.
public class TestConnection {
public static void main(String args[]) {
//make sure when you create a new class, it has the above line, and then
//when you click shift+F6, it works fine for NetBeans IDE 12.4
myConnection my = new myConnection();
my.getConnection();
}
}