首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Android资源链接失败-守护进程: AAPT2 aapt2-3.2.0-4818971-windows守护进程#0

Android资源链接失败-守护进程: AAPT2 aapt2-3.2.0-4818971-windows守护进程#0
EN

Stack Overflow用户
提问于 2018-09-30 02:36:10
回答 1查看 4.1K关注 0票数 3

我将android studio升级到3.2.0并创建了默认项目。但是编译器显示了这个错误:

代码语言:javascript
复制
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:

代码语言:javascript
复制
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:

代码语言:javascript
复制
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'
}

我的清单:

代码语言:javascript
复制
  <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之前,我的项目运行得很好。我想不出任何方法来out.Just寻求帮助!!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-09-30 06:03:18

清单代码中存在问题。在使用操作标签之前,服务标签需要包含意图过滤器标签!!https://developer.android.com/guide/topics/manifest/service-element解决方案:

代码语言:javascript
复制
<service android:name=".service.ForegroundService" >
<intent-filter> 
        <action android:name="android.intent.action.PHONE_STATE" />
</intent-filter> 
    </service>
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52571396

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档