When running a Lint check on files in my project I often come across an error that looks like this (actual names of files redacted, but you'll get the idea):
Dependency from module 'name_of_my_project' on module
'some_3rd_party_library' could be probably be removed when
complementary scope to 'File 'filepath_to_the_class_being_analyzed'
also does not contain references on module 'some_3rd_party_library'
I get this error for every single library that isn't compiled with Gradle - i.e. libraries that have been imported whole into the project and then added as dependencies.
Facebook is a great example of a library that even if you wanted to compile it through Gradle you couldn't because they don't support it, and you need to run it as a local library - it seems like you'll then receive this "unnecessary module dependency" warning for every class that doesn't directly call Facebook.
So, the question is - what is the "proper" way of handling this error? Do I ignore it or am I supposed to change the code in some way to make it disappear?
Edit: in the preferences menu for Lint it describes the check as follows (in case this helps figure it out):
This inspection lists modules which contain redundant dependencies on
other modules. These dependencies can be safely removed.
There are known issues with the Lint checkers. I do not get this error in Android Studio 2.1.1. However, if you still do and you know it to be spurious, I would recommend going to Settings --> Editor --> Inspections --> Unnecessary Module Dependency and changing the Severity type from Warning to Info. This way you get a "clean lint build" and avoid a "broken windows" type of state due to bad lint algo. In fact, I've created a special category that has Info severity called Info Due To Bad Lint Algo to which I've assigned whatever I know to be spurious. This way I can periodically review those and see if they've been fixed.
You should report this to them btw, so there is some hope of it getting fixed... Good luck!
You can avoid lint checking using following block of code.
Add following block of code into app build.gradle file inside android {}
lintOptions {
checkReleaseBuilds false
// set to true to turn off analysis progress reporting by lint
quiet true
// if true, only report errors
ignoreWarnings true
abortOnError false
disable "ResourceType"
}
Related
I am an Eclipse/STS user/developer, now trying to use IntelliJ Idea (CE)
2020.2.(1,2,3)
For a project based on Gradle, how spring-integration, when I open the IDE it happens the following
Ok, let the IDE load the project ... but
From above, that is the problem, I don't want that the IDE starts automatically to build/rebuild the project. I just need, open the project and that's all.
Observation: for example in Eclipse/STS exists the option to disable Build Automatically
I did do a research in the Web and I read the following posts and questions:
How to disable automatic gradle builds?
IntelliJ IDEA “Build project automatically” apparently not working
Intellij IDEA Java classes not auto compiling on save
Sadly the dialog options were changed but ...
Therefore:
From above, seems nothing to do.
Observation: from above observe the Build project automatically option is disabled
Even with that disabled and after to restart the IDE, I must always stop manually the build process
So what is missing? or Do I need a special extra plugin to accomplish my goal?
The images that you show indicate that you are building with Gradle, but the Compiler option that you disable is relevant for building projects with Idea not with Gradle.
For the 2020.2 version, you need to do the following:
Open the Setting > Build Tools page.
Disable the "Reload changes in build scripts" option.
This way you can manually control the reload. When you change the build script, you will see a small gradle icon in the right side of the editor.
For more info, refer to the IntelliJ IDEA help > Gradle section.
https://www.jetbrains.com/help/idea/work-with-gradle-projects.html#auto_reload
There are two different things in IntelliJ's Gradle support that sometimes confused: sync and build. Your pictures demonstrate sync process (note caption on the toolwindow). Word build is kind of misleading here.
What is sync? In gradle we use Groovy to define the build procedure. Groovy is an imperative programming language, so it's hard to predict resulting dependencies graph without actually executing the script. During the sync Idea executes configuration phase of gradle build (one that builds dependency graph), and obtains configured objects from the Gradle daemon. This information is used to setup project in the IDE: modules, libraries, dependencies, which sources are test, which are prod, etc.
Actual build is not happening during sync. You can convince yourself by adding syntax error to any source file, and observe that the sync succeeds. But build will fail if you invoke it.
In answer to the original question: you can't disable automatic build, because it is not enabled.
Is it possible to disable sync in Gradle project? Short answer - no. If you need a code browser, which is not required to understand all the cross-references in the source code, IDEA is not the best choice probably.
TL;DR;
Without sync IDE does not know which files are sources, and which are not. IDEA cannot open folders. It only can open projects. Good thing is that module can contain folder. So you can do the following: File | New | Project. Select Empty project, Next, select some random folder outside the source folder you want to open, Finish.
Then add new module:
Select Java in the left panel, everything else keep default, Next, Finish. Then in new module remove existing content root, and add folder with sources as new content root
Resulting project is mostly useless. Tons of red code (at least, unresolved symbols from external libraries), no inspections, no navigation, no sense. But it might be useful in some rare situations indeed.
This error pops up in Xcode after a gradle build
or like the one below in your intelliJ
When you come across an error like this,
This property is used to replace the default Kotlin/Native compiler used by the Gradle plugin with a local distribution. Since this sample is included in the K/N repo, it has this property specified to use a compiler built from sources.
So you may just remove org.jetbrains.kotlin.native.home from your gradle.properties and rerun the build.
And for the error in the second image, you can ignore that because when you try to perform ./gradlew build in the terminal, this is bound to occurs as this is not handled by the gradle in IntelliJ or Android Studio. It will be recognized by the Xcode when you follow the Readme.md(https://github.com/JetBrains/kotlin-native/tree/master/samples/cocoapods) and unlink the "Pods_ios_app.framework" and re-link by browsing again to make it work.
I am working on a project using kotlinjs for nodejs and I start to learn coroutines and integrate them into my code to say goodbye to the callback hell.
I managed to get coroutines working, my code can be compiled and executed, everything seems fine.
...except: The IDE still shows me errors. It seems to be confused by the additional libraries I added in order to get coroutines running.
I am currently fiddling around with the library dependencies, sometimes some errors go away, but then some code gets red which was okay before...
This is what I see:
Case 1:
Cannot access class 'kotlinx.coroutines.experimental.CoroutineContext'. Check your module classpath for missing or conflicting dependencies
Case 2:
Unresolved reference: JsModule
Modifier 'external' is not applicable to 'class'
You see, launch is recognized when I add the stdlib, but then the IDE complains with the other two errors.
Again, please note: In both cases, actual compilation is successful!
I am using IntelliJ 2018.1 with Kotlin Plugin 1.2.41.
Thanks to Alexander Chernikov at youtrack.jetbrains I could resolve my problem.
I cite his explanation:
The issue is that JavaScript libraries should be marked with special attribute to be recognized.
When they are imported from pom.xml or build.gradle, this mark is set, so the feature works.
In your project they are not marked.
At the moment, to correct the libs manually, please open .idea/libraries/org_jetbrains_kotlin_kotlin_stdlib_js_1_2_41.xml and .idea/libraries/org_jetbrains_kotlinx_kotlinx_coroutines_core_js_0_22_5.xml.
In both files find type="repository" and replace it with type="kotlin.js".
Make sure IDEA sees the change. (You can exit IDEA, make the change and restart.)
Then you can keep only these two libs in dependencies. The editor should work.
Here is the issue link:
https://youtrack.jetbrains.com/issue/KT-24575
There I have also attached a sample project with the problem.
in IntelliJ (2016.2 and previous) we have our Groovy classes marked red with the error "class already exists".
I think we can exclude that the cause is the stub-generation, as this is deactivated.
Probably it's caused in our constellation: We have included our compiled groovy (and java) classes in a jar that is registered as dependency.
Dependency MyProduct.jar contains com.mycompany.MyGroovyClass
Our source contains com.mycompany.MyGroovyClass
The error disappears if the dependency is registered with Test-Scope, in all other scopes the error appears.
However, in our structure we kinda have to include the compiled classes in a compile scope, as we want to avoid that each developer needs to compile all classes (I know about the compile in background ability, but we have a constellation that prevents this from working).
We have no errors in com.mycompany.MyJavaClass which exists as well in source and in MyProduct.jar.
Any ideas on how we can solve this?
We've been suffering the same issue, it seems to be that IntelliJ registers the Java class, but also the Groovy class, and because of that it is showing that message (BTW, we are using a Maven Project).
So we ended up by going to the target folder -> right click -> Mark Directory As -> Excluded. Then, this setting will be saved on the IML file, and it won't happen again.
Hope it works for your as well!
Cheers
I'm using gmavenplus-plugin:1.5
After marking target/generated-sources/generated-sources/main as "Excluded", The error disappeared. I even did "invalidate cache and restart", It persists the setting. This is great. Intellij 2017.1.5
We have two ways to fix this issue
Exclude Stub Directory
target folder -> generated-sources -> groovy-stubs -> Right click main folder -> Mark Directory As -> Excluded
Remove generateStubs goal from gmaven plugin
Remove <goal>generateStubs</goal> from gmavenplus plugin
Make sure you Mark the src folder as Sources Root and do the same for the test folder
Then delete the target folder (most likely it's marked in yellow) and don't worry it won't delete any code from your project
If the issue persist, proceed to go to File -> Invalidate Cache/Restart
I have looked high and low for the solution to this, and I have gotten close, but still having a little trouble.
The error:
Build: Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning.
This error appears for every usage of decorators. I have the MSBuild set up with
<TypeScriptEmitDecoratorMetadata>True</TypeScriptEmitDecoratorMetadata>
<TypeScriptExperimentalDecorators>True</TypeScriptExperimentalDecorators>
and that removed half of the errors (compiler errors, not build errors). However, now I'm stuck with the build errors. The .ts files still get compiled to .js, no problem.*** But the exceptions get in the way of building the rest of the solution.
If any of this doesn't make sense, please let me know. I'm not the best with words.
Edit: I discovered that the .js is created upon save, not build. So anything relating to build is "broken."
I had the same problem. I ended up modifying the .csproj to change all TypeScriptCompile elements to just plain Content elements, and I used my own compile task (via Gulp).
For example,
<TypeScriptCompile Include="app.ts" /> became <Content Include="app.ts" />.
I also removed any imports that referenced Typescript related MSBuild targets, i.e. <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets')" />
I still get IDE (and Resharper, if you use that) support for Typescript - I just explicitly tell Visual Studio not to handle any TS compilation for my project. It seems that the only downside is having to manage my Gulp tasks for compiling the Typescript. Using Task Runner Explorer extension for VS, adding the Gulp compilation task as part of the project's build, or just using the Gulp task inside of a gulp watch can mitigate the tradeoff.