首页 > 解决方案 > Gradle 同步失败,导致“在成功构建项目同步后预览不可用”

问题描述

我正在尝试打开一个非常旧的 android 应用程序,因为我需要对其进行升级。我更新了 Gradle 插件、Gradle 以及 SDK 工具,该项目正在我的设备上编译和运行。

问题是我无法使用我的 XML 文件的预览窗口并且我不断收到此错误 -

Gradle 同步失败:EventQueue.isDispatchThread()=false >Toolkit.getEventQueue()=com.intellij.ide.IdeEventQueue@15b8713b 当前线程:Thread[ApplicationImpl pooled thread >19,4,Idea Thread Group] 1926886061 SystemEventQueueThread:Thread[AWT -EventQueue-0,6,Idea >Thread Group] 686233834 (905 ms)

我试图清理和重建项目,试图使缓存无效并重新启动甚至重新启动计算机,因为我认为一个线程丢失了......

有人遇到过这个问题吗?

更新:

问题解决了。

我在 Manifest 和 Gradle 中都声明了minSdkVersiontargetSdkVersion 。从清单中删除它解决了这个问题。

标签: javaandroidandroid-studio

解决方案


<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
</style>
This is a common problem. It can be easily solved by changing res/values/styles.xml to

<!-- Base application theme. -->
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
</style>
Steps :
Go to res/values/
open styles.xml

change from -> style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"

change to -> style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar"

    (Just prepend "Base." to "Theme".)



Save the file and check Preview now.

Preview Works Perfectly now.

推荐阅读