一、问题描述
国庆放假回来,编译项目突然间就编译不通过了,报错如下
AAPT: error: resource android:attr/lStar not found.
二、解决方式如下
在工程中app/build.gradle中的dependecies上面添加如下代码:
configurations.all {
resolutionStrategy {
force 'androidx.core:core:1.6.0'
force 'androidx.core:core-ktx:1.6.0'
}
}
三、别高兴的太早,请往下看!!!
当我还沉浸在编译通过的喜悦当中时,直接当头一棒,竟然直接crash了,报错如下:
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/view/MenuHost;
at java.lang.reflect.Executable.getParameterTypesInternal(Native Method)
at java.lang.reflect.Method.getParameterTypes(Method.java:179)
at java.lang.Class.getDeclaredMethods(Class.java:1881)
at org.greenrobot.eventbus.SubscriberMethodFinder.findUsingReflectionInSingleClass(SubscriberMethodFinder.java:154)
at org.greenrobot.eventbus.SubscriberMethodFinder.findUsingInfo(SubscriberMethodFinder.java:88)
at org.greenrobot.eventbus.SubscriberMethodFinder.findSubscriberMethods(SubscriberMethodFinder.java:64)
at org.greenrobot.eventbus.EventBus.register(EventBus.java:140)
at XXX.video.BaseActivity.onCreate(BaseActivity.java:26)
at android.app.Activity.performCreate(Activity.java:7023)
at android.app.Activity.performCreate(Activity.java:7014)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2772)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2897)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1623)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6548)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:473)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:859)
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.core.view.MenuHost" on path: DexPathList[[zip file "/data/app/xxx-6DRTzlhdidcesfS-OKBADw==/base.apk"],nativeLibraryDirectories=[/data/app/xxx-6DRTzlhdidcesfS-OKBADw==/lib/arm, /data/app/xxx-6DRTzlhdidcesfS-OKBADw==/base.apk!/lib/armeabi, /system/lib, /vendor/lib, /system/lib, /vendor/lib]]
解决办法如下:
configurations.all {
resolutionStrategy.eachDependency {
DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == "androidx.appcompat") {
if (requested.name == "appcompat") {
details.useVersion "1.3.1"
}
}
}