1、解决Error:All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com

defaultConfig {
   targetSdkVersion:***
   minSdkVersion :***
   versionCode:***
   versionName :***
   //版本名后面添加一句话,意思就是flavor dimension 它的维度就是该版本号,这样维度就是都是统一的了
   flavorDimensions "versionCode"
}

2、Android中Activity和AppcompatActivity

AppcompaActivity相对于Activity的主要的两点变化; 
1:主界面带有toolbar的标题栏; 
2,theme主题只能用android:theme=”@style/AppTheme (appTheme主题或者其子类),而不能用android:style。 否则会提示错误: Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
————————————————

去掉AppcompaActivity的标题栏方法: 
if (getSupportActionBar()!=null){ 
getSupportActionBar().hide(); 

原文链接:https://blog.csdn.net/today_work/article/details/79300181

--------------------------------------------

activity改为AppCompatActivity后崩溃(继承自AppCompatActivity崩溃闪退问题):

activity的style是

<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
    <!-- Customize your theme here. -->
</style>

需要修改为:

<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>

main配置文件中,注册activity时样式也需更改:

android:theme="@style/AppThemeF"

————————————————
 
原文链接:https://blog.csdn.net/moonshine99/article/details/78253696

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐