【发布时间】:2018-06-23 03:27:53
【问题描述】:
我尝试在 github 上上传我的工作项目,但未能上传 XML 文件并以某种方式丢失了它们,因为我以前从未使用过 github,现在当我为我的项目重新编写 XML 文件时,我正面临来自编译器的此错误:
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)
我已经为此寻找解决方案并找到了这个解决方案,但它对我不起作用:https://stackoverflow.com/a/47126127/6473155
Here's the full picture of the error i'm getting:
我的应用级 gradle 文件:
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'
编辑:我的启动器活动的 xml 文件是:
<?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>
清单看起来像这样:
<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>
我的新 XML 文件没有上传到 github,因为我在提交时没有检查它们,their java files also got corrupted like that 所以我通过删除
【问题讨论】:
-
所以您丢失了 res 文件夹中的所有内容?你的清单文件呢?
-
能贴出导致这个错误的xml文件吗?
-
不,我没有丢失所有东西,我已经将我的整个项目(以前的版本)上传到了 github,这些文件是安全的。最近上传后,我只丢失了我制作的新 XML 文件,而且我的新 java 文件也损坏了。
-
@Sub6Resources 我已经上传了启动器 XML 文件。请检查一下。
-
@flopshot 有效,所以诀窍是使用最新的构建版本,对吗?