【问题标题】:Gradle sync failed causing 'Preview is unavailable until after a successful build project sync'Gradle 同步失败导致“在成功构建项目同步后预览不可用”
【发布时间】:2019-07-29 17:39:21
【问题描述】:

我正在尝试打开一个非常旧的 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。 从清单中删除它解决了这个问题。

【问题讨论】:

    标签: java android android-studio


    【解决方案1】:
    <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.
    

    【讨论】:

    • 还是一样的:\
    【解决方案2】:

    您可以尝试删除 .gradle 文件夹吗?这可能会解决我认为的问题。

    【讨论】:

    • 这是评论,不是答案!
    猜你喜欢
    • 1970-01-01
    • 2018-05-30
    • 2015-06-10
    • 1970-01-01
    • 2016-12-29
    • 1970-01-01
    相关资源
    最近更新 更多