【发布时间】:2018-12-04 08:43:25
【问题描述】:
我刚刚将我的 android studio 更新到了 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 编译 --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,但结构是一样的。
我已经更新了我所有的库。
应用级分级:
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'
项目级等级:
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 Studio,问题解决了,但我遇到了以下错误:
> 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
【问题讨论】:
-
您是否尝试过使缓存无效并重新启动?
-
删除 Project->app ->build 文件夹。如果您无法直接删除它,则可以删除所有内部文件夹,例如 generated、intermedias、outputs 等...,然后执行 invalid caches / Restart。
-
@Alex 你会检查我的帖子更新吗? tnx
-
@RumitPatel 你会检查我的帖子更新吗? tnx
-
我不明白为什么您会收到 kotlin 错误。你可以根据我的第一条评论再做一次。或者您可以尝试将所有 gradle 依赖项更新为最新版本。
标签: android android-studio gradle android-gradle-plugin build.gradle