智慧并不产生于学历,而是来自对于知识的终生不懈的追求。这篇文章主要讲述更新android studio后Android资源编译失败相关的知识,希望能为你提供帮助。
我刚刚将我的android工作室更新到版本3.2.1,并通过android studio更新了我的gradle到最新版本,但构建项目面临此错误:
Android资源编译失败输出:D: projectsmyProjectappbuildintermediatesincrementalmergeDebugResourcesmerged.dirvaluesvalues.xml:2577:错误:内部元素必须是资源引用或为空。 D: projectsmyProjectappbuildintermediatesincrementalmergeDebugResourcesmerged.dirvaluesvalues.xml:2585:错误:内部元素必须是资源引用或为空。在该行中它表示存在错误,此代码存在:
命令:C: UsersHamed.gradlecachestransforms-1files-1.1aapt2-3.2.1-4818971-windows.jarea639d8248f3ebb66b449dfd3b6a9a07aapt2-3.2.1-4818971-windowsaapt2.exe compile- -legacy-oD: projectsmyProjectappbuildintermediatesresmergeddebugD: projectsmyProjectappbuildintermediatesincrementalmergeDebugResourcesmerged.dirvaluesvalues。 xml守护程序:AAPT2 aapt2-3.2.1-4818971-windows守护程序#0
怎么了?当我搜索解决方案是this,但结构是相同的。< item name="googledefaultpass" type="id"> 123456789< /item>
【更新android studio后Android资源编译失败】我已经更新了所有库。
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
答案我认为你不应该给id类型资源赋值。更改
<
item name="googledefaultpass" type="id">
123456789<
/item>
to <
item name="googledefaultpass" type="id"/>
另一答案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')
另一答案尝试添加
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71'
在项目级内部gradle依赖项,然后添加
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.71'
在你的应用程序级别内。也许你的一个库需要kotlin插件。
推荐阅读
- 当我转到“设置”时,Android Studio会冻结
- 无法解析配置'(app:debugCompileClasspath的所有依赖项)
- Android Studio(需要407代理身份验证)
- Kotlin Android Studio - 从newsapi加载缩略图
- 如何通过快捷方式在Android Studio中自动生成try catch代码块()
- Android studio / IntelliJ构建窗口自动显示
- android.permission.CALL_PHONE
- 在Android上获取应用程序安装日期
- 在Windows上获取Android的SHA键