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
import kotlin
add a comment |
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
import kotlin
Does this code compile when you use gradle, e.g. when runningbuild
gradle task?
– Ilya
Nov 12 at 0:54
add a comment |
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
import kotlin
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
import kotlin
asked Nov 10 at 16:57
thePunsGuy
32
32
Does this code compile when you use gradle, e.g. when runningbuild
gradle task?
– Ilya
Nov 12 at 0:54
add a comment |
Does this code compile when you use gradle, e.g. when runningbuild
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
add a comment |
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.
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
add a comment |
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Does this code compile when you use gradle, e.g. when running
build
gradle task?– Ilya
Nov 12 at 0:54