2015-10-28 25 views
4

我试图构建Android工作室项目,我得到以下错误:错误:未发现的资源与给定名称匹配(在“了minHeight”,值为“ATTR/actionBarSize?”)

Error:(11, 28) No resource found that matches the given name (at 'minHeight' with value '?attr/actionBarSize'). 
Error:(12, 29) No resource found that matches the given name (at 'background' with value '?attr/colorPrimary'). 
下面

是我XML文件: -

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:qwerjk="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@android:color/black" > 

<android.support.v7.widget.Toolbar 
    android:id="@+id/builder_toolbar" 
    android:layout_height="wrap_content" 
    android:layout_width="match_parent" 
    android:minHeight="?attr/actionBarSize" 
    android:background="?attr/colorPrimary" /> 

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/layout_bottom" 
    android:layout_below="@id/builder_toolbar" 
    android:layout_centerInParent="true" > 

    <RelativeLayout 
     android:id="@+id/lCanvas" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" > 

     <ImageView 
      android:id="@+id/imgEditor" 
      android:layout_width="fill_parent" 
      android:layout_height="100dp" 
      android:layout_alignParentTop="true" /> 

     <qwerjk.better_text.MagicTextView 
      android:id="@+id/tvEditTop" 
      style="@style/BuilderText" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignTop="@id/imgEditor" 
      android:layout_centerHorizontal="true" 
      android:text="TOP" 
      qwerjk:strokeColor="#FF000000" 
      qwerjk:strokeJoinStyle="miter" 
      qwerjk:strokeWidth="5" /> 

     <qwerjk.better_text.MagicTextView 
      android:id="@+id/tvEditMid" 
      style="@style/BuilderText" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerHorizontal="true" 
      android:layout_centerVertical="true" 
      android:text="MID" 
      qwerjk:strokeColor="#FF000000" 
      qwerjk:strokeJoinStyle="miter" 
      qwerjk:strokeWidth="5" /> 

     <qwerjk.better_text.MagicTextView 
      android:id="@+id/tvEditBot" 
      style="@style/BuilderText" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBottom="@id/imgEditor" 
      android:layout_centerHorizontal="true" 
      android:text="BOTTOM" 
      qwerjk:strokeColor="#FF000000" 
      qwerjk:strokeJoinStyle="miter" 
      qwerjk:strokeWidth="5" /> 
    </RelativeLayout> 

    <RelativeLayout 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:layout_alignBottom="@id/lCanvas" 
     android:layout_alignTop="@id/lCanvas" > 

     <Button 
      android:id="@+id/btnEditTop" 
      android:layout_width="80dp" 
      android:layout_height="wrap_content" 
      android:layout_alignParentTop="true" 
      android:background="@drawable/btn_blue" 
      android:text="@string/top" /> 

     <Button 
      android:id="@+id/btnEditMid" 
      android:layout_width="80dp" 
      android:layout_height="wrap_content" 
      android:layout_centerVertical="true" 
      android:background="@drawable/btn_blue" 
      android:text="@string/center" /> 

     <Button 
      android:id="@+id/btnEditBot" 
      android:layout_width="80dp" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:background="@drawable/btn_blue" 
      android:text="@string/bottom" /> 
    </RelativeLayout> 
</RelativeLayout> 

<LinearLayout 
    android:id="@+id/layout_bottom" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:background="@android:color/white" 
    android:gravity="center" 
    android:orientation="horizontal" > 

    <FrameLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"> 

     <FrameLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"> 

      <Button 
       android:id="@+id/btnSave" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/btn_submit" 
       android:gravity="center_vertical" /> 

     </FrameLayout> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:text="@string/submit" 
      android:id="@+id/submitText" 
      android:textColor="@android:color/black" 
      android:layout_gravity="center_horizontal|bottom" 
      android:layout_marginBottom="10dp" 
      android:textSize="20dp" 
      android:textStyle="bold" 
      android:layout_marginRight="7dp" /> 


    </FrameLayout> 


    <Button 
     android:id="@+id/btnCancel" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Cancel" 
     android:visibility="gone" /> 
</LinearLayout> 

<include layout="@layout/loading_overlay"/> 
</RelativeLayout> 

gradle.properties文件包含此: -

ANDROID_BUILD_TARGET_SDK_VERSION=23 
ANDROID_BUILD_TOOLS_VERSION=23.0.0 
ANDROID_BUILD_SDK_VERSION=23 
ANDROID_BUILD_MIN_SDK_VERSION=14 

的build.gradle文件: -

buildscript { 
repositories { 
    mavenCentral() 
} 
dependencies { 
    classpath 'com.android.tools.build:gradle:1.3.0' 
} 
} 


apply plugin: 'com.android.library' 

android { 
    compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION) 
    buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION 

defaultConfig { 
    minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION) 
    targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION) 
    versionCode 1 
    versionName "1.0" 
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
} 

lintOptions { 
    abortOnError false 
} 

packagingOptions { 
    exclude 'META-INF/DEPENDENCIES' 
    exclude 'META-INF/NOTICE' 
    exclude 'META-INF/LICENSE' 
    exclude 'META-INF/LICENSE.txt' 
    exclude 'META-INF/NOTICE.txt' 
} 
publishNonDefault true 

productFlavors { 
    cheezburger { 

    } 
    loquillo{ 
    } 
} 
} 

dependencies { 
compile fileTree(dir: 'libs', include: ['*.jar']) 
provided 'com.android.support:appcompat-v7:23.1.0' 
provided 'org.roboguice:roboguice:3.0.1' 
provided 'org.roboguice:roboblender:3.0.1' 
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3' 
provided 'com.google.android.gms:play-services:8.1.0' 
compile 'com.google.code.gson:gson:2.3' 
compile 'com.android.support:support-v4:23.1.0' 
} 

在这个配置中的任何问题? 在此先感谢。

+0

显示位于值文件夹中的attrs.xml文件。 –

+0

@ChiragSavsani我正在使用当前应用主题的属性。即什么?在android:minHeight =“?attr/actionBarSize”中表示。如我错了请纠正我。 – Amrut

+0

你有没有尝试传递sdk版本的具体值而不是使用Integer包装? –

回答

7

如上所述有两个属性,这是导致一个问题: -

android:minHeight="?attr/actionBarSize" 

我已经通过下面的行替换这和它的工作

android:minHeight="?android:attr/actionBarSize" 

对于第二个即android:background="?attr/colorPrimary"我试着由android:background="?android:attr/colorPrimary",但它与Android棒棒糖及以上兼容。

所以我必须给我的自定义颜色代码/可绘制像android:background = "#FF00FF"分配背景,毫无疑问,这完美的作品。

如果任何机构有其他解决方案,请让我知道。

相关问题