我将android studio升级到了3.2.0并创建了默认项目。但是编译器显示错误:
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之前,我的项目运行良好。 而且我想不出什么办法。只需要帮助!!
答案 0 :(得分:2)
清单文件中有问题。 服务标签需要包含意图过滤器标签 在使用动作标签之前! 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>