重写XML文件后,出现错误java.lang.NoSuchMethodError:没有静态方法getFont ...

时间:2018-06-23 03:27:53

标签: android android-studio

我尝试将我的工作项目上传到github上,但是无法上传XML文件并以某种方式丢失了它们,因为我以前从未使用过github,现在当我为我的项目重新编写XML文件时,编译器将遇到此错误:

Warning: Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it.
in App

我一直在寻找解决方案并找到了解决方案,但是它对我不起作用:https://stackoverflow.com/a/47126127/6473155

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

我的应用程序级别gradle文件:

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)

} 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'

编辑:我的启动器可激活性的xml文件是:

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

清单是这样的:

<?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>

我的新XML文件未在github上上传,因为我在提交和their java files also got corrupted like that时未对其进行检查,因此我通过删除<<<<<

1 个答案:

答案 0 :(得分:0)

问题是您的buildtoolsversion主号码27.x.x与您的应用程序build.gradle文件中的compilesdkversion 26号码不同。

每个sdk发行版都带有一个专门针对该sdk的buildtools发行版,通常不会回移植,因此您的buildtools 27.xx不知道如何使用sdk 26进行构建。突出显示错误。