更新android studio后Android资源编译失败

问题描述 投票:0回答:3

我刚刚将我的android工作室更新到版本3.2.1,并通过android studio更新了我的gradle到最新版本,但构建项目面临此错误:

Android资源编译失败输出:D:\ projects \ myProject \ app \ build \ intermediates \ incremental \ mergeDebugResources \ merged.dir \ values \ values.xml:2577:错误:内部元素必须是资源引用或为空。 D:\ projects \ myProject \ app \ build \ intermediates \ incremental \ mergeDebugResources \ merged.dir \ values \ values.xml:2585:错误:内部元素必须是资源引用或为空。

命令:C:\ Users \ Hamed.gradle \ caches \ transforms-1 \ files-1.1 \ aapt2-3.2.1-4818971-windows.jar \ ea639d8248f3ebb66b449dfd3b6a9a07 \ aapt2-3.2.1-4818971-windows \ aapt2.exe compile - -legacy \ -o \ D:\ projects \ myProject \ app \ build \ intermediates \ res \ merged \ debug \ D:\ projects \ myProject \ app \ build \ intermediates \ incremental \ mergeDebugResources \ merged.dir \ values \ values。 xml守护程序:AAPT2 aapt2-3.2.1-4818971-windows守护程序#0

在该行中它表示存在错误,此代码存在:

<item name="googledefaultpass" type="id">123456789</item>

怎么了?当我搜索解决方案是this,但结构是相同的。

我已经更新了所有库。

app level gradle:

apply plugin: 'com.android.application'
android {
    compileSdkVersion 27
    buildToolsVersion '28.0.3'
    defaultConfig {
        applicationId "com.my.project"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "0.7"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        manifestPlaceholders = [onesignal_app_id               : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                                // Project number pulled from dashboard, local value is ignored.
                                onesignal_google_project_number: "REMOTE"]
    }
    applicationVariants.all { variant ->
        variant.resValue "string", "versionName", variant.versionName
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
repositories {
    jcenter()
}
dependencies {
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    //    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    //    compile 'im.crisp:crisp-sdk:0.1.10'
    implementation 'com.getkeepsafe.taptargetview:taptargetview:1.11.0'
    implementation 'com.stephentuso:welcome:1.4.1'
    implementation 'co.ronash.android:pushe-base:1.4.0'
    implementation 'com.google.android.gms:play-services-gcm:16.0.0'
    implementation 'com.google.android.gms:play-services-location:16.0.0'
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:customtabs:27.1.1'
    //    compile 'com.google.firebase:firebase-auth:16.0.2'
    implementation 'com.google.android.gms:play-services-auth:16.0.1'
    implementation 'com.google.code.gson:gson:2.8.2'
    implementation('io.socket:socket.io-client:1.0.0') {
        // excluding org.json which is provided by Android
        exclude group: 'org.json', module: 'json'
    }
    implementation 'com.android.volley:volley:1.1.0'
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
}


configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '28.+'
            }
        }
    }
}

apply plugin: 'com.google.gms.google-services'

项目级别gradle:

repositories {
        google()
        maven { url 'https://maven.google.com' }
        jcenter()
        mavenCentral()
        buildscript {
            repositories {
                google()
                jcenter()
            }
            dependencies {
                classpath 'com.android.tools.build:gradle:3.2.1'
                classpath 'com.google.gms:google-services:4.0.1'
            }
        }

        allprojects {
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

更新:

我使缓存无效并重新启动Android工作室,问题解决了,但我遇到了以下错误:

> Could not find org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.71.
> Searched in the following locations:
>     https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.2.71/kotlin-stdlib-jdk8-1.2.71.pom
>     https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.2.71/kotlin-stdlib-jdk8-1.2.71.jar
>     https://maven.google.com/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.2.71/kotlin-stdlib-jdk8-1.2.71.pom
>     https://maven.google.com/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.2.71/kotlin-stdlib-jdk8-1.2.71.jar
> Required by:
>     project : > com.android.tools.build:gradle:3.2.1
>     project : > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:builder:3.2.1
>     project : > com.android.tools.build:gradle:3.2.1 > com.android.tools.lint:lint-gradle-api:26.2.1
>     project : > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:gradle-api:3.2.1
>     project : > com.android.tools.build:gradle:3.2.1 > androidx.databinding:databinding-compiler-common:3.2.1
>     project : > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:builder:3.2.1 >
> com.android.tools:sdk-common:26.2.1
>     project : > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:builder:3.2.1 >
> com.android.tools:common:26.2.1
>     project : > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:builder:3.2.1 >
> com.android.tools.build:manifest-merger:26.2.1
>     project : > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:builder:3.2.1 >
> com.android.tools:sdklib:26.2.1 > com.android.tools:repository:26.2.1

关键是我根本不使用Kotlin。我将classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71" 添加到gradle依赖项,但同样的错误引发了。我在整个项目中搜索了Kotlin,但除了一些replay_pid1632.log文件之外什么都没有。

TNX

android android-studio gradle android-gradle build.gradle
3个回答
1
投票

我认为你不应该给id类型资源赋值。更改

<item name="googledefaultpass" type="id">123456789</item>

to 

<item name="googledefaultpass" type="id"/>

1
投票

resource-type id一定没有价值。

因此,改变:

<item name="googledefaultpass" type="id">123456789</item>

要么:

<item name="googledefaultpass" type="integer">123456789</item>
<item name="googledefaultpass" type="string">123456789</item>

或者删除条目并使用AccountManager获取帐户。

关于kotlin-stdlib-jdk8依赖;它可以在存储库mavenCentral()中找到:

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.10"

也许还删除了这个重复的依赖项:

implementation fileTree(include: ['*.jar'], dir: 'libs')

0
投票

尝试添加

classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71'

在项目级内部gradle依赖项,然后添加

implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.71'

在你的应用程序级别内。也许你的一个库需要kotlin插件。

© www.soinside.com 2019 - 2024. All rights reserved.