React-Native Android构建失败:任务':app:processDebugResources'的执行失败。无法处理资源

时间:2018-07-10 22:17:42

标签: react-native android-gradle build.gradle react-native-android google-play-services

我无法弄清楚构建有什么问题。我尝试了运行./gradlew clean的常见解决方案,以及将android.enableAapt2 = false添加到gradle.properties中。

google-services.json文件夹位于/ android / app级别。

我现在对如何克服这个困惑不知所措。

如果我忘了包含有用的内容,请lmk,我将进行更新。

欢呼

错误输出

  

配置项目:app   警告:指定的Android SDK Build Tools版本(26.0.1)被忽略,因为它低于Android Gradle Plugin 3.1.3的最低支持版本(27.0.3)。   将使用Android SDK Build Tools 27.0.3。   要取消显示此警告,请从build.gradle文件中删除“ buildToolsVersion '26 .0.1'”,因为每个版本的Android Gradle插件现在都具有默认版本的构建工具。   在[src / nullnull / debug,src / debug / nullnull,src / nullnull,src / debug,src / nullnullDebug]中查找时找不到google-services.json   不推荐使用registerResGeneratingTask,请使用registerGeneratedResFolders(FileCollection)   在[src / nullnull / release,src / release / nullnull,src / nullnull,src / release,src / nullnullRelease]中查找时找不到google-services.json   registerResGeneratingTask已过时,请使用registerGeneratedResFolders(FileCollection)

     

配置项目:react-native-google-analytics-bridge   警告:配置“编译”已过时,已被“实现”和“ api”替换。   它将于2018年底删除。有关更多信息,请参阅:http://d.android.com/r/tools/update-dependency-configurations.html

     

配置项目:react-native-radar   警告:配置“编译”已过时,已被“实现”和“ api”替换。   它将于2018年底删除。有关更多信息,请参阅:http://d.android.com/r/tools/update-dependency-configurations.html

     

任务:app:processDebugGoogleServices   解析json文件:/Users/kyletreman/18F/courier_test_app/android/app/google-services.json

     

/Users/kyletreman/.gradle/caches/transforms-1/files-1.1/appcompat-v7-23.0.1.aar/64df69838d7c555de168bdcf18f3be5c/res/values/values.xml:113:5-69:AAPT:错误:找不到资源android:attr / fontVariationSettings。

     

/Users/kyletreman/.gradle/caches/transforms-1/files-1.1/appcompat-v7-23.0.1.aar/64df69838d7c555de168bdcf18f3be5c/res/values/values.xml:113:5-69:AAPT:错误:找不到资源android:attr / ttcIndex。

     

错误:链接引用失败。

     

失败:构建失败,并出现异常。

     
      
  • 出了什么问题:   任务':app:processDebugResources'的执行失败。   无法处理资源,请参阅上面的aapt输出以获取详细信息。

  •   
  • 尝试:   使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。使用--scan运行以获取完整的见解。

  •   
  • https://help.gradle.org

  • 获得更多帮助   
     

2秒内失败   50个可执行任务:已执行3个,最新47个   无法在设备上安装该应用,请阅读上面的错误以获取详细信息。   确保您正在运行Android模拟器或已连接设备,并且   设置您的Android开发环境:   https://facebook.github.io/react-native/docs/getting-started.html

/android/app/build.gradle

android {
compileSdkVersion 27
buildToolsVersion "27.0.3"

defaultConfig {
    applicationId "com.courier_test_app.app"
    minSdkVersion 16
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    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 {
implementation(project(':react-native-firebase')) {
    transitive = false
}
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'com.android.support:support-v13:27.1.1'
implementation "com.facebook.react:react-native:+"  // From node_modules
implementation project(':react-native-radar')
implementation project(':react-native-google-analytics-bridge')
}

// 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 plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

/android/build.gradle

buildscript {
repositories {
    jcenter()
    google()
}
dependencies {
    classpath 'com.google.gms:google-services:4.0.0'
    classpath 'com.android.tools.build:gradle:3.1.3'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    mavenLocal()
    google()
    jcenter()
    maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        url "$rootDir/../node_modules/react-native/android"
    }
}
}

configurations.all {
resolutionStrategy {
    force 'com.android.support:support-v4:27.1.0'
}
}

3 个答案:

答案 0 :(得分:1)

从错误日志中,我可以看到appcompat-v7-23.0.1仍在使用中。因此,可能会有助于更新resolutionStrategy:

configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-v4:27.1.0'
        force 'com.android.support:appcompat-v7-23.0.1'
    }
}

此外,您需要将该分辨率策略块放置在app / build.gradle

答案 1 :(得分:0)

已修复

我能够从熟悉母语的人那里获得帮助,他帮助我解决了很多错误。

  • 实施顺序很重要,这是对我有用的顺序

    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation "com.android.support:support-v4:27.1.1"
    implementation 'com.android.support:support-v13:27.1.1'
    implementation "com.android.support:appcompat-v7:27.1.1"
    implementation(project(':react-native-firebase'))
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation project(':react-native-radar')
    implementation project(':react-native-google-analytics-bridge')
    
  • 我需要将配置解析策略移至android / app / build.gradle文件,我的级别不正确。我还必须更改support和appcompat软件包的版本。您可以通过

    查找依赖项
    ./gradlew app:dependencies 
    

    来自android文件夹。问题是,依赖关系中的一个原因是提取了较旧的版本,该版本通过在resolutionStrategies中使用以下内容得以解决。

    force 'com.android.support:appcompat-v7:27.1.1'
    
  • 下一个需要做的更改是MainApplication.java中的以下行

       return BuildConfig.DEBUG;
    

    对此

       return <app_name>.BuildConfig.DEBUG;
    
  • 我还删除了enableaapt2 = false

我要提供的最后一个技巧是命名,除非绝对必要,否则不要重命名您的应用,并确保它在Main java文件和AndroidMainfest.xml中进行更改。

已更新

  • 我意识到我的调试器没有连接,这是因为我删除了一些支持firebase的实现程序包,并将它们添加回去解决了该问题。在firebase实施下方添加以下内容。

    implementation "com.google.android.gms:play-services-base:15.0.1"
    implementation "com.google.firebase:firebase-core:16.0.1"
    

答案 2 :(得分:0)

将此代码放在 android / build.gradle 的末尾 将您自己的数字用于 compileSdkVersion buildToolsVersion

subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion 27
                buildToolsVersion "27.0.2"
            }
        }
    }
}
相关问题