简体   繁体   English

Android Studio预览标题

[英]Android Studio Preview Header

Recently I opened android studio to find that the App preview was not working at all. 最近,我打开了android studio,发现该应用程序预览根本无法正常工作。 After coming on here it was advised to add base in front of the path name inside of the android manifest style tag like so: 进入这里后,建议在android manifest样式标签内的路径名前面添加base,如下所示:

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">

originally it was (As you can see without the Base tag): 最初是这样(如您所见,没有Base标签):

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

My problem now is that it works but no matter what I do when I first start an app I HAVE to add base to the beginning of the style name mentioned above and I also cannot see the ACTUAL theme I am working on in the app preview section. 我现在的问题是,它可以正常工作,但是无论我第一次启动我要在上述样式名称开头添加基础的应用程序时该怎么做,而且在应用程序预览部分中我也看不到正在使用的ACTUAL主题。 I have tried changing the Theme to the Theme Thats in my style tag which is DarkActionBAr but all it does is then gives me the following error: 我曾尝试将样式标签中的主题更改为DarkActionBAr中的主题,但这只是给我以下错误:

The following classes could not be instantiated: - android.support.v7.widget.ActionBarContainer (Open Class, Show Exception, Clear Cache) - android.support.v7.widget.ActionBarContextView (Open Class, Show Exception, Clear Cache) - android.support.v7.app.WindowDecorActionBar (Open Class, Show Exception, Clear Cache) Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE. 无法实例化以下类:-android.support.v7.widget.ActionBarContainer(打开类,显示异常,清除缓存)-android.support.v7.widget.ActionBarContextView(打开类,显示异常,清除缓存)-android .support.v7.app.WindowDecorActionBar(打开类,显示异常,清除缓存)提示:在IDE中显示时,在自定义视图中使用View.isInEditMode()可以跳过代码或显示示例数据。 If this is an unexpected error you can also try to build the project, then manually refresh the layout. 如果这是意外错误,您也可以尝试构建项目,然后手动刷新布局。 Exception Details java.lang.ClassNotFoundException: android.view.View$OnUnhandledKeyEventListener Copy stack to clipboard 异常详细信息java.lang.ClassNotFoundException:android.view.View $ OnUnhandledKeyEventListener复制堆栈到剪贴板

and

Failed to load AppCompat ActionBar with unknown error. 无法加载具有未知错误的AppCompat ActionBar。

As always any help would be greatly appreciated. 一如既往,任何帮助将不胜感激。 Thank You 谢谢

Okay So after 2 hours of trying everything from deleting everything to searching everywhere I have come up with the answer. 好了,经过2个小时的尝试,从删除所有内容到在任何地方搜索,我都给出了答案。

My problem was with the compileSdkVersion. 我的问题是compileSdkVersion。 I had it set to 28. After checking another app that I had done a few days ago that was still working fine I went in and checked all the settings and compared them. 我将其设置为28。在检查了几天前完成的另一个应用程序后,该应用程序仍然可以正常工作,然后我检查了所有设置并进行了比较。

Afterward I rolled the other app back to 27 by changing the following inside of build.gradle: 之后,通过更改build.gradle中的以下内容,将其他应用回滚到27。

from: 从:

compileSdkVersion 28

To: 至:

compileSdkVersion 27

from: 从:

implementation 'com.android.support:appcompat-v7:28.0.0-beta01'

to: 至:

implementation 'com.android.support:appcompat-v7:27.1.1'

Hopefully this will help others if you run into this problem. 如果您遇到此问题,希望对其他人有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM