英文:
Theme.AppCompat is not found in Android Studio
问题
I need to use Theme.AppCompat.Light.NoActionBar, but Theme.AppCompat is not found in Android Studio
how it looks
I added implementation 'com.android.support:appcompat-v7:28.0.0' to gradle, but the problem still the same
dependencies in gradle:
dependencies {
implementation 'androidx.core:core-ktx:1.10.1'
//
implementation 'androidx.room:room-ktx:2.5.1'
kapt "androidx.room:room-compiler:2.5.1"
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1'
implementation 'androidx.preference:preference-ktx:1.2.0'
implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0"))
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.android.material:material:1.9.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.google.android.material:material:1.10.0-alpha03'
//
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
implementation 'androidx.activity:activity-compose:1.7.1'
implementation platform('androidx.compose:compose-bom:2022.10.00')
implementation 'androidx.compose.ui:ui'
implementation 'androidx.compose.ui:ui-graphics'
implementation 'androidx.compose.ui:ui-tooling-preview'
implementation 'androidx.compose.material3:material3'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation platform('androidx.compose:compose-bom:2022.10.00')
androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
debugImplementation 'androidx.compose.ui:ui-tooling'
debugImplementation 'androidx.compose.ui:ui-test-manifest'
}
英文:
I need to use Theme.AppCompat.Light.NoActionBar, but Theme.AppCompat is not found in Android Studio
how it looks
I added implementation 'com.android.support:appcompat-v7:28.0.0' to gradle, but the problem still the same
dependencies in gradle:
dependencies {
implementation 'androidx.core:core-ktx:1.10.1'
//
implementation 'androidx.room:room-ktx:2.5.1'
kapt "androidx.room:room-compiler:2.5.1"
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1'
implementation 'androidx.preference:preference-ktx:1.2.0'
implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0"))
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.android.material:material:1.9.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.google.android.material:material:1.10.0-alpha03'
//
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
implementation 'androidx.activity:activity-compose:1.7.1'
implementation platform('androidx.compose:compose-bom:2022.10.00')
implementation 'androidx.compose.ui:ui'
implementation 'androidx.compose.ui:ui-graphics'
implementation 'androidx.compose.ui:ui-tooling-preview'
implementation 'androidx.compose.material3:material3'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation platform('androidx.compose:compose-bom:2022.10.00')
androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
debugImplementation 'androidx.compose.ui:ui-tooling'
debugImplementation 'androidx.compose.ui:ui-test-manifest'
}
I added implementation 'com.android.support:appcompat-v7:28.0.0' to gradle, but the problem still the same
答案1
得分: 1
I think you write in your file theme.xml wrong way.
a common error when you are new to Android is to write like this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.ShoppingList" parent="theme.AppCompat.Light.NoActionBar" />
</resources>
or like this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.ShoppingList" parent="android:Theme.AppCompat.Light.NoActionBar" />
</resources>
The right way to write the parent theme is to make sure you have it like this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.ShoppingList" parent="Theme.AppCompat.Light.NoActionBar" />
</resources>
The parent theme starts with a capital letter "Theme".
英文:
the problem i think you write in your file theme.xml wrong way.
in the "parent" of style.
a common error when you new in android it is write like this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.ShoppingList" parent="theme.AppCompat.Light.NoActionBar" />
</resources>
or like this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.ShoppingList" parent="android:Theme.AppCompat.Light.NoActionBar" />
</resources>
The right way to write parent theme make sure you have like this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.ShoppingList" parent="Theme.AppCompat.Light.NoActionBar" />
</resources>
the parent theme starts with a capital letter "Theme"
答案2
得分: 0
添加这个库
implementation 'androidx.appcompat:appcompat:1.6.1'
确保最新版本已经实现,这将解决问题。
同时注释掉旧的库
implementation 'com.android.support:appcompat-v7:28.0.0'
英文:
add this library
implementation 'androidx.appcompat:appcompat:1.6.1'
make sure latest should implement it will solve the problem.
and also comment the old library
implementation 'com.android.support:appcompat-v7:28.0.0'
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论