delete27
delete27

Reputation: 41

error when sync Gradle project in android studio

I can not sync my gradle project. Every time I sync, it shows an error:

Error:(11) Tag <style> can not appear inside <style>, only <item>

When I edit value.xml & value-v21.xml or remove <style> , it will reappear.

How to solve the problem?

build gradle app:

compileSdkVersion 28
buildToolsVersion "28.0.3"

defaultConfig {
    applicationId "ir.bijac.com.bijac"
    minSdkVersion 14
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

And dependencies:

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

Description image

Upvotes: 0

Views: 198

Answers (4)

Ishan R Tripathi
Ishan R Tripathi

Reputation: 74

Try deleting the value-v21.xml and if tag is still nested in value.xml , edit it. Hope this helps

Upvotes: 1

Skizo-ozᴉʞS ツ
Skizo-ozᴉʞS ツ

Reputation: 20616

Remove the MyCheckBox style from inside of AppTheme.NoActionBar style.

Tag <style> can not appear inside <style>, only <item>

It's says that a style can not contain another style inside, just an item, so removing MyCheckBox style outside it should work.

Make sure your layout.xml only contains one style inside a component, for instance :

<Checkbox>
...
...
style=@style/MyCheckBox
</Checkbox>

Oh, I see you can edit so, please try first :

File/Invalidate Caches/Restart 

if it does not work, make sure you can scroll up and down in your styles, then you can edit it.

Also make sure you are not editing the files that Android studio are generating automatically make sure you are editing this :

app->src->main->res->values

Upvotes: 0

Nouman Ch
Nouman Ch

Reputation: 4121

The error is very clear you can't do this

<stle><style> </style></style>

instead what you can do is

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyTheme" parent="android:Theme">
    <item name="android:textViewStyle">@style/MyTextViewStyle</item>
</style>

<style name="MyTextViewStyle" parent="android:Widget.TextView">
    <item name="android:textColor">#F00</item>
    <item name="android:textStyle">bold</item>
</style>
</resources>

Hope this will help you

Upvotes: 0

Agshin Huseynov
Agshin Huseynov

Reputation: 170

Put MyCheckbox style to outside of AppTheme.NoActionBar

Upvotes: 0

Related Questions