gpt4 book ai didi

Android Studio 许多错误 : Could not find class 'android.XXX'

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:58:36 26 4
gpt4 key购买 nike

我正在使用 Android Studio 2.1.2,调试设备 android 4.4.2 API19,构建环境:

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
}

我已尝试重新打开项目、使缓存无效、禁用 instantRun,但我仍然不断收到如下错误:

06-24 01:15:08.302 27320-27320/org.linphone E/InstantRun: Could not find slices in APK; aborting.
06-24 01:15:08.322 27320-27320/org.linphone E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method org.linphone.LinphoneLauncherActivity.access$super
06-24 01:15:08.322 27320-27320/org.linphone E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method org.linphone.LinphoneLauncherActivity.access$super
06-24 01:15:08.322 27320-27320/org.linphone E/dalvikvm: Could not find class 'android.media.session.MediaController', referenced from method org.linphone.LinphoneLauncherActivity.access$super
06-24 01:15:08.322 27320-27320/org.linphone E/dalvikvm: Could not find class 'android.widget.Toolbar', referenced from method org.linphone.LinphoneLauncherActivity.access$super
06-24 01:15:08.332 27320-27320/org.linphone E/dalvikvm: Could not find class 'android.app.ActivityManager$TaskDescription', referenced from method org.linphone.LinphoneLauncherActivity.access$super
06-24 01:15:08.332 27320-27320/org.linphone E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method org.linphone.LinphoneLauncherActivity.access$super
06-24 01:15:08.332 27320-27320/org.linphone E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method org.linphone.LinphoneLauncherActivity.access$super
06-24 01:15:08.342 27320-27320/org.linphone E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method org.linphone.LinphoneLauncherActivity.access$super
06-24 01:15:08.342 27320-27320/org.linphone E/dalvikvm: Could not find class 'android.app.assist.AssistContent', referenced from method org.linphone.LinphoneLauncherActivity.access$super
06-24 01:15:08.352 27320-27320/org.linphone E/dalvikvm: Could not find class 'android.view.SearchEvent', referenced from method org.linphone.LinphoneLauncherActivity.access$super
06-24 01:15:08.352 27320-27320/org.linphone E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method org.linphone.LinphoneLauncherActivity.access$super

谁能帮帮我?

最佳答案

在阅读许多类似问题时,我发现启用 Multidex 可能会解决此问题,归功于 this answer from Bharath Kumar .他还发布了一些我推荐阅读的有用链接。至少它对我有用(准确地说:我现在只剩下这些错误中的 1 个,而以前有数百个)!

简而言之:只需在 gradle defaultConfig 中添加 multiDexEnabled true 并添加依赖项 compile 'com.android.support:multidex 即可启用 multidex :1.0.1'。最后,通过将这段代码添加到您的应用程序类来安装 Multidex:

@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}

当然,另一种选择是避免 64K 方法限制,因此您不再需要 MultiDex。您可以通过减少 Gradle 文件中(未使用的)依赖项的数量或使用更具体的依赖项(wittyurchin 在 this answer 中提供了一个很好的 google play-services 示例)来实现这一点。

但是,如果您确实需要 Multidex,那么您可能会遇到一些问题,例如我发现的问题:

1) 在构建目标 API 设备时禁用即时运行(当从 Android Studio 运行您的应用时,您会看到弹出的错误消息)。

2) 如果您使用 Robolectric 进行单元测试,您可能将无法再运行测试。您可以通过扩展之前的 MultiDex.install(this); 代码来解决此问题。与其自己解释一切,不如检查问题,并通过 here 回答 sschuberth 会更容易。 .

...

附言。似乎我不一定需要 compile 'com.android.support:multidex:1.0.1' 来让 MultiDex 工作,但是,我看到很多建议说它是必需的。如果有人对此有更多建议,请成为我的客人!

关于Android Studio 许多错误 : Could not find class 'android.XXX' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37998266/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com