When I try to add IntArrays in my codes, the Android Studio gives me these errors:
"C:Program FilesAndroidAndroid Studiojreinjava.exe" "-javaagent:C:Program FilesAndroidAndroid Studiolibidea_rt.jar=50719:C:Program FilesAndroidAndroid Studioin" -Dfile.encoding=UTF-8 -classpath C:UsersosunAppDataLocalAndroidSdkplatformsandroid-29android.jar;C:UsersosunAppDataLocalAndroidSdkplatformsandroid-29data
es;C:UsersosunAndroidStudioProjectsTest2appuildintermediatesjavacdebugclasses;C:UsersosunAndroidStudioProjectsTest2appuildmpkotlin-classesdebug;C:UsersosunAndroidStudioProjectsTest2appuildgenerated
es
esValuesdebug;C:Usersosun.gradlecachesmodules-2files-2.1org.jetbrains.kotlinkotlin-android-extensions-runtime1.3.61289bdf25b4886749e040c7a7d3aab8a57f85c631kotlin-android-extensions-runtime-1.3.61.jar;C:Usersosun.gradlecachesmodules-2files-2.1org.jetbrains.kotlinkotlin-stdlib-jdk71.3.6170dffc5f8ac5ea7c34f30deac5b9d8b1d48af066kotlin-stdlib-jdk7-1.3.61.jar;C:Usersosun.gradlecachesmodules-2files-2.1org.jetbrains.kotlinkotlin-stdlib1.3.614702105e97f7396ae41b113fdbdc180ec1eb1e36kotlin-stdlib-1.3.61.jar;C:Usersosun.gradlecachesmodules-2files-2.1org.jetbrains.kotlinkotlin-stdlib-common1.3.6165abb71d5afb850b68be03987b08e2c864ca3110kotlin-stdlib-common-1.3.61.jar;C:Usersosun.gradlecachesmodules-2files-2.1org.jetbrainsannotations13.0919f0dfe192fb4e063e7dacadee7f8bb9a2672a9annotations-13.0.jar;C:Usersosun.gradlecachesmodules-2files-2.1androidx.collectioncollection1.0.042858b26cafdaa69b6149f45dfc2894007bc2c7acollection-1.0.0.jar;C:Usersosun.gradlecachesmodules-2files-2.1androidx.lifecyclelifecycle-common2.0.0e070ffae07452331bc5684734fce6831d531785clifecycle-common-2.0.0.jar;C:Usersosun.gradlecachesmodules-2files-2.1androidx.arch.corecore-common2.0.0b21b9a11761451b51624ac428d1f1bb5deeac38core-common-2.0.0.jar;C:Usersosun.gradlecachesmodules-2files-2.1androidx.annotationannotation1.0.22f1d597d48e5309e935ce1212eedf5ae69d3f97annotation-1.0.2.jar;C:Usersosun.gradlecachesransforms-2files-2.14400ce52558a1326f6f8df052592e334core-ktx-1.0.2jarsclasses.jar;C:Usersosun.gradlecachesransforms-2files-2.1879984f11f327e0566da31edd3b93778appcompat-1.0.2jarsclasses.jar;C:Usersosun.gradlecachesransforms-2files-2.1879984f11f327e0566da31edd3b93778appcompat-1.0.2
es;C:Usersosun.gradlecachesransforms-2files-2.19ac1dcdf45a51c129ec9ab070abfd8d7fragment-1.0.0jarsclasses.jar;C:Usersosun.gradlecachesransforms-2files-2.19b9150b07929bc69439efe995438be41vectordrawable-animated-1.0.0jarsclasses.jar;C:Usersosun.gradlecachesransforms-2files-2.159d04c87522e7722ea3ca8715a8b0d7dlegacy-support-core-ui-1.0.0jarsclasses.jar;C:Usersosun.gradlecachesransforms-2files-2.1e8e43754c06475d8590f4ff699e532f8legacy-support-core-utils-1.0.0jarsclasses.jar;C:Usersosun.gradlecachesransforms-2files-2.1f918a2c43bb058b74c18b9596e2a2796vectordrawable-1.0.1jarsclasses.jar;C:Usersosun.gradlecachesransforms-2files-2.1d1a473dd41ab9d9cfedb415a767fa8e2loader-1.0.0jarsclasses.jar;C:Usersosun.gradlecachesransforms-2files-2.128a2f2bfe5b19437baae53dd908102d9viewpager-1.0.0jarsclasses.jar;C:Usersosun.gradlecachesransforms-2files-2.1ced0565cf77ede6c9fe2cc907e012eb2coordinatorlayout-1.0.0jarsclasses.jar;C:Usersosun.gradlecachesransforms-2files-2.1ced0565cf77ede6c9fe2cc907e012eb2coordinatorlayout-1.0.0
es;C:Usersosun.gradlecachesransforms-2files-2.1e17e0903cc4b356cac1f1cdb05efef6drawerlayout-1.0.0jarsclasses.jar;C:Usersosun.gradlecachesransforms-2files-2.13bb2c7104f2f4e21e4344de7d5162af7slidingpanelayout-1.0.0jarsclasses.jar;C:Usersosun.gradlecachesransforms-2files-2.1e4f940674933431d2ed1592b500f2e4ecustomview-1.0.0jarsclasses.jar;C:Usersosun.gradlecachesransforms-2files-2.14cc9299baa04d807d8b5ed7d258aef09swiperefreshlayout-1.0.0jarsclasses.jar;C:Usersosun.gradlecachesransforms-2files-2.170edb5ab10f0c6baaf068d26450280d2asynclayoutinflater-1.0.0jarsclasses.jar;C:Usersosun.gradlecachesransforms-2files-2.1de5344dd836d92b3a6c11207c599e3dcore-1.0.2jarsclasses.jar;C:Usersosun.gradlecachesransforms-2files-2.1de5344dd836d92b3a6c11207c599e3dcore-1.0.2
es;C:Usersosun.gradlecachesransforms-2files-2.11df4b1ae03d2b473d0219ecebc547a11versionedparcelable-1.0.0jarsclasses.jar;C:Usersosun.gradlecachesransforms-2files-2.1a5cd9e8e0d405c18c2b2d3ee49201e52cursoradapter-1.0.0jarsclasses.jar;C:Usersosun.gradlecachesransforms-2files-2.14ec2bbfd3859804671a6ce6c91e03a8cdocumentfile-1.0.0jarsclasses.jar;C:Usersosun.gradlecachesransforms-2files-2.19d992e7c041153936c4b20c6e9d00821localbroadcastmanager-1.0.0jarsclasses.jar;C:Usersosun.gradlecachesransforms-2files-2.199907df3d56060bc7b1502dcd5ee124bprint-1.0.0jarsclasses.jar;C:Usersosun.gradlecachesransforms-2files-2.199a636cd82617c988188441746e7f20dlifecycle-viewmodel-2.0.0jarsclasses.jar;C:Usersosun.gradlecachesransforms-2files-2.1c20fb0ee45b96eb0e4b0a639b2ec1f4dlifecycle-runtime-2.0.0jarsclasses.jar;C:Usersosun.gradlecachesransforms-2files-2.17b586029e966589a4a60caf5a0a6e9d2interpolator-1.0.0jarsclasses.jar;C:Usersosun.gradlecachesransforms-2files-2.1d94f7826feb0de043e3c43244f79749alifecycle-livedata-2.0.0jarsclasses.jar;C:Usersosun.gradlecachesransforms-2files-2.1e31b9daaaa8bb7510409960c20556b7elifecycle-livedata-core-2.0.0jarsclasses.jar;C:Usersosun.gradlecachesransforms-2files-2.1373d10fc23cf87276d7fbe4eda833447core-runtime-2.0.0jarsclasses.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.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…