0

Recently i have update the android gradle and support library version in android. But now for me it showing issue in xml layout setContentView(R.layout.main). It show error like this

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/com.test.app-1/base.apk:classes6.dex)

If i removed Textview from the layout its not showing any issues and working fine. But I need Textview how can i solve this issue.

I have set version like this

compileSdkVersion 26
buildToolsVersion '26.0.2'
minSdkVersion 16
targetSdkVersion 26

compile 'com.android.support:appcompat-v7:26.0.2'
compile 'com.android.support:design:26.0.2'
compile 'com.android.support:support-v4:26.0.2'
compile 'com.android.support:recyclerview-v7:26.0.2'
compile 'com.android.support:cardview-v7:26.0.2'


classpath 'com.android.tools.build:gradle:3.0.0'

XML

<TextView 
  style="@style/TextAppearance.TitleTwo" 
  android:layout_width="match_parent" 
  android:layout_height="wrap_content" 
  android:gravity="center" 
  android:padding="4dp" 
  android:text="@string/go_shopping" 
  android:textColor="@color/black" />

1 Answers1

0

change your build tool version to same as support library version

compileSdkVersion 26
buildToolsVersion '26.0.2'
minSdkVersion 16
targetSdkVersion 26

compile 'com.android.support:appcompat-v7:26.0.2'
compile 'com.android.support:design:26.0.2'
compile 'com.android.support:support-v4:26.0.2'
compile 'com.android.support:recyclerview-v7:26.0.2'
compile 'com.android.support:cardview-v7:26.0.2'

classpath 'com.android.tools.build:gradle:3.0.0'

I have faced same problem and it worked for me :)

Shankar
  • 2,890
  • 3
  • 25
  • 40