Android Studio не может найти ресурс, и не удалось связать ресурс - PullRequest
0 голосов
/ 26 мая 2019

Недавно у меня были проблемы с AAPT2.Проблемы были вызваны моим именем пользователя, которое содержало символы не ascii.Я создал другую учетную запись Windows (без символов, отличных от ascii) и установил Android Studio.Затем я открыл свой старый проект, и когда AS попросил меня обновить, я согласился на это.Теперь, когда я пытаюсь создать свое приложение, я получаю следующие ошибки:

Не удалось связать ресурс Android. D: \ Android_Studio \ Praca \ app \ build \ промежуточные \ incremental \ mergeDebugResources \ merged.dir \ values-v28\ values-v28.xml: 7: ошибка: ресурс android: attr / dialogCornerRadius не найден.D: \ Android_Studio \ Praca \ app \ build \ middleates \ incremental \ mergeDebugResources \ merged.dir \ values-v28 \ values-v28.xml: 11: ошибка: ресурс android: attr / dialogCornerRadius не найден.D: \ Android_Studio \ Praca \ app \ build \ middleates \ incremental \ mergeDebugResources \ merged.dir \ values ​​\ values.xml: 2970: ошибка: ресурс android: attr / fontVariationSettings не найден.D: \ Android_Studio \ Praca \ app \ build \ middleates \ incremental \ mergeDebugResources \ merged.dir \ values ​​\ values.xml: 2971: ошибка: ресурс android: attr / ttcIndex не найден.ошибка: не удалось связать ссылки.

Большинство потоков, которые я обнаружил в StackOverflow, предполагают, что эта проблема может быть связана с библиотекой поддержки, они говорят, что ее версия может быть неправильной.Как я мог изменить версию?Мой проект также использует библиотеку OpenCV, и ее конфигурация может быть неверной.Я уже пытался очистить и перестроить проект и настроить compileSDKVersion в Gradle.

Вот values-v28.xml file

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Base.Theme.AppCompat" parent="Base.V28.Theme.AppCompat"/>
<style name="Base.Theme.AppCompat.Light" parent="Base.V28.Theme.AppCompat.Light"/>
<style name="Base.V28.Theme.AppCompat" parent="Base.V26.Theme.AppCompat">
    <!-- We can use the platform styles on API 28+ -->
    <item name="dialogCornerRadius">?android:attr/dialogCornerRadius</item>
</style>
<style name="Base.V28.Theme.AppCompat.Light" parent="Base.V26.Theme.AppCompat.Light">
    <!-- We can use the platform styles on API 28+ -->
    <item name="dialogCornerRadius">?android:attr/dialogCornerRadius</item>
</style>

А вот и манифест:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.kawa.praca">

<uses-feature
    android:name="android.hardware.camera"
    android:required="true" />

<uses-permission
    android:name="android.permission.WRITE_EXTERNAL_STORAGE"
    android:maxSdkVersion="18" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".Powitanie">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".Trening" />
    <activity android:name=".Zdjecia" />

    <provider
        android:name=".DbProvider"
        android:authorities="com.example.kawa.praca"
        android:exported="true" />
    <provider
        android:name="android.support.v4.content.FileProvider"
        android:authorities="com.example.android.fileprovider"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/file_paths" />
    </provider>

    <activity android:name=".AddActivity" />
    <activity android:name=".UserPanel" />
    <activity android:name=".ScoringPanel" />
    <activity android:name=".Scoring" />
    <activity android:name=".NewPlanActivity" />

    <receiver
        android:name=".PlanReceiver"
        android:enabled="true"
        android:exported="true" />

    <activity android:name=".ChartsActivity"></activity>
</application>

</manifest>

Такжениже мой модуль приложения файла build.gradle.В этом файле в подпункте «зависимости» записи с библиотекой поддержки подчеркнуты, и AS показывает мне предупреждение:

Все библиотеки com.android.support должны использовать одну и ту же спецификацию версии (смешивание версий можетпривести к сбоям во время выполнения).Найдено версии 28.0.0, 26.1.0.Примеры включают com.android.support:animated-vector-drawable:28.0.0 и com.android.support:customtabs:26.1.0

Я пытался изменить версию на более новую или более старую, но это предупреждение по-прежнемупоявляется.

apply plugin: 'com.android.application'

android {
compileSdkVersion 26
defaultConfig {
    applicationId "com.example.kawa.praca"
    minSdkVersion 24
    targetSdkVersion 26

    versionCode 1
    versionName "1.0"
    testInstrumentationRunner 
 "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
sourceSets { main { jni.srcDirs = ['src/main/jni', 'src/main/jniLibs/'] } 
}
// Encapsulates your external native build configurations.
externalNativeBuild {

    // Encapsulates your CMake build configurations.
    cmake {

        // Provides a relative path to your CMake build script.
        path "../CMakeLists.txt"
    }
}
//buildToolsVersion '27.0.3'
buildToolsVersion '28.0.3'
productFlavors {
}
}

repositories {
maven { url 'https://jitpack.io' }
}

dependencies {
//implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0-alpha'
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:animated-vector-drawable:28.0.0'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:customtabs:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-v4:26.1.0'
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 project(':openCVLibrary340')
//implementation 'com.jjoe64:graphview:4.2.2'
}

dependencies {
implementation 'com.android.support.constraint:constraint-layout:+'
}

1 Ответ

0 голосов
/ 26 мая 2019

Я исправил ту же ошибку, обновив compilesdkversion до 28, поскольку в настоящее время моя версия инструментов сборки - 28.0.3, следовательно, версия должна быть такой же, чтобы иметь идеальную сборку. Также проверьте вашу реализацию 'com.android.support:appcompat-v7:28.0.0' Измените соответствующие версии зависимости на 28, это предотвратит сбой во время выполнения

...