Kotlin.math package not importing









up vote
0
down vote

favorite












I'm trying to use kotlin.math.abs in a util.kt file, but the following code results in an "unused import" warning on the import statement and an unresolved reference where I use abs in the code.



import kotlin.math.abs

fun fuzzyEquals(a: Double, b:Double, epsilon: Double= 0.001) = abs(a-b) < epsilon


I'm using IntelliJ and gradle to organize the project. I'm on Intellij 2018.2.5 with Kotlin 1.3.0.



The folling code does work, so I don't think it's a problem with Kotlin as a whole



import kotlin.sequences.find

fun test() = listOf(1,2).findit==1









share|improve this question





















  • Does this code compile when you use gradle, e.g. when running build gradle task?
    – Ilya
    Nov 12 at 0:54














up vote
0
down vote

favorite












I'm trying to use kotlin.math.abs in a util.kt file, but the following code results in an "unused import" warning on the import statement and an unresolved reference where I use abs in the code.



import kotlin.math.abs

fun fuzzyEquals(a: Double, b:Double, epsilon: Double= 0.001) = abs(a-b) < epsilon


I'm using IntelliJ and gradle to organize the project. I'm on Intellij 2018.2.5 with Kotlin 1.3.0.



The folling code does work, so I don't think it's a problem with Kotlin as a whole



import kotlin.sequences.find

fun test() = listOf(1,2).findit==1









share|improve this question





















  • Does this code compile when you use gradle, e.g. when running build gradle task?
    – Ilya
    Nov 12 at 0:54












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm trying to use kotlin.math.abs in a util.kt file, but the following code results in an "unused import" warning on the import statement and an unresolved reference where I use abs in the code.



import kotlin.math.abs

fun fuzzyEquals(a: Double, b:Double, epsilon: Double= 0.001) = abs(a-b) < epsilon


I'm using IntelliJ and gradle to organize the project. I'm on Intellij 2018.2.5 with Kotlin 1.3.0.



The folling code does work, so I don't think it's a problem with Kotlin as a whole



import kotlin.sequences.find

fun test() = listOf(1,2).findit==1









share|improve this question













I'm trying to use kotlin.math.abs in a util.kt file, but the following code results in an "unused import" warning on the import statement and an unresolved reference where I use abs in the code.



import kotlin.math.abs

fun fuzzyEquals(a: Double, b:Double, epsilon: Double= 0.001) = abs(a-b) < epsilon


I'm using IntelliJ and gradle to organize the project. I'm on Intellij 2018.2.5 with Kotlin 1.3.0.



The folling code does work, so I don't think it's a problem with Kotlin as a whole



import kotlin.sequences.find

fun test() = listOf(1,2).findit==1






import kotlin






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 10 at 16:57









thePunsGuy

32




32











  • Does this code compile when you use gradle, e.g. when running build gradle task?
    – Ilya
    Nov 12 at 0:54
















  • Does this code compile when you use gradle, e.g. when running build gradle task?
    – Ilya
    Nov 12 at 0:54















Does this code compile when you use gradle, e.g. when running build gradle task?
– Ilya
Nov 12 at 0:54




Does this code compile when you use gradle, e.g. when running build gradle task?
– Ilya
Nov 12 at 0:54












1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










The functions from kotlin.math package can be unresolved by one of the following reasons:



  • you don't have the kotlin standard library in dependencies (it doesn't seem so from your question), or the version of that dependency is lower than that, where this package was introduced, namely 1.2. Check the dependencies block of your build file.


  • apiVersion compiler option, which limits visible API to only available in the specified version, can be set. Check whether you have this option in Gradle build file and also check the effective version in the Kotlin facet of your module in IntelliJ project structure.





share|improve this answer




















  • This didn't solve my problem entirely, but it got me going in the right direction! Thank you. Turns out my issue was that I depend on a package that has Kotlin 1.1 bundled in, and my build was defaulting to that instead of 1.3. Unlinking and relinking the project in Gradle seems to have fixed the issue.
    – thePunsGuy
    Nov 13 at 3:02











  • Perhaps this has been accompanied with a warning "w: Some JAR files in the classpath have the Kotlin Runtime library bundled into them. This may cause difficult to debug problems if there's a different version of the Kotlin Runtime library in the classpath. Consider removing these libraries from the classpath"
    – Ilya
    Nov 13 at 11:56










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53241258%2fkotlin-math-package-not-importing%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote



accepted










The functions from kotlin.math package can be unresolved by one of the following reasons:



  • you don't have the kotlin standard library in dependencies (it doesn't seem so from your question), or the version of that dependency is lower than that, where this package was introduced, namely 1.2. Check the dependencies block of your build file.


  • apiVersion compiler option, which limits visible API to only available in the specified version, can be set. Check whether you have this option in Gradle build file and also check the effective version in the Kotlin facet of your module in IntelliJ project structure.





share|improve this answer




















  • This didn't solve my problem entirely, but it got me going in the right direction! Thank you. Turns out my issue was that I depend on a package that has Kotlin 1.1 bundled in, and my build was defaulting to that instead of 1.3. Unlinking and relinking the project in Gradle seems to have fixed the issue.
    – thePunsGuy
    Nov 13 at 3:02











  • Perhaps this has been accompanied with a warning "w: Some JAR files in the classpath have the Kotlin Runtime library bundled into them. This may cause difficult to debug problems if there's a different version of the Kotlin Runtime library in the classpath. Consider removing these libraries from the classpath"
    – Ilya
    Nov 13 at 11:56














up vote
0
down vote



accepted










The functions from kotlin.math package can be unresolved by one of the following reasons:



  • you don't have the kotlin standard library in dependencies (it doesn't seem so from your question), or the version of that dependency is lower than that, where this package was introduced, namely 1.2. Check the dependencies block of your build file.


  • apiVersion compiler option, which limits visible API to only available in the specified version, can be set. Check whether you have this option in Gradle build file and also check the effective version in the Kotlin facet of your module in IntelliJ project structure.





share|improve this answer




















  • This didn't solve my problem entirely, but it got me going in the right direction! Thank you. Turns out my issue was that I depend on a package that has Kotlin 1.1 bundled in, and my build was defaulting to that instead of 1.3. Unlinking and relinking the project in Gradle seems to have fixed the issue.
    – thePunsGuy
    Nov 13 at 3:02











  • Perhaps this has been accompanied with a warning "w: Some JAR files in the classpath have the Kotlin Runtime library bundled into them. This may cause difficult to debug problems if there's a different version of the Kotlin Runtime library in the classpath. Consider removing these libraries from the classpath"
    – Ilya
    Nov 13 at 11:56












up vote
0
down vote



accepted







up vote
0
down vote



accepted






The functions from kotlin.math package can be unresolved by one of the following reasons:



  • you don't have the kotlin standard library in dependencies (it doesn't seem so from your question), or the version of that dependency is lower than that, where this package was introduced, namely 1.2. Check the dependencies block of your build file.


  • apiVersion compiler option, which limits visible API to only available in the specified version, can be set. Check whether you have this option in Gradle build file and also check the effective version in the Kotlin facet of your module in IntelliJ project structure.





share|improve this answer












The functions from kotlin.math package can be unresolved by one of the following reasons:



  • you don't have the kotlin standard library in dependencies (it doesn't seem so from your question), or the version of that dependency is lower than that, where this package was introduced, namely 1.2. Check the dependencies block of your build file.


  • apiVersion compiler option, which limits visible API to only available in the specified version, can be set. Check whether you have this option in Gradle build file and also check the effective version in the Kotlin facet of your module in IntelliJ project structure.






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 12 at 0:58









Ilya

8,81543055




8,81543055











  • This didn't solve my problem entirely, but it got me going in the right direction! Thank you. Turns out my issue was that I depend on a package that has Kotlin 1.1 bundled in, and my build was defaulting to that instead of 1.3. Unlinking and relinking the project in Gradle seems to have fixed the issue.
    – thePunsGuy
    Nov 13 at 3:02











  • Perhaps this has been accompanied with a warning "w: Some JAR files in the classpath have the Kotlin Runtime library bundled into them. This may cause difficult to debug problems if there's a different version of the Kotlin Runtime library in the classpath. Consider removing these libraries from the classpath"
    – Ilya
    Nov 13 at 11:56
















  • This didn't solve my problem entirely, but it got me going in the right direction! Thank you. Turns out my issue was that I depend on a package that has Kotlin 1.1 bundled in, and my build was defaulting to that instead of 1.3. Unlinking and relinking the project in Gradle seems to have fixed the issue.
    – thePunsGuy
    Nov 13 at 3:02











  • Perhaps this has been accompanied with a warning "w: Some JAR files in the classpath have the Kotlin Runtime library bundled into them. This may cause difficult to debug problems if there's a different version of the Kotlin Runtime library in the classpath. Consider removing these libraries from the classpath"
    – Ilya
    Nov 13 at 11:56















This didn't solve my problem entirely, but it got me going in the right direction! Thank you. Turns out my issue was that I depend on a package that has Kotlin 1.1 bundled in, and my build was defaulting to that instead of 1.3. Unlinking and relinking the project in Gradle seems to have fixed the issue.
– thePunsGuy
Nov 13 at 3:02





This didn't solve my problem entirely, but it got me going in the right direction! Thank you. Turns out my issue was that I depend on a package that has Kotlin 1.1 bundled in, and my build was defaulting to that instead of 1.3. Unlinking and relinking the project in Gradle seems to have fixed the issue.
– thePunsGuy
Nov 13 at 3:02













Perhaps this has been accompanied with a warning "w: Some JAR files in the classpath have the Kotlin Runtime library bundled into them. This may cause difficult to debug problems if there's a different version of the Kotlin Runtime library in the classpath. Consider removing these libraries from the classpath"
– Ilya
Nov 13 at 11:56




Perhaps this has been accompanied with a warning "w: Some JAR files in the classpath have the Kotlin Runtime library bundled into them. This may cause difficult to debug problems if there's a different version of the Kotlin Runtime library in the classpath. Consider removing these libraries from the classpath"
– Ilya
Nov 13 at 11:56

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53241258%2fkotlin-math-package-not-importing%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo