Ошибка компиляции Gradle (Ошибка получения родительского элемента) - PullRequest
0 голосов
/ 08 октября 2018

В моем проекте React Native сборка Gradle выдала мне эту ошибку:

> Task :app:processDebugGoogleServices
Parsing json file: /Users/valentinmourot/ODE/Dev/mobile-app/android/app/google-services.json

/Users/valentinmourot/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/234563a256b75883624274d32dc30b63/res/values-v24/values-v24.xml:3:5-157: AAPT
: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.

/Users/valentinmourot/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/234563a256b75883624274d32dc30b63/res/values-v24/values-v24.xml:4:5-135: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.

/Users/valentinmourot/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/234563a256b75883624274d32dc30b63/res/values-v26/values-v26.xml:13:5-16:13: AAPT: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.

Некоторые потоки говорили, что это произошло из-за неправильной конфигурации в файле build.gradle.Вот мое:

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "-----------"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 8
        versionName "0.0.8"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

dependencies {
    compile project(':react-native-view-overflow')
    compile(project(':react-native-firebase')) {
        transitive = false
    }
    compile "com.google.android.gms:play-services-base:15.0.0"
    compile "com.google.firebase:firebase-core:15.0.2"
    compile project(':react-native-i18n')
    compile project(':react-native-vector-icons')
    compile project(':react-native-fs')
    compile project(':react-native-image-to-base64')
    compile project(':rn-fetch-blob')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.3"
    compile "com.facebook.react:react-native:+"
    compile project(':react-native-smart-splash-screen')
    compile project(':react-native-cookies')
    compile "com.google.firebase:firebase-analytics:15.0.2"
    compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
        transitive = true
    }
    compile "com.google.firebase:firebase-perf:15.1.0"
    compile "com.google.firebase:firebase-messaging:15.0.2"
    compile project(':react-native-image-picker')
    compile project(':react-native-mixpanel')
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
apply plugin: 'com.google.gms.google-services'

Похоже, что ошибки связаны с google-сервисами (Firebase?).Я не знаю, почему здесь используется appcompat-v7-27.1.1.Ошибка, возникшая после обновления Android Studio.

Вот моя среда React Native:

React Native Environment Info:
    System:
      OS: macOS High Sierra 10.13.6
      CPU: x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
      Memory: 59.94 MB / 8.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.9.0 - /usr/local/bin/node
      Yarn: 1.9.4 - /usr/local/bin/yarn
      npm: 6.4.1 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0
      Android SDK:
        Build Tools: 23.0.1, 26.0.2, 27.0.3
        API Levels: 23, 25, 26, 27
    IDEs:
      Android Studio: 3.2 AI-181.5540.7.32.5014246
      Xcode: 10.0/10A255 - /usr/bin/xcodebuild
    npmPackages:
      @types/react: 16.4.14 => 16.4.14
      @types/react-native: 0.57.1 => 0.57.1
      react: 16.5.0 => 16.5.0
      react-native: 0.57.1 => 0.57.1
    npmGlobalPackages:
      react-native-cli: 2.0.1

Спасибо за вашу помощь!:)

Постскриптум:

Иногда ошибка другая (кажется, происходит от Reaction-native-i18n):

> Task :react-native-i18n:compileDebugJavaWithJavac
Note: /Users/valentinmourot/ODE/Dev/mobile-app/node_modules/react-native-i18n/android/
src/main/java/com/AlexanderZaytsev/RNI18n/RNI18nModule.java uses or overrides a deprec
ated API.
Note: Recompile with -Xlint:deprecation for details.

/Users/valentinmourot/.gradle/caches/transforms-1/files-1.1/appcompat-v7-28.0.0.aar/b8
5fe69b67b83a703766c9386b9fdeb8/res/values-v24/values-v24.xml:3:5-157: AAPT: Error retr
ieving parent for item: No resource found that matches the given name 'android:TextApp
earance.Material.Widget.Button.Borderless.Colored'.

/Users/valentinmourot/.gradle/caches/transforms-1/files-1.1/appcompat-v7-28.0.0.aar/b85fe69b67b83a703766c9386b9fdeb8/res/values-v24/values-v24.xml:4:5-135: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.

/Users/valentinmourot/.gradle/caches/transforms-1/files-1.1/appcompat-v7-28.0.0.aar/b85fe69b67b83a703766c9386b9fdeb8/res/values-v26/values-v26.xml:13:5-16:13: AAPT: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'

... или иногда другая: > Task :react-native-cookies:compileDebugJavaWithJavac с теми же сообщениями.

Ответы [ 3 ]

0 голосов
/ 08 октября 2018

Можете ли вы попробовать добавить версию инструмента сборки.

buildToolsVersion "23.XX"

0 голосов
/ 08 октября 2018

обновление до:

api "com.android.support:appcompat-v7:28.0.0"

, в то время как имеются другие устаревшие версии.

0 голосов
/ 08 октября 2018

Вы пытались запустить gradlew clean в android/ dir?

Иногда я получаю эту ошибку и исправляю ее, хотя я не знаю, что ее вызывает.

...