Installing dependencys with Gradle Kotlin DSL does not work - kotlin

Hi everyone I am new to IntelliJ in general and especially to Gradle and I feel like a total noob. :D
Im not sure if this is a Kotlin DSL thing or if I just do it the wrong way and it wouldn't work in Groovey either.
After hours of trial and error and reading other SO posts I'm still not able to install a simple dependency... it can't be that hard...
Currently I am playing around with Jetpack Compose for Desktop even though it's still in alpha and it works but for the love of god I am not able to add a dependency.
So here is my Problem:
I try to install the dependency like they say I should in
https://developer.android.com/jetpack/compose/navigation#kts
and yes I know it's an android package so it may not compile or it may crash during runtime but shouldn't it at least find and download the dependency???
So... if I add
implementation("androidx.navigation:navigation-compose:2.4.0-alpha10")
to my build.gradle.kts
And try to compile it I get an exception during the build process:
What I tried so far:
I checked if the repository maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
who is configured in my build.gradle.kts repositories-section and in my settings.gradle.kts pluginManagement-section contains the package that I want.
The site https://mvnrepository.com/artifact/androidx.navigation/navigation-compose?repo=space-public-compose-dev tells me, that the repository contains the package that I need.
I checked the error log itself.
But I don't relly know what it tries to say.
I use Java SDK16, since I expect downward compatibility and the fact that the dependency is still in alpha I assume it should be compatible.
I use Kotlin 1.5....
that's it.
Thanks for reading all that :) I really appreciate your time... If I forgot some crucial information let me know and I will add it as soon as I can.

the problem which I feel is, is you are basically opening the wrong file. (I don't use jetpack compose so the answer might differ)
on the top left corner in the image, where there is project dropdown, open it and select android.
now there will be a different set of files in the Gradle folder, in fact, there will be 2 different files in that folder.
build.gradle (project: <project_name>)
build.gradle (Module: <project_name>.app)
open the second file and there will be dependencies copy + paste implementation code there.
the file which you have opened is actually the first file.

Well... here I am back again answering my own question.
After I switched to the terminal in IntelliJ Idea (which to be honest I could have thought of that prior to posting my question) there was highlighted text that gave me the necessary insight, why it wasn't working.
And after some searching the web in order to find out what an "aar" file is and why I didn't get a jar file like I expected it turns out that android has it's own little file format for android applications and that those cannot be used in regular java/kotlin projects.
I read somewhere, that 'aar' files contain a jar file and some other stuff and extracting the jar file from the aar file may be a way to get it working, but it didn't fix anything, maybe because the dependencies of the navigation package are aar files as well and therefor I'd need those packages as well and extract the jar file from those as well and it all seems like this isn't the right way...
So I guess I have to wait until Jetpack Compose for desktop somehow is able to use aar files or until the repositories deliver the packages in a regular jar file.

Related

Intellij Idea doesn't recognize generated classes if they are not in the same directory

So I have an issue with Intellij Idea because it absolutely wants my generated ressources to be in the folder of their package, otherwise it won't work (but it still compiles)
Here are my files, as they should stay
The "package" file view is wrong too
And other files from the same package doesn't recognize their brothers and there's a big red mess, this is my issue
As said, only Intellij Idea is complaining because when I run maven, it compiles with no errors.
I already tried making Antlr4 generating files in target/generated-sources/fr/bananasmoothii/scriptcommands/core/antlr4parsing, but it was messy because Intellij idea was marking the wrong directory as generated source, but after remarking correctly the directories, it worked perfectly.
Afterwards, I though it is better to generate files normally and make Intellij idea understad what it should.

How to share (VCS) run configurations templates with IntelliJ IDEA

I've dug a lot and learned how to share the run configurations in IntelliJ IDEA CE (presently using 2019.3.4) via the in .idea/runConfigurations/*.xml files. When we check those file into VCS (Git) others get them and all works as expected.
The question is related to sharing the templates for JUnit and Application configurations. When created manually they end up in .idea/workspace.xml which is not meant for or suitable for sharing (often modified, has personal preferences and even screen locations, ...).
I could not find any mention of how to do this so I tried extracting the relevant <component ...>...</component> fragments into standalone files inside .idea/runConfigurations/. This seemed to work but weird things started happening - IDEA renamed the files from my original names (whatever they were, forgot), to:
.idea/_template__of_JUnit.xml and
.idea/_template__of_Application.xml
I was happy with that and submitted those to Git but then other people commented how IDEA keeps renaming those files further.
What is the proper way to accomplish this?
Thanks!
IntelliJ IDEA doesn't support sharing run/debug configuration defaults at the moment.

IntelliJ + Play Framework routes file red underline error

Image of the errors
I don't how to fix this red underlines I recently got in my routes files.
What I did:
I split up my routes files into 3 files:
- routes
- rest.routes
- web.routes
And after I did, IntelliJ said something about "We have a new program that can handle .routes files" and I clicked yes to it. <-- Stupid me :(
Can also mention that I cant remember what addon that was installed, and I cant find any addons that differs from previous versions.
Before there was no "spellchecking" on the file, but now I get this box in top of the file saying "Project SDK is not defined 'Setup SDK' ". It also gives the red "undelining" similar to spellchecking under every single line of code in the file.
The code itself works great, its just very frustrating to have these red lines everywhere.
Anyone know how to get rid of it?
Highly appreciated!
IntelliJ 2017.2 and Play Framework 1, I had this problem one day. Took me awhile to figure out but it was the Scala plugin that made this fail for me. After uninstalling the Scala plugin it works again.
I also faced similar issue recently. The plugin that Intellij asks to install in this case is Erlang. You just have to uninstall it (or just suppress the warning).
To uninstall Erlang go to Preferences.. -> Plugins. Then search for Erlang and select. Then click uninstall (on the right pane).
First, setup Java SDK (even if you use scala)
Second, try to compile code (run play application) and recheck routes files. I suggest that IDEA use compile routes classes to verify config.
Third, check syntax of your conf/routes . Are you sure want use -> ?

Make IntelliJ understand usage of Babel's moduleRoot

For our project we use EcmaScript 6 through Babel, Gulp and npm.
We have three projects: Base, Common and Game.
We're actively developing Common and Game so we have those checked out (and npm link from Game to Common), while we get the Base project through npm and don't change it often.
The import paths we use start with the project name such as import "Base/utils/svg" or import "Game/model/boardtile". The map according to the following on the file system:
Base → /intellij-project/base-project-src/node_modules/base/
Common → /intellij-project/base-project-src/js/
Game → /intellij-project/game-project-src/js/
The problem: IntelliJ does not understand this import scheme. We use the moduleRoot and moduleId options of Babel to identify our AMD modules that way during the gulp build process. When that is done we concatenate everything into one big file. That works, but IntelliJ does not know that we do this magic.
Is there a way to still make IntelliJ understand our imports? So that it will know that Base/utils/svg actually means /intellij-project/base-project-src/node_modules/base/? At the moment the IDE is mostly a glorified text editor, as refactorings obviously relies on the IDE understanding the imports.
Note: Unfortunately I can't change the import structure, as it's a decision I can't change. Nor can I switch to other tools instead of the above mentioned ones, such as WebPack.
I'm facing the same problem with this. I'm looking for a way to get rid of the annoying relative paths as you guys have done, but to get them to work with IntelliJ is another piece of work.
What can help is the symlink approach that can be found here.
https://gist.github.com/branneman/8048520
IntelliJ can work nicely with node_modules, so you could symlink a folder in your node_modules to point to the real thing. Then I suppose IntelliJ will be able to resolve your imports.

IntelliJ IDEA Report Highlighting error when using routes in Controller

I have a Scala Play project. I'm using Play 2.2.1. I downloaded Scala, Play 2 supported and SBT plugins. Everything is OK, but When I call route on Action in the Controller appear following error(Look screenshots):
I'm using IntelliJ IDEA 12.1.6 Ultimate version. Scala version 2.10.2
Anybody know how to fix this problem?
Thanks in advance!
Edit
When I generate my project to Intellij IDEA via "play idea" command in play console, and I opened project in IDEA project structure was such:
Then I saw answer #millhouse and discussing on this githup([Play 2.2] "play idea" creates not working source mapping in target) and I removed following folders from Sources Folders:
target\scala-2.10\src_managed\main\controllers
target\scala-2.10\src_managed\main\views
and "Report highlighting error" disappeared, but now there is another error:
and
my route:
And I've changed "Sources Folders" as shown below:
But it doesn't help me. And remains "Unspecified value parametrs" error.
millhouse's answer helped me find the right answer. Play 2.2 (and perhaps earlier versions, haven't checked) output a scala version of the routes file to project_dir/target/scala-2.10/src_managed/main So for IntelliJ to get the highlighting right you need to make sure that src_managed/main is added as a source folder. The reverse routes for javascript are for some reason included in project_dir/target/scala-2.10/classes_managed so you'll have to add that as well. (In your screenshot it looks like classes_managed is set to excluded so you'll want to un-exclude it by pressing the x button on the right hand side.)
Here's a screen shot of my project structure:
Update:
In Play 2.3 (or perhaps recent versions of IntelliJ) adding the classes_managed no longer fixes the problem. Instead of adding classes_managed to the project's sources add it to it's dependencies. By doing that IntelliJ should be able to pick up the compiled routes.class.
This is a common problem, it's because IntelliJ needs to be shown where to look for the compiled Scala templates and routes file. Here's how I fixed it on my IntelliJ 12.1 installation:
Go to the Module Settings for your project in IntelliJ (select the top-level, hit F4)
Choose the Modules item in the Project Structure window that appears
Select the projectname item (as opposed to the projectname-build item)
Add the compiler's output directory to the Source Folders items;
For Scala 2.10 it's target/scala-2.10/classes
I personally find the IntelliJ UI for this to be very non-intuitive; you might need to take the target directory and/or one of its subdirectories out of the Excluded Folders first
After applying that change, IntelliJ should see the results of compiling each routes and .scala.html file as just-another source file, so they won't show as "broken" and auto-complete should work for them.