2

I tried to upload my working project on github but failed to upload XML files and lost them somehow because I have never used github before, now when I re write the XML files for my project I'm facing this error from the compiler:

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.example.syyam.dietplan-1/base.apk)

I have looked for the solution for this and found this solution but it didn't work for me: https://stackoverflow.com/a/47126127/6473155

Here's the full picture of the error i'm getting:

My app level gradle file:

apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "27.0.3"
defaultConfig {
    applicationId "com.example.syyam.dietplan"
    minSdkVersion 19
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    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'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
//noinspection GradleCompatible
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.firebaseui:firebase-ui-database:0.4.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-auth:12.0.1'
implementation 'com.google.firebase:firebase-database:12.0.1'
implementation 'com.jjoe64:graphview:4.2.2'
testImplementation 'junit:junit:4.12'

}apply plugin: 'com.google.gms.google-services'

Edit: the xml file of my launcher acctivity is:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".EEG">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="35dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="15dp"
            android:layout_marginBottom="10dp"
            android:orientation="horizontal"
            >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:textSize="19dp"
                android:text="Alpha   "
                />
            <SeekBar
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="12"
                android:layout_marginLeft="5dp"
                android:id="@+id/mSeekAlpha"/>

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:id="@+id/alphaCount"
                android:text="0.0"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="5dp"
                android:textSize="18dp"

                />

        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="35dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="15dp"
            android:layout_marginBottom="10dp"
            android:orientation="horizontal">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:textSize="20dp"
                android:text="Beta     "/>
            <SeekBar
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="12"
                android:layout_marginLeft="5dp"
                android:id="@+id/mSeekBeta"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:id="@+id/betaCount"
                android:text="0.0"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="5dp"
                android:textSize="18dp"

                />
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="35dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="15dp"
            android:layout_marginBottom="10dp"
            android:orientation="horizontal">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:textSize="20dp"
                android:text="Delta    "/>
            <SeekBar
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="12"
                android:layout_marginLeft="5dp"
                android:id="@+id/mSeekDelta"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:id="@+id/deltaCount"
                android:text="0.0"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="5dp"
                android:textSize="18dp"

                />
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="35dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="15dp"
            android:layout_marginBottom="10dp"
            android:orientation="horizontal">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:textSize="20dp"
                android:text="Theta   "/>
            <SeekBar
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="12"
                android:layout_marginLeft="5dp"
                android:id="@+id/mSeekTheta"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:id="@+id/thetaCount"
                android:text="0.0"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="5dp"
                android:textSize="18dp"

                />
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="35dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="15dp"
            android:layout_marginBottom="10dp"
            android:orientation="horizontal">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:textSize="19dp"
                android:text="Gamma"/>
            <SeekBar
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="12"
                android:layout_marginLeft="5dp"
                android:id="@+id/mSeekGamma"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:id="@+id/gammaCount"
                android:text="0.0"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="5dp"
                android:textSize="18dp"

                />
        </LinearLayout>
        <Button
            android:id="@+id/subBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_margin="10dp"
            android:background="@color/colorPrimaryDark"
            android:paddingLeft="10dp"
            android:paddingRight="10dp"
            android:text="Submit"
            android:textColor="@android:color/background_light"
            android:textSize="16dp"
            android:textStyle="bold"
            />
    </LinearLayout>
</RelativeLayout>

and the manifest looks like that:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.syyam.dietplan">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".EEG">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".LoginActivity" />
        <activity android:name=".RegisterActivity" />
        <activity android:name=".Suffering" />
        <activity android:name=".DisorederWebView" />
        <activity android:name=".ChoosePlan" />
        <activity android:name=".Schedule" />
        <activity android:name=".DailyAppContent" />
        <activity android:name=".WeeklyAppContent" />
        <activity android:name=".MonthlyAppContent" />
        <activity android:name=".OverallSchedule" />
        <activity android:name=".WeeklyDailyAppContent" />
        <activity android:name=".MonthlyDailyAppContent" />
        <activity android:name=".chooseTestType" />
        <activity android:name=".history" />
        <activity android:name=".MainActivity" />
    </application>

</manifest>

My new XML files didn't get upload on the github because I remained them unchecked while committing and their java files also got corrupted like that So I corrected them manually by removing the <<<<<

Syyam Noor
  • 474
  • 5
  • 15

1 Answers1

0

The problem is that your buildtoolsversion major number 27.x.x is not the same as your compilesdkversion number 26 in your app: build.gradle file.

Each sdk release comes with a buildtools release specifically for that sdk, and they usually aren’t back ported, so your buildtools 27.x.x has no idea how to build with the sdk 26. Android Studio should have displayed a lint warning highlighting the error.

flopshot
  • 1,153
  • 1
  • 16
  • 23