不能在Android上运行的工作室应用 [英] Can not running App on android studio
问题描述
当我创建在Android Studio中一个新的项目,我找到了活动类扩展了最初和AppCompatActivity我必须改变它延长
活动吧。
但我面临的是问题,R类是无法识别,我收到错误斜面解析符号R。我张贴的build.gradle
以下文件,并在我看来,它有没有错误。
此外,后试着找出解决办法,我检查了所有的XML文件,我发现下面贴的style.xml在Theme.AppCompat.Light.DarkActionBar有错误
和android工作室不能解析它。
请让我知道如何解决这个错误。
code :
公共类MainActivity延伸活动{
@覆盖
保护无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.xxx.xxx); //着决心标记R
}
}
style.xml :
<! - Base应用程序的主题。 - >
<样式名称=AppTheme父=Theme.AppCompat.Light.DarkActionBar> //着决心的象征主题+斜面解析符号应用程序兼容性
<! - 在这里自定义的主题。 - >
< /风格>< /资源>
gradle.build
应用插件:'com.android.application安卓{
compileSdkVersion 23
buildToolsVersion23.0.1 defaultConfig {
的applicationIDcom.example.com.bt_11
19的minSdkVersion
targetSdkVersion 21
版本code 1
的versionName1.0
}
buildTypes {
发布 {
minifyEnabled假
proguardFiles getDefaultProguardFile('proguard的-android.txt'),'proguard-rules.pro
}
}
}依赖{
编译文件树(导演:'库',包括:['的* .jar'])
编译com.android.support:appcompat-v7:23.+
}
您将不得不改变主题,以全息光或全息深色或材料的主题如下粘贴;
<资源> <! - Base应用程序的主题。 - >
<样式名称=AppTheme父=@安卓风格/ Theme.Holo.Light.DarkActionBar>
<! - 在这里自定义的主题。 - >
< /风格>< /资源>
when i create a new project in android studio i find the the activity class initially extends AppCompatActivity and i have to change it to extend Activity instead.
but the issue that i am facing is, R class is not recognisable and i receive the error "Cant resolve symbol R". i posted the build.gradle file below and it seems to me it has no errors.
also, after tryin to find out the solution, i checked all the xml files and i found that the style.xml "posted below" has error at "Theme.AppCompat.Light.DarkActionBar" and android studio cant resolve it.
please let me know how to fix this error.
code: public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.xxx.xxx);//cant resolve symbol R
}
}
style.xml:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">//cant resolve symbol Theme+cant resolve symbol AppCompat
<!-- Customize your theme here. -->
</style>
</resources>
gradle.build:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.com.bt_11"
minSdkVersion 19
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.+'
}
You will have to change the theme to Holo Light or Holo Dark or Material theme as pasted below;
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="@android:style/Theme.Holo.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
这篇关于不能在Android上运行的工作室应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!