简体   繁体   中英

Can not running App on android studio

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM