1

When I try to add IntArrays in my codes, the Android Studio gives me these errors:

"C:\Program Files\Android\Android Studio\jre\bin\java.exe" "-javaagent:C:\Program Files\Android\Android Studio\lib\idea_rt.jar=50719:C:\Program Files\Android\Android Studio\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\bosun\AppData\Local\Android\Sdk\platforms\android-29\android.jar;C:\Users\bosun\AppData\Local\Android\Sdk\platforms\android-29\data\res;C:\Users\bosun\AndroidStudioProjects\Test2\app\build\intermediates\javac\debug\classes;C:\Users\bosun\AndroidStudioProjects\Test2\app\build\tmp\kotlin-classes\debug;C:\Users\bosun\AndroidStudioProjects\Test2\app\build\generated\res\resValues\debug;C:\Users\bosun\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-android-extensions-runtime\1.3.61\289bdf25b4886749e040c7a7d3aab8a57f85c631\kotlin-android-extensions-runtime-1.3.61.jar;C:\Users\bosun\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-jdk7\1.3.61\70dffc5f8ac5ea7c34f30deac5b9d8b1d48af066\kotlin-stdlib-jdk7-1.3.61.jar;C:\Users\bosun\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib\1.3.61\4702105e97f7396ae41b113fdbdc180ec1eb1e36\kotlin-stdlib-1.3.61.jar;C:\Users\bosun\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-common\1.3.61\65abb71d5afb850b68be03987b08e2c864ca3110\kotlin-stdlib-common-1.3.61.jar;C:\Users\bosun\.gradle\caches\modules-2\files-2.1\org.jetbrains\annotations\13.0\919f0dfe192fb4e063e7dacadee7f8bb9a2672a9\annotations-13.0.jar;C:\Users\bosun\.gradle\caches\modules-2\files-2.1\androidx.collection\collection\1.0.0\42858b26cafdaa69b6149f45dfc2894007bc2c7a\collection-1.0.0.jar;C:\Users\bosun\.gradle\caches\modules-2\files-2.1\androidx.lifecycle\lifecycle-common\2.0.0\e070ffae07452331bc5684734fce6831d531785c\lifecycle-common-2.0.0.jar;C:\Users\bosun\.gradle\caches\modules-2\files-2.1\androidx.arch.core\core-common\2.0.0\bb21b9a11761451b51624ac428d1f1bb5deeac38\core-common-2.0.0.jar;C:\Users\bosun\.gradle\caches\modules-2\files-2.1\androidx.annotation\annotation\1.0.2\2f1d597d48e5309e935ce1212eedf5ae69d3f97\annotation-1.0.2.jar;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\4400ce52558a1326f6f8df052592e334\core-ktx-1.0.2\jars\classes.jar;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\879984f11f327e0566da31edd3b93778\appcompat-1.0.2\jars\classes.jar;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\879984f11f327e0566da31edd3b93778\appcompat-1.0.2\res;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\9ac1dcdf45a51c129ec9ab070abfd8d7\fragment-1.0.0\jars\classes.jar;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\9b9150b07929bc69439efe995438be41\vectordrawable-animated-1.0.0\jars\classes.jar;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\59d04c87522e7722ea3ca8715a8b0d7d\legacy-support-core-ui-1.0.0\jars\classes.jar;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\e8e43754c06475d8590f4ff699e532f8\legacy-support-core-utils-1.0.0\jars\classes.jar;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\f918a2c43bb058b74c18b9596e2a2796\vectordrawable-1.0.1\jars\classes.jar;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\d1a473dd41ab9d9cfedb415a767fa8e2\loader-1.0.0\jars\classes.jar;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\28a2f2bfe5b19437baae53dd908102d9\viewpager-1.0.0\jars\classes.jar;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\ced0565cf77ede6c9fe2cc907e012eb2\coordinatorlayout-1.0.0\jars\classes.jar;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\ced0565cf77ede6c9fe2cc907e012eb2\coordinatorlayout-1.0.0\res;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\0e17e0903cc4b356cac1f1cdb05efef6\drawerlayout-1.0.0\jars\classes.jar;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\3bb2c7104f2f4e21e4344de7d5162af7\slidingpanelayout-1.0.0\jars\classes.jar;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\e4f940674933431d2ed1592b500f2e4e\customview-1.0.0\jars\classes.jar;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\4cc9299baa04d807d8b5ed7d258aef09\swiperefreshlayout-1.0.0\jars\classes.jar;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\70edb5ab10f0c6baaf068d26450280d2\asynclayoutinflater-1.0.0\jars\classes.jar;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\bde5344dd836d92b3a6c11207c599e3d\core-1.0.2\jars\classes.jar;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\bde5344dd836d92b3a6c11207c599e3d\core-1.0.2\res;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\1df4b1ae03d2b473d0219ecebc547a11\versionedparcelable-1.0.0\jars\classes.jar;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\a5cd9e8e0d405c18c2b2d3ee49201e52\cursoradapter-1.0.0\jars\classes.jar;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\4ec2bbfd3859804671a6ce6c91e03a8c\documentfile-1.0.0\jars\classes.jar;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\9d992e7c041153936c4b20c6e9d00821\localbroadcastmanager-1.0.0\jars\classes.jar;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\99907df3d56060bc7b1502dcd5ee124b\print-1.0.0\jars\classes.jar;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\99a636cd82617c988188441746e7f20d\lifecycle-viewmodel-2.0.0\jars\classes.jar;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\c20fb0ee45b96eb0e4b0a639b2ec1f4d\lifecycle-runtime-2.0.0\jars\classes.jar;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\7b586029e966589a4a60caf5a0a6e9d2\interpolator-1.0.0\jars\classes.jar;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\d94f7826feb0de043e3c43244f79749a\lifecycle-livedata-2.0.0\jars\classes.jar;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\e31b9daaaa8bb7510409960c20556b7e\lifecycle-livedata-core-2.0.0\jars\classes.jar;C:\Users\bosun\.gradle\caches\transforms-2\files-2.1\373d10fc23cf87276d7fbe4eda833447\core-runtime-2.0.0\jars\classes.jar com.example.test2.MainKt
Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/KotlinPackage
    at com.example.test2.MainKt.main(main.kt:4)
    at com.example.test2.MainKt.main(main.kt)
Caused by: java.lang.ClassNotFoundException: kotlin.KotlinPackage
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 2 more

Most codes works fine. I can test some projects. Emulator is working fine too. But when it comes to add IntArrays it cannot compile. I've search on everywhere but I couldn't find the solution. I've reinstalled the Android Studio and JRE but it didn't work as well.

Used Codes:

package com.example.test2

fun main(){
    var a:IntArray = intArrayOf(1,2,3,4)
    println("test")
}

My build Gradles:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.3.61'
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files

    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

and the second one is:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 29
    buildToolsVersion '29.0.2'
    defaultConfig {
        applicationId "com.example.test2"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.core:core-ktx:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'

}

Addition: I have tested this situation in a completely different computer. It gives an error too. I guess it is kind a bug of Android Studio.

5
  • "var a:IntArray = intArrayOf(1,2,3,4)" to "var a = intArrayOf(1,2,3,4)".... remove ":IntArray" Commented Dec 29, 2019 at 18:23
  • It didn't work. Commented Dec 29, 2019 at 20:22
  • that doesn't look like an android activity to me, what exactly are you trying to achieve? my guess is that you got android all wrong, try adding an (auto-generated) activity and see how its coded. Commented Dec 30, 2019 at 17:30
  • Can you try to compile a project which has IntArrays in it ? I have projects which contains activites. I know what activity is. The thing is I faced this problem when it comes to use IntArrays. So, I decided to test it with "no empty" project. But it is failure. Commented Jan 1, 2020 at 10:27
  • I am facing same issue. I am using Intellij IDEA for pure kotlin (not android) and when I call the intArrayOf() function, compiler throws an error : Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/KotlinPackage. I think this problem is about Java SDK or Kotlin SDK but I could not figure out which one... Commented Jan 31, 2020 at 1:50

1 Answer 1

5

I had the same problem and I discovered that this is a bug of Kotlin library. (I am so serious.) You cannot call intArrayOf() method.

I am sure that you are using Windows 10 Single Language Turkish. (I was using the same operating system.) Kotlin's some libraries cannot work on Turkish operating system. You can check this issue on YouTrack.

You can solve your problem with installing Windows 10 Pro English or Windows 10 Single Language English. I do not know any other approach right now. (You can open new issue on Kotlin website.)

This bug took from me 30 days. You can check my related question about this Kotlin bug.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.