资源android:attr/android:progressBarStyle未找到。

12

我在将Android Studio升级到最新版本后尝试构建项目时出现了以下错误:

C:\Users\YaCn.gradle\caches\transforms-2\files-2.1\5502c0022567bdcff063e0fb4352b137\folioreader-0.3.3\res\layout\progress_dialog.xml:10: AAPT:错误:未找到资源android:attr/android:progressBarStyle。

该XML文件:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout android:id="@+id/layout_loading"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:gravity="center">
        <ProgressBar android:id="@+id/loading"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="?android:attr/android:progressBarStyle"/>
        <TextView android:id="@+id/label_loading"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="4dp"
            android:textSize="18sp"
            android:textColor="@android:color/white"
            android:text="@string/loading"/>
    </LinearLayout>
</RelativeLayout>

构建gradle文件:

   apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.admin.hashtab"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        multiDexEnabled true

        manifestPlaceholders = [manifestApplicationId          : "${applicationId}",
                                onesignal_app_id               : "654bcb8c-90a6-4012-924a-e18e5787a7de",
                                onesignal_google_project_number: "3520309722"]

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility = 1.8
        targetCompatibility = 1.8
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.0'
    implementation 'com.android.support:design:27.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation 'com.loopj.android:android-async-http:1.4.9'
    implementation 'com.android.support:recyclerview-v7:27.1.0'
    implementation 'com.android.support:cardview-v7:27.1.0'
    implementation 'com.wang.avi:library:2.1.3'
    implementation 'com.makeramen:roundedimageview:2.3.0'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
    implementation 'com.google.android.gms:play-services-ads:12.0.1'
    implementation 'com.google.android.gms:play-services-gcm:12.0.1'
    implementation 'com.google.android.gms:play-services-analytics:12.0.1'
    implementation 'com.onesignal:OneSignal:3.+@aar'
    implementation 'com.google.firebase:firebase-core:12.0.1'
    implementation 'com.github.ornolfr:rating-view:0.1.2@aar'
    implementation project(path: ':library')
    implementation project(path: ':SmoothCheckBox-master')
    implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'
    implementation 'com.folioreader:folioreader:0.3.3'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.lmntrx.android.library.livin.missme:missme:0.1.5'
}
// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'
3个回答

6
尝试将此内容添加到您的依赖项中。
implementation "com.folioreader:folioreader:0.5.4"//this is just the updated version as of now
implementation 'com.android.support:multidex:1.0.3' // ( for androidx)
configurations.matching { it.name == '_internal_aapt2_binary' }.all {
    config -> config.resolutionStrategy.eachDependency {
        details -> details.useVersion("3.3.2-5309881")
    } 
}

5

您使用了错误的样式。只需将您的样式更改为:

style="?android:attr/progressBarStyle"

代替
style="?android:attr/android:progressBarStyle"

2
在layout中新建一个名为progress_dialog.xml的文件,并粘贴以下代码。
<LinearLayout android:id="@+id/layout_loading"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:gravity="center"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <ProgressBar
        android:id="@+id/loading"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        style="?android:attr/progressBarStyle" />

    <TextView
        android:id="@+id/label_loading"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="4dp"
        android:textSize="18sp"
        android:textColor="@android:color/white"
        android:text="@string/loading" />
</LinearLayout>

你能否添加一下为什么这个方法解决了问题? - creyD
我不确定这个解释是否正确,但我猜在布局中添加这个文件会覆盖库中的progress_dialog.xml。 - xriminact
这个解决方案对我有效。 - Payam Roozbahani

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接