카카오링크(android) : gradle 오류문의

환경설정을 제대로 했는데 에러가 계속 납니다.
아래의 소스를 보시고 답변 부탁드립니다.


● 1) project : build.gradle

buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath ‘com.android.tools.build:gradle:3.1.0’

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files

    classpath 'com.google.gms:google-services:3.2.0'
}

}
allprojects {
repositories {
google()
jcenter()

    mavenCentral()
    maven { url 'http://devrepo.kakao.com:8088/nexus/content/groups/public/' }
}

}

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

● 2) app : build.gradle

apply plugin: ‘com.android.application’

android {
compileSdkVersion 26
defaultConfig {
applicationId “kr.co.itrap.itrap”
minSdkVersion 15
targetSdkVersion 26
versionCode 40
versionName “3.2.8”
testInstrumentationRunner “android.support.test.runner.AndroidJUnitRunner”
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’
}
}
}

dependencies {
implementation fileTree(dir: ‘libs’, include: [’*.jar’])
implementation ‘com.android.support:appcompat-v7:26.1.0’
implementation ‘com.android.support:support-v4:26.1.0’

//compile 'com.google.firebase:firebase-core:12.0.0'
compile 'com.google.firebase:firebase-messaging:11.8.0' // Firebase Cloud Message
compile 'com.squareup.okhttp3:okhttp:3.9.0'                 // HTTP 통신(get, post, put..) : http://square.github.io/okhttp/
compile 'org.jsoup:jsoup:1.8.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

/****************************************************************************************************
 위에  implementation 'com.android.support:appcompat-v7:26.1.0' 부분이 에러나는데
 아래의 카카오링크 부분 주석시 오류가 나지 않음!
****************************************************************************************************/
// 카카오링크 sdk를 사용하기 위해 필요.
compile group: 'com.kakao.sdk', name: 'kakaolink', version: project.KAKAO_SDK_VERSION

}
apply plugin: ‘com.google.gms.google-services’


● 3) gradle.properties

org.gradle.jvmargs=-Xmx1536m

카카오

KAKAO_SDK_GROUP=com.kakao.sdk
KAKAO_SDK_VERSION=1.9.0


● 에러내용

E/AndroidRuntime: FATAL EXCEPTION: main
Process: kr.co.itrap.itrap, PID: 19788
java.lang.NoSuchMethodError: No static method getFont(Landroid/content/Context;ILandroid/util/TypedValue;ILandroid/widget/TextView;)Landroid/graphics/Typeface; in class Landroid/support/v4/content/res/ResourcesCompat; or its super classes (declaration of ‘android.support.v4.content.res.ResourcesCompat’ appears in /data/app/kr.co.itrap.itrap-1/split_lib_dependencies_apk.apk)
at android.support.v7.widget.TintTypedArray.getFont(TintTypedArray.java:119)
at android.support.v7.widget.AppCompatTextHelper.updateTypefaceAndStyle(AppCompatTextHelper.java:208)
at android.support.v7.widget.AppCompatTextHelper.loadFromAttributes(AppCompatTextHelper.java:110)
at android.support.v7.widget.AppCompatTextHelperV17.loadFromAttributes(AppCompatTextHelperV17.java:38)
at android.support.v7.widget.AppCompatTextView.(AppCompatTextView.java:81)
at android.support.v7.widget.AppCompatTextView.(AppCompatTextView.java:71)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:103)
at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1024)
at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1081)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:732)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at kr.co.itrap.itrap.FullscreenActivity.onCreate(FullscreenActivity.java:180)
at android.app.Activity.performCreate(Activity.java:6288)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2758)
at android.app.ActivityThread.access$900(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5942)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

위 에러 메시지는 제가 보기에 서포트 라이브러리의 버전이 맞지 않아서 발생하는 문제 같아요.

개발자님이 쓰시는 버전, firebase가 쓰는 버전, 카카오 SDK가 사용하는 버전이 다를 경우에 런타임 예외가 발생할 수 있는데요. 우선 카카오 SDK에서는 프래그먼트 등 제한적인 부분에서만 서포트 라이브러리를 사용하므로 문제가 되는 버전을 exclude 하는 방식으로 먼저 시도해 보시는게 맞을 것 같아요.

dependencies {
    api('com.android.support:recyclerview-v7:22.2.0') {
       exclude module: 'support-v4'
    }
 }

https://medium.com/mindorks/avoiding-conflicts-in-android-gradle-dependencies-28e4200ca235

위와 같은 블로그 포스트 들에도 어떻게 conflict를 해결할 수 있는지 간단하게 나와있어요 :slight_smile: