Android Studio组件未显示且应用程序未运行 [英] Android Studio components aren't displaying and app does not run
问题描述
我是Android Studio的新手,想知道为什么它对我真的不起作用.
I am new to Android Studio and want to know why it does not really work for me.
基本上,我只是通过观看在线课程开始学习Android Studio,因此我所做的事情与讲师对视频所做的事情相同,但是结果却从未如此.
Basically, I just started learning Android Studio watching an online course, so I am just doing the same thing what the lecturer does on the videos, but the result never turns out the same.
首先,我想让您知道我没有碰过任何东西.但是Android Studio不显示任何组件,例如textView,当我运行它时,ADB(模拟器)从不运行该应用程序,而仅显示Android手机的默认屏幕.
Firstly I want to let you know that I have not touched anything. But Android Studio does not show any of components, such as textView, and when I run it, the ADB(the Emulator) never runs the app but only shows the default screen of an Android phone.
我最好附上Android Studio的一些屏幕截图,以向您显示正在发生的事情.
I better attach some screenshots of my Android Studio to show you what is going on.
从这张图片中可以看到,有一个textView组件,但是它没有出现在中间的屏幕上.
As you can see from this picture, there is a textView component but it does not appear on the screen that is in the center.
如上所述,我什么都没碰.在我创建一个新项目之后就可以了.无论我添加什么组件,它都不会显示.
As I wrote above, I did not touch anything. It is just right after I create a new project. No matter what component I add, it never shows up.
我不知道这是否重要,但是如果您查看右上角,会出现一个错误(红色感叹号),该错误是呈现问题:无法加载具有未知错误的AppCompat ActionBar".
I have no idea if it would matter but if you look at the top right, an error occurs (red exclamation mark) that is saying "Render Problem: Failed to load AppCompat ActionBar with unknown error".
我已经尝试解决了好几个小时的错误,而且也找不到真正的解决方案.
I have tried to solve this error for several hours and could not really find a solution to this too.
当我运行应用程序时(按绿色箭头按钮),会发生以下情况.
And when I run the app (by pressing green arrow button), here's what happens.
它仅停留在此屏幕上.此后什么也没发生.
It just stays on this screen. Nothing really happens after this.
我应该怎么做才能查看我的组件并使它运行该应用程序?我想念什么?我确实完成了与正在观看的在线课程完全相同的操作,而且我没有人遇到我现在面临的问题.
What should I do to see my components and to make it run the app? What am I missing? I really have done exactly the same as the online course I am watching and I see no one is having the problem I am facing now.
有帮助吗?
如果需要它,我也将同时上传两个gradle文件:
In case of it will be needed, I am uploading both of my gradle files too:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这是gradle文件build.gradle(项目:项目名称)
This is a gradle file build.gradle (Project: project name)
以下是gradle文件build.gradle(模块:app)
And the following is a gradle file build.gradle (Module: app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.auclo.exampleapp"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
和styles.xml
And styles.xml
谢谢.
推荐答案
这是版本28的问题,您应该降级到版本27,直到问题解决.
This is an issue of version 28, you should downgrade to version 27 until the problem is solved.
转到您的应用程序/Gradle Scripts/build.gradle(模块:app)
Go to your app/Gradle Scripts/build.gradle (Module:app)
1
更改此行:
compileSdkVersion 28
到
compileSdkVersion 27
2
更改此行:
targetSdkVersion 28
到
targetSdkVersion 27
3
更改此行:
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
到
implementation 'com.android.support:appcompat-v7:27.1.1'
然后,Android Studio会要求您同步文件,方法是单击立即同步
Then Android Studio will ask you to Sync the files, and you do so by clicking in Sync Now
请继续学习如何编写代码,很快Android将解决此问题.您可以在此处 a>.
Keep learning how to code, and soon Android will solve this problem. You can see more about this discussion here.
这篇关于Android Studio组件未显示且应用程序未运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!