android - 错误 :No resource found that matches the given name (at 'minHeight' with value '?attr/actionBarSize' )

标签 android android-studio android-gradle-plugin build.gradle

我正在尝试构建 android studio 项目,但出现以下错误:

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

这个配置有什么问题吗? 提前致谢。

最佳答案

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

android:minHeight="?attr/actionBarSize"

我已经用下面的行替换了它,它起作用了

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

对于第二个,即 android:background="?attr/colorPrimary" 我尝试了 android:background="?android:attr/colorPrimary" 但它是兼容的使用 android lollipop 及以上版本。

因此,我必须使用我的自定义颜色代码/可绘制对象来分配背景,例如 android:background = "#FF00FF",毫无疑问,这非常有效。

如果任何机构有除此以外的解决方案,请告诉我。

关于android - 错误 :No resource found that matches the given name (at 'minHeight' with value '?attr/actionBarSize' ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33385552/

相关文章:

java - 如何将这些按钮添加到我的主要 Activity 中?

android - 在 jetpack compose 中对齐行项目

java - 无法解析符号 'GoogleCloudMessaging' GCM

android - 程序类型已经存在 : com. google.thirdparty.publicsuffix

Android list 重复权限

android - 在 Android 应用程序中使用邮政编码搜索新加坡地址

java - 如何根据您所在的 Activity 从 CustomAdapter 隐藏元素?

android - 如何在我的 Chrome/Firefox 浏览器中查看 SQLite 数据库?

java - Android Studio 项目无法正确编译

java - 安装拆分 apk 时出错 : com. android.ddmlib.InstallException:无法完成 session :INSTALL_FAILED_INVALID_APK