更新搞砸的Android Studio环境 [英] Update messed up Android Studio environment
问题描述
更新的Android Studio和一切通过SDK管理器相关的之后,我再也不能创建简单的包含一个空白活动的应用程序,因为所有这些渲染问题。选择一个空的活动似乎仍然可控,但。
说回我的空白活动的问题,这是我的环境内容摘要:
Android的工作室1.5.1
Android SDK工具24.4.1
Android SDK中平台工具23.1
Android SDK中构建工具23.0.2
Android的支持库23.2
我看到一吨在两个activity_main.xml中和content_main.xml渲染问题的错误消息。我改变了主题Holo浅色,我降级在IDE中的API级至19日,但无济于事。我都activity_main.xml中和content_main.xml上展示变灰CoordinatorLayout。所以,我不能再拖累任何组件到IDE中的布局。我缺少什么?!
编辑2016年3月10日:添加的设置细节和错误信息......
这是我的应用程序的文件的build.gradle:
应用插件:'com.android.application安卓{
compileSdkVersion 23
buildToolsVersion23.0.2 defaultConfig {
的applicationIDcom.udemycourse.notes
19的minSdkVersion
targetSdkVersion 23
版本code 1
的versionName1.0
}
buildTypes {
发布 {
minifyEnabled假
proguardFiles getDefaultProguardFile('proguard的-android.txt'),'proguard-rules.pro
}
}
}依赖{
编译文件树(导演:'库',包括:['的* .jar'])
testCompile'的JUnit:JUnit的:4.12
编译com.android.support:appcompat-v7:23.2.0
编译com.android.support:design:23.2.0
}
缺少的款式。是正确的主题选择了此布局?
注:一个或多个布局缺少layout_width或layout_height属性。这些都需要在大多数布局。
以下类不能被实例化:
android.support.design.widget.AppBarLayout
android.support.design.widget.CoordinatorLayout
android.support.design.widget.FloatingActionButton
在渲染窗口中显示的例外:
java.lang.IllegalArgumentException异常:您需要使用Theme.AppCompat主题(或后代)的设计库。在
android.support.design.widget.ThemeUtils.checkAppCompatTheme(ThemeUtils.java:34)
在
android.support.design.widget.AppBarLayout(AppBarLayout.java:145)
在sun.reflect.NativeConstructorAccessorImpl.newInstance0(母语
法)在
sun.reflect.NativeConstructorAccessorImpl.newInstance(来源不明)
在sun.reflect.DelegatingConstructorAccessorImpl.newInstance(未知
源)在java.lang.reflect.Constructor.newInstance(来源不明)
在
org.jetbrains.android.ui preview.ViewLoader.createNewInstance(ViewLoader.java:458)
在
org.jetbrains.android.ui preview.ViewLoader.loadClass(ViewLoader.java:170)
在
org.jetbrains.android.ui preview.ViewLoader.loadView(ViewLoader.java:103)
在
com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:168)
在
android.view.BridgeInflater.loadCustomView(BridgeInflater.java:247)
在
android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:171)
在
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
在
android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:835)
在
android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
在android.view.LayoutInflater.rInflate(LayoutInflater.java:811)在
android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
在android.view.LayoutInflater.inflate(LayoutInflater.java:515)在
android.view.LayoutInflater.inflate(LayoutInflater.java:394)在
com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:223)
在com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:426)
在
com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
在
com.android.tools.idea.rendering.RenderTask $ 2.compute(RenderTask.java:510)
在
com.android.tools.idea.rendering.RenderTask $ 2.compute(RenderTask.java:498)
在
com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:888)
在
com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:498)
在
com.android.tools.idea.rendering.RenderTask.access $ 600(RenderTask.java:72)
在
com.android.tools.idea.rendering.RenderTask $ 3.call(RenderTask.java:610)
在
com.android.tools.idea.rendering.RenderTask $ 3.call(RenderTask.java:607)
在
com.android.tools.idea.rendering.RenderService.runRenderAction(RenderService.java:362)
在
com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:607)
在
com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:629)
在
com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel$6.run(AndroidDesignerEditorPanel.java:480)
在
com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
在
com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
在
com.intellij.util.ui.update.MergingUpdateQueue $ 2.run(MergingUpdateQueue.java:254)
在
com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
在
com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
在
com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
在
com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
在com.intellij.util.Alarm $ $请求1.run(Alarm.java:351)在
java.util.concurrent.Executors $ RunnableAdapter.call(来源不明)
在java.util.concurrent.FutureTask.run(来源不明)在
java.util.concurrent.ThreadPoolExecutor.runWorker(来源不明)在
java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(来源不明)在
java.lang.Thread.run(来源不明)
块引用>解决方案事情你应该照顾,而使用
应用紧凑型
与沿工具栏
正在使用Theme.AppCompat
主题的继承人这样的主题的 AppTheme 。正如你所得到的当前错误。<样式名称=AppTheme父=Theme.AppCompat.Light.DarkActionBar>
<! - 在这里自定义的主题。 - >
<项目名称=colorPrimary> @彩色/ colorPrimary< /项目>
<项目名称=colorPrimaryDark> @彩色/ colorPrimaryDark< /项目>
<项目名称=colorAccent> @彩色/ colorAccent< /项目>
<项目名称=windowActionBar>假LT; /项目>
<项目名称=windowNoTitle>真< /项目>
< /风格>在你的
的AndroidManifest.xml
文件,确保您的应用程序的元素有这个属性安卓主题=@风格/ AppTheme
。您可能需要删除从单个活动的主题属性。
例如:
块引用><应用
机器人:allowBackup =真
机器人:图标=@的mipmap / ic_launcher
机器人:标签=@字符串/ APP_NAME
机器人:supportsRtl =真
机器人:主题=@风格/ AppTheme>如果你还在这个项目面临的一些配置问题,请检查该库,这是虚设code,但你可以把它比你的项目。如果你仍然面临的问题让我知道。
您可能需要使用这些替换
的build.gradle
依赖编译com.android.support:appcompat-v7:23.1.1
编译com.android.support:design:23.1.1
编译com.android.support:support-v4:23.1.1文件= GT;项目结构= GT;现在点击给出模块,然后对依赖的
应用程序。
After updating Android Studio and everything related via the SDK Manager, I can no longer create the simplest of apps containing a single Blank Activity, because of all these rendering problems. Choosing an Empty Activity still seems manageable though.
Coming back to my Blank Activity issue, this is a summary of my environment:
Android Studio 1.5.1 Android SDK Tools 24.4.1 Android SDK Platform Tools 23.1 Android SDK Build Tools 23.0.2 Android Support Library 23.2
I see a ton of rendering problem error messages on both activity_main.xml and content_main.xml. I changed the theme to Holo Light, I downgraded the API level in the IDE to 19, but to no avail. I have both activity_main.xml and content_main.xml displaying grayed out CoordinatorLayout. So I cannot drag any components onto the layout in the IDE. What am I missing?!
Edit 3/10/2016: Adding detail on setup and the error messages...
This is my app's build.gradle file:
apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultConfig { applicationId "com.udemycourse.notes" minSdkVersion 19 targetSdkVersion 23 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.2.0' compile 'com.android.support:design:23.2.0' }
Missing styles. Is the correct theme chosen for this layout? Note: One or more layouts are missing the layout_width or layout_height attributes. These are required in most layouts. The following classes could not be instantiated: android.support.design.widget.AppBarLayout android.support.design.widget.CoordinatorLayout android.support.design.widget.FloatingActionButton
Exception displayed in the rendering window: java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the design library. at android.support.design.widget.ThemeUtils.checkAppCompatTheme(ThemeUtils.java:34) at android.support.design.widget.AppBarLayout.(AppBarLayout.java:145) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:458) at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:170) at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:103) at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:168) at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:247) at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:171) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:835) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70) at android.view.LayoutInflater.rInflate(LayoutInflater.java:811) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:394) at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:223) at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:426) at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350) at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:510) at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:498) at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:888) at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:498) at com.android.tools.idea.rendering.RenderTask.access$600(RenderTask.java:72) at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:610) at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:607) at com.android.tools.idea.rendering.RenderService.runRenderAction(RenderService.java:362) at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:607) at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:629) at com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel$6.run(AndroidDesignerEditorPanel.java:480) at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320) at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310) at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254) at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269) at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227) at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217) at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238) at com.intellij.util.Alarm$Request$1.run(Alarm.java:351) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)
解决方案Things you should take care of while using
App Compact
along withToolbar
that you are using a decedent ofTheme.AppCompat
Theme like this Theme AppTheme. As you are getting the current error.<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="windowActionBar">false</item> <item name="windowNoTitle">true</item> </style>
In your
AndroidManifest.xml
file make sure your application element has this attributeandroid:theme="@style/AppTheme"
. you may want to remove theme attribute from individual Activities.Eg
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme">
if you are still facing some configuration issues with the project, kindly check this repository, it's a dummy code but you can compare your project with it. If you are still facing issue let me know.
You might want to replace
build.gradle
dependencies with thesecompile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:design:23.1.1' compile 'com.android.support:support-v4:23.1.1' File => Project Structure =>
now click on the
app
in given module and then on dependencies.这篇关于更新搞砸的Android Studio环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!