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(Module: 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 (Module: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 就会解决这个问题.您可以在此处查看有关此讨论的更多信息一>.
Keep learning how to code, and soon Android will solve this problem. You can see more about this discussion here.
这篇关于Android Studio 组件未显示且应用程序未运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!