Aman Gupta -  ΔMΔN
Aman Gupta - ΔMΔN

Reputation: 3007

When i add appcompat-v7 library to my android project R.java is removed

When I have added a library appcompat-v7 to my app R.java is removed and the console give the following error:

[2015-11-02 16:50:32 - MP] /home/users/aman.gupta/workspace/appcompat_v7/res/values-v23/styles_base.xml:20: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.

[2015-11-02 16:50:32 - MP] /home/users/aman.gupta/workspace/appcompat_v7/res/values-v23/styles_base_text.xml:19: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.

Actually I was using android:Theme.Light (default theme of android) and i want to use AppCompat theme instead of android default theme. And In java file i want to extends AppCompatActivity instead of Activity to give some materialistic look to my app action bar.

But the problem is that when i import appcompat-v7 library to my project, R.java was removed. So i can't do any thing.

Note: When i create new project then it do not give any error message and work correctly when importing appcompat-v7 library.

And i want some suggestion on how to change my current theme, So please give some suggestion from where should i start this work.

My project configuration:

    android:minSdkVersion="17"
    android:targetSdkVersion="21" 

And i have tried to cleaning and rebuilding the project.

Upvotes: 2

Views: 164

Answers (2)

Mobikul Webkul
Mobikul Webkul

Reputation: 1

Mainly this issue was come in Eclipse. Now most of the persons are using the Android Studio. So just the remove the build folders or Clean your project. It will work fine.

Upvotes: 0

Anoop M Maddasseri
Anoop M Maddasseri

Reputation: 10549

Do the changes as below.

Gradle

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.package"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

Style.xml

    <!--.......................................MyTheme......................................-->
    <style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
       <!-- Optionals..-->
        <item name="colorPrimary">@color/red_primary_color</item>
        <item name="colorPrimaryDark">@color/red_primary_color_dark</item>
        <item name="android:textColorHint">@color/red_placeholder_color</item>
        <item name="android:editTextStyle">@style/MaterialEditText</item>
    </style>
    <!--........................................................................................-->

After clean and build the project.

Upvotes: 2

Related Questions