我将Android Studio更新为2.2,我的项目将不再构建.我的Activity的super.onCreate(savedInstanceState)给了我一个错误:
java.lang.NoSuchMethodError: No static method getDrawable(LandroID/content/Context;I)LandroID/graphics/drawable/Drawable; in class LandroID/support/v4/content/ContextCompat; or its super classes (declaration of 'androID.support.v4.content.ContextCompat' appears in /data/app/x.y.z-1/base.apk:classes32.dex) at androID.support.v7.Widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:197) at androID.support.v7.Widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:185) at androID.support.v7.Widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:720) at androID.support.v7.Widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:190) at androID.support.v7.Widget.TintTypedArray.getDrawableIfKNown(TintTypedArray.java:77) at androID.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:127) at androID.support.v7.app.AppCompatDelegateImplV9.<init>(AppCompatDelegateImplV9.java:147) at androID.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:27) at androID.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:50) at androID.support.v7.app.AppCompatDelegateImplV23.<init>(AppCompatDelegateImplV23.java:29) at androID.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:199) at androID.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:181) at androID.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:521) at androID.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71) at zz.yyy.xxx.activitIEs.AsdActivity.onCreate(AsdActivity.java:12) at androID.app.Activity.performCreate(Activity.java:6904) at androID.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136) at androID.app.ActivityThread.performlaunchActivity(ActivityThread.java:3266) at androID.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415) at androID.app.ActivityThread.access00(ActivityThread.java:229) at androID.app.ActivityThread$H.handleMessage(ActivityThread.java:1821) at androID.os.Handler.dispatchMessage(Handler.java:102) at androID.os.Looper.loop(Looper.java:148) at androID.app.ActivityThread.main(ActivityThread.java:7325) at java.lang.reflect.Method.invoke(Native Method) at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
我创建了一个全新的Activity来查看是否是我的代码导致问题,但它没有帮助.这是活动:
import androID.support.v7.app.AppCompatActivity;import androID.os.Bundle;public class AsdActivity extends AppCompatActivity { @OverrIDe protected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_asd); }}
这是我的build.gradle(app)
buildscript { repositorIEs { maven { url 'https://maven.fabric.io/public' } } dependencIEs { classpath 'io.fabric.tools:gradle:1.+' }}apply plugin: 'com.androID.application'apply plugin: 'io.fabric'repositorIEs { maven { url 'https://maven.fabric.io/public' }}androID { compileSdkVersion 24 buildToolsversion "23.0.3" defaultConfig { minSdkVersion 21 targetSdkVersion 24 ... } buildTypes { deBUG { ... MinifyEnabled false } release { ... MinifyEnabled false proguardfiles getDefaultProguardfile('proguard-androID.txt'), 'proguard-rules.pro' } }}dependencIEs { compile filetree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' compile('com.crashlytics.sdk.androID:crashlytics:2.5.5@aar') { transitive = true; } compile project(':VIEwlib') compile files('libs/commons-io-2.5.jar') compile project(':GrIDheaders') compile 'com.amazonaws:aws-androID-sdk-s3:2.2.16' compile 'com.Google.code.gson:gson:2.6.2' compile 'com.squareup.okhttp3:okhttp:3.2.0' compile 'com.github.franmontIEl:PersistentcookieJar:v0.9.3' compile 'com.amazonaws:aws-androID-sdk-mobileanalytics:2.2.9' compile('com.facebook.fresco:fresco:0.11.0') { exclude module: 'support-v4' } compile 'org.apache:pdfBox-androID:1.8.9.0' compile 'com.androID.support:appcompat-v7:24.2.1' compile 'com.androID.support:design:24.2.1'}
在此错误之前我得到了这个:java.lang.NoSuchMethodError: No static method setOnApplyWindowInsetsListener
在此之前,我有另一个类似的错误.两者都是通过更新我的支持库来修复的.现在我得到了appcompatv7和设计库的最新版本(24.2.1),所以我不知道我怎么做了.
解决方法:
我能够解决这个问题.在我的/ libs文件夹下,我有一个旧的androID-support-v13.jar,它是用gradle编译的.我的应用程序试图使用此.jar的ContextCompat类,并且该类没有静态getDrawable(Context)方法.删除这个.jar解决了我的问题.
总结以上是内存溢出为你收集整理的java.lang.NoSuchMethodError:没有静态方法getDrawable(Landroid / content / Context; I)Landroid / graphics /全部内容,希望文章能够帮你解决java.lang.NoSuchMethodError:没有静态方法getDrawable(Landroid / content / Context; I)Landroid / graphics /所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)