我该如何解决?
app.gradle
android {
compileSdkVersion 24
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "*****"
minSdkVersion 21
targetSdkVersion 24
versionCode 5
versionName "2.1.1"
multiDexEnabled true;
}
--
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.1'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'pl.bclogic:pulsator4droid:1.0.3'
compile project(path: ':libs:AlexaAndroid')
compile project(path: ':libs:RecorderLevelView')
compile project(path: ':libs:speechutils-master')
compile project(path: ':libs:pulsator4droid')
compile project(path: ':libs:MaterialRippleLayout')
compile project(path: ':libs:ListViewAnimations-core')
compile files('--/libs/universal-image-loader-1.9.3.jar')
compile files('--/libs/nineoldandroids-2.4.0.jar')
compile files('--/libs/listviewanimations_lib-manipulation_3.1.0.jar')
compile files('--/libs/listviewanimations_lib-core-slh_3.1.0.jar')
compile files('--/libs/android-support-v4.jar')
compile 'com.android.support:support-v4:24.2.0'
compile 'com.android.support:support-v13:24.2.0'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:support-vector-drawable:24.2.0'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:recyclerview-v7:24.2.0'
}
-- shows jar file path.
错误日志
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/com.***.***.***-1/base.apk)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:194)
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.AppCompatDelegate.create(AppCompatDelegate.java:201)
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 com.***.***.***.BaseActivity.onCreate(BaseActivity.java:70)
at com.***.***.***.MainActivity.onCreate(MainActivity.java:59)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Activity的super.onCreate(savedInstanceState)给出了一个错误: 应用程序与ADB设备一起正常工作或者如果我在设备上使用usb调试,那么它的工作正常,但它不适用于发布apk。
我不确定是否进行了任何gradle更新,我与旧版本相比没有任何差异。
答案 0 :(得分:1)
我解决了这个问题。
在项目库中,{lib}文件夹中的compile files('--/libs/listviewanimations_lib-core-slh_3.1.0.jar')
存在com.android.support:support-v4.jar
文件,所以gradle引用它的jar并给出错误NoSuchMethodError: No static method getDrawable in class ContextCompat; or its super classes declaration of 'android.support.v4.content.ContextCompat'
因为getDrawable函数未在com.android.support:support-v4.jar
文件中声明
从lib文件夹中删除com.android.support:support-v4.jar
并清理后,重建我的android项目并与gradle同步并为我工作。