Reputation: 2354
I uninstalled a previous version of android and just have install version3.0.1 I created a new application in android studio scratch I have not modified any code but when I try to build the project I get the following errors
Error:resource style/Theme.AppCompat.Light.DarkActionBar (aka com.example.android.my:style/Theme.AppCompat.Light.DarkActionBar) not found.
C:\AndroidStudioProjects\MyAPP\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
Error:(101) error: style attribute 'attr/colorPrimary (aka com.example.android.my:attr/colorPrimary)' not found.
Error:(102) error: style attribute 'attr/colorPrimaryDark (aka com.example.android.com.example.android.my:attr/colorPrimaryDark)' not found.
Error:(103) error: style attribute 'attr/colorAccent (aka com.example.android.my:attr/colorAccent)' not found.
Error:(101) style attribute 'attr/colorPrimary (aka com.example.android.my:attr/colorPrimary)' not found.
Error:(102) style attribute 'attr/colorPrimaryDark (aka com.example.android.my:attr/colorPrimaryDark)' not found.
Error:(103) style attribute 'attr/colorAccent (aka com.example.android.my:attr/colorAccent)' not found.
Error:failed linking references.
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':app:processDebugResources'.
> Failed to execute aapt
This is my build.gradle
file
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.android.my"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'p
roguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.1'
}
And this is my values.xml
file:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr format="reference" name="constraintSet"/>
<attr format="integer" name="layout_constraintBaseline_creator"/>
..... some codes here ....
<attr format="dimension" name="layout_goneMarginTop"/>
<attr name="layout_optimizationLevel">
<flag name="none" value="1"/>
<flag name="all" value="2"/>
<flag name="basic" value="4"/>
<flag name="chains" value="8"/>
</attr>
<color name="colorAccent">#FF4081</color>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<declare-styleable name="ConstraintLayout_Layout"><attr name="android:orientation"/><attr name="android:minWidth"/>
.... some more attributes here ....
<string name="app_name">MyAppName</string>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
It seems that that error are some strange behaviors in android studio I have invalidated caches and restarted the project but the issue still exists, How should I solve this issue?
Upvotes: 3
Views: 17948
Reputation: 347
You don't need to change anything in dependencies. If you are combining multi-module, maybe they are conflicted , you must add prefix "android:". In this situation, I think you just update your file styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:colorPrimary">@color/colorPrimary</item>
<item name="android:colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="android:colorAccent">@color/colorAccent</item>
</style>
</resources>
It's worked with my source.
Upvotes: 0
Reputation: 3735
I was receiving this error when doing the android tutorial on support libraries
The problem is in your styles.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
**<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>**
</style>
Just remove those 4 item lines above and it will work. Perhaps because you are using a Compat library and the theme is not defined.
Upvotes: 2
Reputation: 2344
If anyone reading this has the same problem, this happened to me recently, and it was due to having the xml header written twice by mistake:
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?> <!-- Remove this one -->
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/mug_blue"/>
<corners android:radius="@dimen/featured_radius" />
</shape>
The error I was getting was completely unrelated to this file so it was a tough one to find. Just make sure all your new xml files don't have some kind of mistake like this (as it doesn't show up as an error).
Upvotes: 8
Reputation: 3977
you have duplicated lines in your gradle file. the fallowings are same
compile 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:appcompat-v7:26.1.0'
remove following line:
compile 'com.android.support:appcompat-v7:26.1.0'
Upvotes: 4