Home > Enterprise >  Why Android Studio uses Java classes instead of Kotlin
Why Android Studio uses Java classes instead of Kotlin

Time:01-09

I am new to kotlin. So I created a kotlin project in Android Studio and imported Fragment-ktx and Activity-ktx dependencies. So in a Fragment when I right click on the fragment and then Go To->Implementations it just opens the Fragment.java file. When using the Fragment-ktx dependency is this normal? Any help would be great.

Here's my app.gradle file

android {
    compileSdkVersion 31
    defaultConfig {
        applicationId "com.xxxxxxx.xxxxxxxxxx"
        minSdk 23
        targetSdk 31
        versionCode 117
        versionName "3.2.11"
        vectorDrawables.generatedDensities = []
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/proguard/androidx-annotations.pro'
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        viewBinding true
    }
}

dependencies {
    implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
    implementation platform('com.google.firebase:firebase-bom:29.0.3')
    implementation 'com.google.firebase:firebase-analytics-ktx'
    implementation 'com.google.firebase:firebase-crashlytics-ktx'
    implementation 'com.google.firebase:firebase-messaging-ktx'
    implementation "androidx.core:core-ktx:1.7.0"
    implementation "androidx.activity:activity-ktx:1.4.0"
    implementation "androidx.fragment:fragment-ktx:1.4.0"
    implementation "androidx.collection:collection-ktx:1.2.0"
    implementation 'androidx.appcompat:appcompat:1.4.0'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation "androidx.preference:preference-ktx:1.1.1"
    implementation "androidx.biometric:biometric-ktx:1.2.0-alpha04"
    implementation 'androidx.work:work-runtime-ktx:2.7.1'
    implementation 'com.android.billingclient:billing:4.0.0'
    implementation 'com.android.volley:volley:1.2.1'
    implementation 'com.google.android.gms:play-services-ads:20.5.0'
    implementation 'com.google.android.play:core-ktx:1.8.1'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0'
    implementation 'com.github.lzyzsd:circleprogress:1.2.1'
    implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
    implementation 'com.nabinbhandari.android:permissions:3.8'
    implementation 'com.nex3z:toggle-button-group:1.2.3'
    implementation 'com.github.bumptech.glide:glide:4.12.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
    implementation "io.github.iamthevoid.batteryview:batteryview:0.6.1"
}

CodePudding user response:

There's nothing to be surprised about. Entire native SDK and most of jetpack libraries are pure java.

fragment-ktx just contains a bunch of extensions for fragment manager and viewmodels on top of inheriting androidx.fragment package.

  •  Tags:  
  • Related