Oğu*_*gül 40 android android-manifest aapt
注意:请不要将此"android.enableAapt2 = false"作为答案发布.这不是一个解决方案.它只是忽略了在运行时没有引起任何问题的真正错误.
解决方案很简单,只是在清单文件中的intent过滤器之外删除了错误放置的操作标记.
有一个由Android Studio 2.3构建的应用程序很好.更新Android Studio 3.0 Stable后,开始出现此错误并无法构建我的项目.
这是我的manifest.xml
<application
android:name=".ApplicationClass"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<!--other unrelated stuff-->
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.xxx.xxx" />
</intent-filter>
</receiver>
</application>
Run Code Online (Sandbox Code Playgroud)
错误显示此行:
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
Run Code Online (Sandbox Code Playgroud)
如果我评论/删除此动作标记行,项目构建正常但是它是必要的GCM,我无法删除它.
当您看到日志时,主清单文件中不会发生错误,发生在/ build/intermediates/manifests/full/debug /AndroidManifest.xml
尝试清洁,重建,禁用即时运行.有什么解决方案吗?
错误日志:
/THE_PROJECT_PATH/app/build/intermediates/manifests/full/debug/AndroidManifest.xml
Error:(99) error: unknown element <action> found.
Error:(99) unknown element <action> found.
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':app:processDebugResources'.
> Failed to execute aapt
Information:BUILD FAILED in 1s
Information:6 errors
Information:0 warnings
Information:See complete output in console
Run Code Online (Sandbox Code Playgroud)
Raz*_*Raz 37
你有一个错位的标签.新的AAPT(AAPT2)现在会引发错误.
来自这里的文档:https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html
使用AAPT2时行为会发生变化
为了改进增量资源处理,Android插件3.0.0默认启用AAPT2.虽然AAPT2应该可以立即使用旧项目,但本节介绍了一些您应该注意的行为更改.
Android清单中的元素层次结构
在以前版本的AAPT中,嵌套在Android清单中不正确节点中的元素会被忽略或导致警告.例如,请考虑以下示例:
Run Code Online (Sandbox Code Playgroud)<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.myname.myapplication"> <application ... <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <action android:name="android.intent.action.CUSTOM" /> </activity> </application> </manifest>以前版本的AAPT会忽略错位的标签.但是,使用AAPT2,您会收到以下错误:
Run Code Online (Sandbox Code Playgroud)AndroidManifest.xml:15: error: unknown element <action> found.要解决此问题,请确保您的清单元素已正确嵌套.有关更多信息,请阅读Manifest文件结构.
小智 16
在根 项目的gradle.properties中添加此代码:
android.enableAapt2=false
Run Code Online (Sandbox Code Playgroud)
这对我有用
root
|
|--gradle.properties
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
54114 次 |
| 最近记录: |