Along with many class resolution errors, my project suddenly started to display this error on the package:
The type groovy.lang.MetaClass cannot be resolved. It is indirectly referenced from required .class files
- The type groovy.lang.GroovyObject cannot be resolved. It is indirectly referenced from required .class
files
I also noted that the unit tests all are failing to compile and display this error on the TestFor annotation:
- Groovy:class TestFor is not an annotation in #TestFor
- Groovy:unable to resolve class TestFor , unable to find class for
annotation
I have tried to clean the project then to refresh dependencies but still no joy. I quite STS and restarted and tried the clean/refresh as well.
I do get a compile error on one of my .groovy files which complain about undefined classes--but I have added the jar defining those classes to my lib folder and do not see any errors on import of the class.
Any suggestions? Do I have to rebuild the entire project?
It turns out that an undefined symbol that stopped the compile had this result. I wasn't familiar with how STS/Eclipse handles a failure to resolve a class and had expected the class path to have been defined before any actual compiles were completed.
So the answer is to look in the error log for STS, determine if one of my classes are missing, and resolve that first before rabbit-holing down a path like this.
Related
I am using RoslynPad project to test how external plugins (Class libraries) could be used in the script.
I have created Class Library with a single class and method.
In roslynPad project i have added "plugin_demo" into RoslynHostReferences NamespaceDefault structure.
I have also added reference to plugin dll:
MetadataReference newref = MetadataReference.CreateFromFile("G:\\projects\\demos\\plugin_demo\\plugin_demo\\bin\\Debug\\plugin_demo.dll");
MetadataReferences = MetadataReferences.Add(newref);
Now i see that my new class is seen by diagnostics and autocomplition also works.
The code with a method call compiles fine.
But when i run it i get exception:
Could not load assembly or file. File not found.
I have copied plugin_demo.dll into directory where compiled roslynPad dll resides. Still no result.
I have checked that class library and roslynpad use the same .Code version.
What can be the problem?
What is correct way of adding assemblies to roslyn project?
Thanks
I have solved the problem after debugging. The roslynPad project generates file nams_deps.json when editor is launched. It must be deleted and after that the assembly is found.
So, I have been trying to migrate the development of a multi-project (eclipse projects that is) app to Android Studio (v1.1).
Importing via File > Import Project was really easy and went without incident.
However, when I tried Make/Rebuild project I encountered numerous surprises. The first, not Proguard-related, had to do with source file encoding (originally in Windows-1252), but I quickly found a solution using this Windows-1252 > Reload > UTF-8 > Convert answer.
Then, "error: cannot find symbol class" for a com.comp.mod.X class of mine. I then solved it by going to the module (Android Studio module that is, previously an Eclipse project) that contains that class and added to its proguard.cfg the following:
-keep public class com.comp.mod.X
Which left me with an "error: cannot find symbol variable" for a const BB defined in the aforementioned class. I solved this by adding to the same proguard.cfg the following:
-keepclassmembers class com.comp.mod.X {
public static final boolean BB;
}
That left me with only one "error: cannot find symbol method getPreferenceX()". I solve this by adding to the same -keepclassmembers that method, so that the above now looks:
-keepclassmembers class com.comp.mod.X {
public static final boolean BB;
public static java.lang.String getPreferenceX();
}
I thought I was done, but to my dismay, when I attempted to rebuild the project, I received numerous additional errors from other modules in the project, all of the type to "error: cannot find symbol class/variable/method" and related to some proguard.cfg.
I could have continued butchering the proguard.cfg files for each and every module but at this point I am beginning to suspect that I am doing something fundamentally wrong, because those proguard.cfg files work perfectly under Eclipse. So,
Why all of a sudden these are no longer good for Android Studio?
If ProGuard runs only when you build your application in release mode, why is the Android Studio based build complaining about "cannot find symbol" due to Proguard's obfuscation?
What am I missing?
Note: I have not attempted "Generate Signed APK". All I do is "Rebuild Project".
Currently (as of 2015-04-24), minifyEnabled's default value of false for all build types is incorrect for multi-module projects, in which some modules (app included) are dependent on other modules. This is due to bug #52962 that causes build types to not propagate to libraries -- they are always built as RELEASE.
Suggestions to work around this bug or notifications of its fix are most welcome.
I have IntelliJ 12 and some groovy code (along with a pile of java code) in a project.
In intelliJ, i can see class A's import of some groovy code, and i have also included the library that has that code.
However, while the package itself is in one colour (for the import), the actual class being imported is in red, which implies an issue of some sort. Hovering the mouse over it reveals no issue though.
When i run a "make" or a "rebuild project" is where the problems start - i get
Groovyc: unable to resolve class com.blah.blah.blah.A
How can i resolve this?
Currently, my project setup is like so:
Under "Libraries" in (Project Structure -> Project Settings -> Libraries) I have:
the jar file with all the groovy code
the src jar file with all the groovy code
In the "Modules" section i have the - well, i don't know what to call it, the column isn't labelled - the library name from the libraries section associated with the src and class files, and the little "export" button beside it is ticked.
Incidentally, opening the class in intelliJ never shows the source code, which given the source is included struck me as weird.
Is there anything else I should need to do?
I've worked this one out, but if anybody knows why groovy cannot be in the "Resource Patterns" list and wants an upvote, do chime in
Oh, right.
I removed the !?*.groovy entry from the list of, um, entries in the File : Settings -> Compiler -> Resource Patterns thingy.
It doesn't seem to matter if "use external build" is on or off for this, but the !?*.groovy; entry cannot be there.
I wonder if anybody knows why?
I had the same problem and had to Add Framework Support and add Groovy to the project to get round this problem.
I created the project using gradle.
I just got your question in my Google results as I had a similar issue. My problem was that I was able to get the groovy code in my IntelliJ 12 project to compile ok, but it wasn't getting wired in properly when I tried to run unit tests within the IDE.
After some investigation, I uncovered that groovy and logback libraries were all set up in the project to be available in the runtime stage of the Maven build of the project, but that resulted in them not being available in the test stage. To fix this, I ended up manually updating the groovy-all and the logback libraries scope from runtime to provided under File->Project Structure->Modules->Dependencies. This allowed me to both compile and test within the IDE while including the Groovy modules as well as the Java modules.
Perhaps you had something similar going on in your project?
Six years later, I also just got this question near the top of my search results.
In my project my Unable to load class 'groovy.text.SimpleTemplateEngine' problem was actually due to a codenarc issue. I was able to resolve the issue by adding the following to build.gradle:
// codenarc version issue work-around
configurations.codenarc {
resolutionStrategy.eachDependency { DependencyResolveDetails d ->
if (d.requested.group == 'org.codehaus.groovy') {
d.useVersion '2.4.7'
}
}
}
I tried to obfuscate my project in j2me..But it is showing the following error.I came to know that this obfuscation error happened only when i importing Json.jar in my project..If i remove this jar means obfuscation is happening..Please help me solve this..Thanks in advance.
Warning: org.json.me.JSONArray: can't find referenced method 'java.lang.Object remove(int)' in class java.util.Vector
Warning: there were 1 unresolved references to program class members.
Your input classes appear to be inconsistent.
You may need to recompile them and try again.
Alternatively, you may have to specify the options
'-dontskipnonpubliclibraryclasses' and/or
'-dontskipnonpubliclibraryclassmembers'.
Error: Please correct the above warnings first.
C:\Users\Ponmani\Documents\TThehinduNov22ponmani\nbproject\build-impl.xml:427: Obfuscation failed with error code 1.
BUILD FAILED (total time: 4 seconds)
This error happens because the JSONArray class uses remove(int) method from Vector class, but this method is not available for Java ME: http://docs.oracle.com/javame/config/cldc/ref-impl/midp2.0/jsr118/java/util/Vector.html
You picked a Java Se version of the library. Please, try this other library: https://github.com/upictec/org.json.me/
Update
There is a ZIP button where you can download the repository as a zip file.
Inside the zip file enter /src/main/java.
Copy org folder and paste it in your src folder.
I have two groovy files (in case you are not familiar with groovy, think of it as a java file).
I have file A.groovy in package test.BI. This file has makes use of a class Master which is in B.groovy which is also in the package test.BI. However this B.groovy also makes use of a class Execution which is in A.groovy.
When I compile A.groovy it errors unable to resolve class Master and when I compile B.groovy it errors unable to resolve class Execution.
Both A.groovy & B.groovy have multiple classes. How can I solve this problem without creating one file for each class.
In IntelliJ IDEA, invoke Make (Ctrl+F9), or Compile (Ctrl+Shift+F9) on just these two files (after selecting them both in the Project View).