Can not running App on android studio

梦想与她 提交于 2019-12-13 05:20:49

问题


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.+'
}

回答1:


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>


来源:https://stackoverflow.com/questions/32721761/can-not-running-app-on-android-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!