Xamarin-android: APT0000: unexpected element <activity> found in <manifest>.

Created on 11 Jan 2020  路  4Comments  路  Source: xamarin/xamarin-android

Steps to Reproduce

  1. Enable aapt2 (Use incremental android packaging system ) in Android Build >> General
  2. Build the application

Expected Behavior

We should be able get the sucessful build

Actual Behavior

Local Build Error : APT0000: unexpected element found in .

App Center Build Error (only after enabling .aab build) :
1. APT0000: unexpected element found in .
2. ##[error]Error: The process '/Library/Frameworks/Mono.framework/Versions/6_4_0/bin/msbuild' failed with exit code 1

Local Version Information

=== Visual Studio Community 2019 for Mac ===

Version 8.4 (build 2657)
Installation UUID: e68b7427-2235-4d07-8203-ade9ce959a07
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 5.16.1.25 (issue-7441-d16-3-vsmac / 881172e73)

Package version: 606000155

=== Mono Framework MDK ===

Runtime:
Mono 6.6.0.155 (2019-08/296a9afdb24) (64-bit)
Package version: 606000155

=== Roslyn (Language Service) ===

3.4.0-beta4-19562-05+ff930dec4565e2bc424ad3bf3e22ecb20542c87d

=== NuGet ===

Version: 5.3.0.6192

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/3.1.100/Sdks
SDK Versions:
3.1.100
3.0.101
2.1.701
2.1.700
2.1.505
2.1.302
2.1.300-preview2-008533
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.6.0/lib/mono/msbuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
3.1.0
3.0.1
2.1.14
2.1.12
2.1.11
2.1.9
2.1.2
2.1.0-preview2-26406-04

=== Xamarin.Profiler ===

Version: 1.6.12.29
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Apple Developer Tools ===

Xcode 11.3 (15712)
Build 11C29

=== Xamarin.Mac ===

Version: 6.8.3.0 (Visual Studio Community)
Hash: 0d8fe219c
Branch: d16-4
Build date: 2019-12-04 13:06:40-0500

=== Xamarin.iOS ===

Version: 13.8.3.0 (Visual Studio Community)
Hash: 0d8fe219c
Branch: d16-4
Build date: 2019-12-04 13:06:41-0500

=== Xamarin Designer ===

Version: 16.4.0.468
Hash: 519082ea8
Branch: remotes/origin/d16-4
Build date: 2019-12-04 16:21:00 UTC

=== Xamarin.Android ===

Version: 10.1.1.0 (Visual Studio Community)
Commit: xamarin-android/d16-4/f2c9364
Android SDK: /Users/abhijeet/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
5.0 (API level 21)
5.1 (API level 22)
6.0 (API level 23)
7.0 (API level 24)
7.1 (API level 25)
8.0 (API level 26)
8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 29.0.5
SDK Build Tools Version: 29.0.2

Build Information:
Mono: bef1e63
Java.Interop: xamarin/java.interop/d16-4@c4e569f
ProGuard: xamarin/proguard/master@905836d
SQLite: xamarin/sqlite/3.28.0@46204c4
Xamarin.Android Tools: xamarin/xamarin-android-tools/master@9f4ed4b

=== Microsoft Mobile OpenJDK ===

Java SDK: /Users/abhijeet/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 16.4.0.9
Hash: 3f7256f
Branch: remotes/origin/d16-4
Build date: 2019-12-19 18:59:12 UTC

=== Android Device Manager ===

Version: 16.4.0.28
Hash: 68e9956
Branch: remotes/origin/d16-4
Build date: 2019-12-19 18:59:32 UTC

=== Xamarin Inspector ===

Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1

=== Build Information ===

Release ID: 804002657
Git revision: 4c6723413e884e024466fc93ff10e938bca7f721
Build date: 2020-01-06 18:20:13+00
Build branch: release-8.4
Xamarin extensions: 0f572cad12fd3886cd8e21a8b93b86e29ceaf111

=== Operating System ===

Mac OS X 10.14.6
Darwin 18.7.0 Darwin Kernel Version 18.7.0
Thu Jun 20 18:42:21 PDT 2019
root:xnu-4903.270.47~4/RELEASE_X86_64 x86_64

App+Library Build need-info

Most helpful comment

The activity needs to appear inside the application element

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.infinitespacestudios.adcoop">
    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="29" />
    <application android:label="AdCoOp.Android">
        <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="@android:style/Theme.Translucent" />
        <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="<ad id metadata>" />
    </application>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.FLASHLIGHT" />
</manifest>

Note that aapt2 is much much stricter about what is ok with regards to resources and the manifest.

All 4 comments

@glintpursuit can you post your manifest file please so we can take a look as what might be causing the issue?

Please got through below manifest file as requested.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" package="com.yzx.XYZ.app" android:versionName="1.0.0" android:versionCode="10000">
    <uses-permission android:name="com.android.vending.BILLING" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-feature android:name="android.hardware.camera" android:required="false" />
    <uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
    <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="29" />
    <application android:label="My App" android:theme="@style/MyTheme" android:icon="@drawable/ic_launcher" android:largeHeap="true">
        <provider android:name="android.support.v4.content.FileProvider" android:authorities="com.yzx.XYZ.appp.fileprovider" android:exported="false" android:grantUriPermissions="true">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"></meta-data>
        </provider>
    </application>
</manifest>

The activity needs to appear inside the application element

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.infinitespacestudios.adcoop">
    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="29" />
    <application android:label="AdCoOp.Android">
        <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="@android:style/Theme.Translucent" />
        <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="<ad id metadata>" />
    </application>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.FLASHLIGHT" />
</manifest>

Note that aapt2 is much much stricter about what is ok with regards to resources and the manifest.

Thanks @dellis1972

Now we are able to build with aap2 settings on.

Was this page helpful?
0 / 5 - 0 ratings