Studio Compile Sdk Version 使用API23: Android6.0创建项目中使用V4包控件问题兼容解决方案

No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.
No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
No resource found that matches the given name 'android:Widget.Material.Button.Colored'

很多时候Android Studio跟新到最高版本的Compile Sdk Version API23: Android6.0 和Build Tools Version 23.0.1

时会使用到很多6.0的属性主题,

可是有时候我们会使用V4包下的一些控件Viewpager,Fragment等,可能会出现一些兼容问题,如果你改成低版本的Compile SDK和Build Tools 来解决兼容问题,就会造成报错,即使你把那个V7包主题删掉,它又自动生成。

报错信息:

E:\androidSutio\News\app\build\intermediates\res\merged\debug\values-v23\values-v23.xml

Error:(3) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.

Error:(24) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.

Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'E:\android-sdk-windows\build-tools\21.0.1\aapt.exe'' finished with non-zero exit value 1

如果想干脆在把

compile 'com.android.support:appcompat-v7:23.1.1'这个V7删掉添加V4包到libs建立依赖,又会报V7包下的一些高版本属性主题找不到异常
E:\androidSutio\News\app\build\intermediates\res\merged\debug\values\values.xml
Error:(18) Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.
E:\androidSutio\News\app\src\main\res\values\styles.xml
Error:(4, 5) No resource found that matches the given name: attr 'colorAccent'.
Error:(4, 5) No resource found that matches the given name: attr 'colorPrimary'.
Error:(4, 5) No resource found that matches the given name: attr 'colorPrimaryDark'.
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'E:\android-sdk-windows\build-tools\21.0.1\aapt.exe'' finished with non-zero exit value 1


其实解决方案很简单就在
compile 'com.android.support:appcompat-v7:23.1.1'
在依赖节点上面填上个v4支持包写法如下:
下面填上这句话就可以了
compile 'com.android.support:support-v4:23.1.1'

你可能感兴趣的:(Studio环境问题依赖包问题)