Creating new compose activity in my existing proje...
# compose
s
Creating new compose activity in my existing project am getting build issue I am in the process of migrating an Android application from XML to Compose. My methodology is to migrate one Activity at a time. Each Activity represents a flow with several fragments. So far, I have only migrated one Activity. However, the problem I am facing is that I am unable to make the existing theme defined with XML coexist with the theme generated by Compose when creating the first Compose Activity. When I launch the application, I encounter the following error:
Copy code
bashCopy code
Execution failed for task ':app:mergeDebugResources'.
> [style/AppTheme] /Users/ckroot/StudioProjects/leukseller/app/src/main/res/values/styles.xml [style/AppTheme] /Users/ckroot/StudioProjects/leukseller/app/src/main/res/values/themes.xml: Error: Duplicate resources
themes.xml
Copy code
<resources>
    <style name="AppTheme" parent="android:Theme.Material.Light.NoActionBar" />
    <!--    <style name="AppThemeCompose" parent="android:Theme.Material.Light.NoActionBar" />-->
</resources>
styles.xml
Copy code
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>

    <item name="android:windowBackground">@color/colorWindowBackground</item>

</style>
To fix the error, I modified the
themes.xml
file generated by Compose by changing the name to
AppThemeCompose
instead of
AppTheme
.
Copy code
<style name="AppThemeCompose" parent="android:Theme.Material.Light.NoActionBar" />
After this change, I am able to compile, but the theme defined by Compose does not change. I have changed the primary and secondary colors, but the changes have no effect on the Activity that uses Compose. It only displays the default color generated by Compose when generating the Activity using Compose. Thank you in advance.
c
Compose theming work with the MaterialTheme composable that you should wrap your “main” composable into. The theme in the xml is just for general view based layouts and the activity itself.
1
s
Thank's very much . the dynmicColor were set to true that's way didn't see my changes in primary and secondary color