android - Android 资源链接失败 - 守护进程:AAPT2 aapt2-3.2.0-4818971-windows Daemon #0
问题描述
我将 android studio 升级到 3.2.0 并创建了默认项目。但是编译器显示错误:</p>
Android resource linking failed
Output: D:\android1\project\algeria\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml:54: error: unexpected element <action> found in <manifest><application><service>.
Command: C:\Users\nthan\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-4818971-windows.jar\82eccc572f5d84358296092db0bec570\aapt2-3.2.0-4818971-windows\aapt2.exe link -I\
D:\Sdk\platforms\android-26\android.jar\
--manifest\
D:\android1\project\algeria\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\
-o\
D:\android1\project\algeria\app\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
-R\
@D:\android1\project\algeria\app\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
--auto-add-overlay\
--java\
D:\android1\project\algeria\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
--custom-package\
\
-0\
apk\
--output-text-symbols\
D:\android1\project\algeria\app\build\intermediates\symbols\debug\R.txt\
--no-version-vectors
Daemon: AAPT2 aapt2-3.2.0-4818971-windows Daemon #0
我的项目构建 gradle:
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我的模块构建 gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "27.0.1"
defaultConfig {
applicationId ""
minSdkVersion 16
targetSdkVersion 26
versionCode 3
versionName "2.3"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
buildTypes.each {
it.buildConfigField 'String', 'handsome', black
}
}
dependencies {
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'
})
implementation 'com.android.support:appcompat-v7:26.+'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.google.android.exoplayer:exoplayer:r1.5.3'
implementation 'com.google.code.gson:gson:2.6.2'
implementation 'com.google.firebase:firebase-ads:10.2.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.android.gms:play-services-ads:8.4.0'
testImplementation 'junit:junit:4.12'
}
我的清单:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<!--<action android:name="android.intent.action.PHONE_STATE" >-->
<!--</action>-->
</intent-filter>
</activity>
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />
<activity android:name=".InterstitialActivity"></activity>
<service android:name=".service.ForegroundService" >
<action android:name="android.intent.action.PHONE_STATE" />
</service>
</application>
我有最新版本的android studio,在升级我的gradle之前我的项目运行良好......而且我想不出任何出路。只是为了帮助!
解决方案
您的清单代码有问题。在使用操作标签之前,服务标签需要包含意图过滤标签! https://developer.android.com/guide/topics/manifest/service-element 解决方案:
<service android:name=".service.ForegroundService" >
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
</service>
推荐阅读
- python - conda 没有显示更新的包
- maven - 如何在 Maven 版本中跳过模块:准备
- java - Apache Nutch 跳过 URL 和截断
- c# - 异步套接字在 Unity-iOS 上间歇性挂起
- c# - 如何解决对 XMLHttpRequest 的访问已被 CORS 策略阻止?
- jquery - jQuery 加载新视图,然后加载部分视图
- excel - excel公式如果数字然后vlookup以获取行中关联的文本
- python - 重新排列二进制数字
- android - 'MainActivity' 中的方法 'AlertUser' 的签名不正确
- ios - Flutter (iOS) 数字键盘小数分隔符