libktx / ktx

Kotlin extensions for the libGDX game framework
https://libktx.github.io/
Creative Commons Zero v1.0 Universal
1.35k stars 71 forks source link

Error after including KTX in Android project #128

Closed tneginareb closed 6 years ago

tneginareb commented 6 years ago

java.lang.NoSuchMethodError: No static method getFont(Landroid/content/Context;ILandroid/util/TypedValue;ILandroid/widget/TextView;)

After I implemented KTX in build.gradle, after build process, this error occurred.

czyzby commented 6 years ago
  1. Are you using KTX for Gradle build scripting or in your application?
  2. Did that error occur right after including an extra dependency or did some KTX code triggered it?
  3. Does your application work with pure LibGDX?
  4. Which KTX modules are you using?

Please include your build.gradle files or the whole project. Also, add whole stack traces in issues. You can run Gradle with --stacktrace.

tneginareb commented 6 years ago

Hey @czyzby , initially thank you for the quick response.

  1. In my Application
  2. An error occurred after including KTX, I didn't use any KTX code. I just add the dependency. (I added dagger dependency but I don't think that this dependency can have any mutual issue?)
  3. Nope
  4. I didn't have a chance to build the project initially.

my build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {

    compileSdkVersion 27
    defaultConfig {
        applicationId "com.myapp.gb"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 2
        versionName "1.0"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    // Script Properties
    def google_android_version = '11.8.0'
    def android_support_version = '26.1.0'
    def anko_version = '0.10.4'
    def retrofit2_version = '2.3.0'
    def dagger2_version = '2.13'

    implementation fileTree(include: ['*.jar'], dir: 'libs')
    // Kotlin Framework
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    // Anko Kotlin Helper
    implementation "org.jetbrains.anko:anko:$anko_version"
    implementation "org.jetbrains.anko:anko-commons:$anko_version"
    // Kotlin Extensions
    **implementation 'androidx.core:core-ktx:0.1'**

    // View Libraries
    implementation "com.android.support:appcompat-v7:$android_support_version"
    implementation "com.android.support:cardview-v7:$android_support_version"
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'me.relex:circleindicator:1.2.2@aar'
    // Rating View
    implementation 'com.iarcuschin:simpleratingbar:0.1.5'
    //App Loader
    implementation 'com.wang.avi:library:2.1.3'
    //Image Loader
    implementation("com.github.bumptech.glide:glide:4.6.1") {
        exclude group: "com.android.support"
    }

    // Google
    implementation "com.google.android.gms:play-services-maps:$google_android_version"
    implementation "com.google.android.gms:play-services-location:$google_android_version"
    // Firebase FCM
    implementation "com.google.firebase:firebase-messaging:$google_android_version"
//    implementation 'com.firebase:firebase-jobdispatcher:0.8.5'

    // Permission Helper Library
    implementation 'com.karumi:dexter:4.2.0'

    // retrofit
    implementation "com.squareup.retrofit2:retrofit:$retrofit2_version"
    implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit2_version"
    implementation "com.squareup.retrofit2:converter-gson:$retrofit2_version"

    implementation 'com.squareup.okhttp3:logging-interceptor:3.9.0'

    // rxandroid
    implementation "io.reactivex.rxjava2:rxandroid:2.0.1"

    //Depedency Injection Dagger2
    compile "com.google.dagger:dagger-android:$dagger2_version"
    kapt "com.google.dagger:dagger-android-processor:$dagger2_version"
    compileOnly "com.google.dagger:dagger:$dagger2_version"
    kapt "com.google.dagger:dagger-compiler:$dagger2_version"

}
apply plugin: 'com.google.gms.google-services'
czyzby commented 6 years ago

implementation 'androidx.core:core-ktx:0.1'

This is not our library. You wanted to be here.

tneginareb commented 6 years ago

@czyzby yes you're right. My mistake, sorry for that!

czyzby commented 6 years ago

It's OK, don't worry - I expected such issues since Google released their library with a similar name. Bookmark us, and give LibKTX a try if you ever wanted to develop some 2D games, though. ;)