5

I am new in Android and trying to develop hello application with android studio version 3.3.2. I am trying to create Default Navigation Activity project and its giving error like below during build.

Android resource linking failed
error: resource style/Animation.AppCompat.Dialog (aka com.example.myapplication:style/Animation.AppCompat.Dialog) not found.
error: resource style/Theme.AppCompat.Light.DarkActionBar (aka com.example.myapplication:style/Theme.AppCompat.Light.DarkActionBar) not found.
error: resource style/ThemeOverlay.AppCompat.Dark.ActionBar (aka com.example.myapplication:style/ThemeOverlay.AppCompat.Dark.ActionBar) not found.
F:\MyApplication2\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:401: error: style attribute 'attr/windowActionBar (aka com.example.myapplication:attr/windowActionBar)' not found.
F:\MyApplication2\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:402: error: style attribute 'attr/windowNoTitle (aka com.example.myapplication:attr/windowNoTitle)' not found.
F:\MyApplication2\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v21\values-v21.xml:8: error: style attribute 'attr/windowActionBar (aka com.example.myapplication:attr/windowActionBar)' not found.
F:\MyApplication2\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v21\values-v21.xml:9: error: style attribute 'attr/windowNoTitle (aka com.example.myapplication:attr/windowNoTitle)' not found.
error: resource style/ThemeOverlay.AppCompat.Light (aka com.example.myapplication:style/ThemeOverlay.AppCompat.Light) not found.
F:\MyApplication2\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:416: error: resource style/Widget.AppCompat.ListView.Menu (aka com.example.myapplication:style/Widget.AppCompat.ListView.Menu) not found.
F:\MyApplication2\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:417: error: resource style/Animation.AppCompat.DropDownUp (aka com.example.myapplication:style/Animation.AppCompat.DropDownUp) not found.
F:\MyApplication2\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:421: error: style attribute 'attr/windowMinWidthMajor (aka com.example.myapplication:attr/windowMinWidthMajor)' not found.
F:\MyApplication2\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:422: error: style attribute 'attr/windowMinWidthMinor (aka com.example.myapplication:attr/windowMinWidthMinor)' not found.
F:\MyApplication2\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:425: error: style attribute 'attr/windowFixedWidthMajor (aka com.example.myapplication:attr/windowFixedWidthMajor)' not found.
F:\MyApplication2\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:426: error: style attribute 'attr/windowFixedWidthMinor (aka com.example.myapplication:attr/windowFixedWidthMinor)' not found.
F:\MyApplication2\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:427: error: style attribute 'attr/windowFixedHeightMajor (aka com.example.myapplication:attr/windowFixedHeightMajor)' not found.
F:\MyApplication2\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:428: error: style attribute 'attr/windowFixedHeightMinor (aka com.example.myapplication:attr/windowFixedHeightMinor)' not found.
F:\MyApplication2\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:431: error: style attribute 'attr/windowMinWidthMajor (aka com.example.myapplication:attr/windowMinWidthMajor)' not found.
F:\MyApplication2\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:432: error: style attribute 'attr/windowMinWidthMinor (aka com.example.myapplication:attr/windowMinWidthMinor)' not found.
F:\MyApplication2\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:438: error: style attribute 'attr/actionBarPopupTheme (aka com.example.myapplication:attr/actionBarPopupTheme)' not found.
F:\MyApplication2\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:439: error: style attribute 'attr/actionBarWidgetTheme (aka com.example.myapplication:attr/actionBarWidgetTheme)' not found.

I have project gradle file like below

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.myapplication"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    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'
}

I am able to import and run another projects but this is giving me error like above.

Zoe
  • 27,060
  • 21
  • 118
  • 148
Raju Bhatt
  • 385
  • 5
  • 17

2 Answers2

1

Try this

File->Import (android-sdk\extras\android\support\v7). Choose "AppCompat" Project-> properties->Android. In the section library Add and choose "AppCompat"

and if above not works try one more option as below

First check if you are using Androidx then do as below

Remove

implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'

Add this

implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.material:material:1.1.0-alpha08'

check in your gradel.properties this two lines are added, if not added then add this line

android.useAndroidX=true
android.enableJetifier=true

then clean and Rebuild project once

YuvrajsinhJadeja
  • 1,383
  • 7
  • 23
1

AppCompat is a library project. You need to reference the library project in your android project

  1. Include Google's Maven repository in your project's build.gradle file

    allprojects { repositories { google() If you're using a version of Gradle lower than 4.1, you must instead use: maven { url 'https://maven.google.com' } } }

  2. For each module in which you want to use a Support Library, add the library in the dependencies block of the module's build.gradle file. For example, to add the v7 core-utils library, add the following:

implementation "com.android.support:support-core-utils:28.0.0"

Black mamba
  • 462
  • 4
  • 15