我刚刚将我的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'
项目级别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 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
答案 0 :(得分:1)
我认为您不应该为id类型的资源赋值。更改
<item name="googledefaultpass" type="id">123456789</item>
to
<item name="googledefaultpass" type="id"/>
答案 1 :(得分: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')
答案 2 :(得分:0)
尝试添加
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71'
在项目级别的gradle内部,然后添加
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.71'
在您的应用级别gradle内部。 也许您的图书馆之一需要kotlin插件。
答案 3 :(得分:0)
就我而言,问题是我忘记在 StringArray
的项目中转义撇号。
所以在我的 strings.xml
中我改变了
<string-array name="questions">
<item>What's the weather today?</item>
</string-array>
到
<string-array name="questions">
<item>What\'s the weather today?</item>
</string-array>
现在它构建得非常好。