Xamarin AndroidManifest.xml is different to the one in Visual Studio - android

In Visual Studio, une the Properties/AndroidManifest.xml file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:installLocation="auto" android:versionName="1.0">
<uses-sdk />
<application android:label="Aftermath" android:largeHeap="true">
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" /></application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
However, after installation on a device, when I check my application's manifest using the manifestViewer app (available on the playstore), the manifest is completly different and looks like this:
<?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="Aftermath.Aftermath">
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="15"/>
<application
android:icon="#2130837644"
android:name="mono.android.app.Application"
android:debuggable="true">
<activity
android:name="androclient.activities.AftermathActivity"
android:screenOrientation="landscape"/>
<activity
android:label="Aftermath"
android:icon="#2130837644"
android:name="androclient.activities.TitleScreenActivity"
android:screenOrientation="landscape">
<intent-filter>
<action
android:name="android.intent.action.MAIN"/>
<category
android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<provider
android:name="mono.MonoRuntimeProvider"
android:exported="false"
android:authorities="Aftermath.Aftermath.mono.MonoRuntimeProvider.__mono_init__"
android:initOrder="2147483647"/>
<receiver
android:name="mono.android.Seppuku">
<intent-filter>
<action
android:name="mono.android.intent.action.SEPPUKU"/>
<category
android:name="mono.android.intent.category.SEPPUKU.Aftermath.Aftermath"/>
</intent-filter>
</receiver>
</application>
<uses-permission
android:name="android.permission.INTERNET"/>
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission
android:name="android.permission.ACCESS_NETWORK_STATE"/>
</manifest>
Is this normal ? How can I edit the manifest to include application attributes, meta-data and activities ?
Thanks

Xamarin uses Attributes in code to fill in the Android Manifest when building. You can use Attributes for Activity, Service, BroadcastReceiver, IntentFilter, Application, MetaData etc.
So if you have a BroadcastReceiver like this in Xamarin
[BroadcastReceiver]
[IntentFilter(new string[] { "com.example.filter" }]
public class BR : BroadcastReceiver {}
You'll get an addition to the generated manifest with your BroadcastReceiver and IntentFilter.
Or an Activity such as
[Activity(MainLauncher = true, ScreenOrientation = Android.Content.PM.ScreenOrientation.Portrait)]
public class MainActivity : Activity {}
Or in your Application class
[Application(Theme = "#style/AppTheme", Icon = "#drawable/icon")]
public class App : Application
All of these will be included in the generated Android Manifest

Hi and thanks for answering.
It turned out that I had to delete the AndroidManifest.xml file and restart visual studio to have the compiler to properly update the manifest during the compilation.
Weird bug...
Hope this will help somebody.

Related

Unable to find explicit activity class {}; have you declared this activity in your AndroidManifest.xml,my android manifest file read like this

<-- I m getting this fatal error which occurred while trying to upload pictures for my app in the android studio.please help get rid of this error.whats the best solution? the error is: Unable to find explicit activity class {}; have you declared this activity in your AndroidManifest.xml -->>
----------
----------
: Unable to find explicit activity class {}; have you declared this
activity in your AndroidManifest.
<?XML version="1.0" encoding="utf-8"?>
<manifest XML ns:android="http://schemas.android.com/apk/res/android"
package="com.parse.starter" >
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="18"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-sdk
android:minSdkVersion="15"
android:maxSdkVersion="23"/>
<application
android:name=".StarterApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.parse.APPLICATION_ID"
android:value="#string/parse_app_id" />
<meta-data
android:name="com.parse.CLIENT_KEY"
android:value="#string/parse_client_key" />
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
You have to check a package where MainActivity is placed. It should be com.parse.starter. It seems MainActivity is in other place and you are getting an exception.
This can happen when you say copy and paste an activity instead of adding it via Android Studio. Basically it just means you'll need to add this line to your AndroidManifest.xml:
<activity android:name=".your-activity-class-name"></activity>

Xamarin Forms - PCL project The app could not be started

I am using Visual Studio 2015 and have a PCL based project created. All this application does is show a splash screen and then navigate to the next page. I am unable to get this to work on Android. Here is the link for the splash screen
The error I get:
The application could not be started. Ensure that the application has
been installed to the target device and has a launchable activity
(MainLauncher = true).
Additionally, check Build->Configuration Manager to ensure this
project is set to Deploy for this configuration.
I have followed this link and tried all the solutions there and still have the same result
Any tips to fix this?
Edit
Android Manifest File
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="Splash.Splash" android:installLocation="auto" android:versionCode="1" android:versionName="1.0">
<!--suppress UsesMinSdkAttributes-->
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application android:icon="#drawable/icon-3" android:name="mono.android.app.Application" android:allowBackup="true" android:label="Splash.Splash" android:debuggable="true">
<activity android:label="Splash screen" android:name="md5ac585b47313c1dc414c7b7a18f93e457.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:icon="#drawable/icon-3" android:noHistory="true" android:theme="#style/Theme.Splash" android:name="md5ac585b47313c1dc414c7b7a18f93e457.Splash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider android:name="mono.MonoRuntimeProvider" android:exported="false" android:initOrder="2147483647" android:authorities="Splash.Splash.mono.MonoRuntimeProvider.__mono_init__" />
<!--suppress ExportedReceiver-->
<receiver android:name="mono.android.Seppuku">
<intent-filter>
<action android:name="mono.android.intent.action.SEPPUKU" />
<category android:name="mono.android.intent.category.SEPPUKU.STM.STM" />
</intent-filter>
</receiver>
</application>
</manifest>
Edit
New Manifest below
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="Super.Super" android:installLocation="auto">
<uses-sdk android:minSdkVersion="15" />
<application android:icon="#drawable/stmicon-3"></application>
</manifest>
EDITED: There was more than one problem in your question. I addressed two of them but the last one was the icon name.
Android resources can't have the '-' character in the name.
so this is the correction:
<application android:icon="#drawable/stmicon3"></application>
Initial answer:
Its wrong to have two activities with the same intent filter for launching.
So, first on your Manifest, remove entirely the two Activities tags.
For helping debugging this. please change your manifest to this (yes we are ignoring the Provider too)
So your final Manifest would be:
<?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.yournamespace.courier">
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="22" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application android:label="yournamespace">
</application>
</manifest>
After this, were gonna set the SplashActivity as MainLauncher:
[Activity(MainLauncher = true,
NoHistory = true)]
public class SplashActivity : AppCompatActivity
And finally the MainActivity:
[Activity(Icon = "#drawable/icon")]
public class MainActivity : FormsAppCompatActivity
You Can Do As Jon Sugguested Or Just Go Into Your Android Device Settings & Application Manager And uninstall the previous version of the application on your android device

Error: Activity class {} does not exist

My application launches well both on Nexus 7 and Nook Tablet, but doesn't start on Kindle Fire with the following error:
Error: Activity class {com.js.pathoflight/com.js.pathoflight.JSNativeActivity} does not exist.
Here is my manifest complete:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.js.pathoflight"
android:versionCode="3"
android:versionName="0.8.3">
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application android:label="#string/app_name"
android:icon="#drawable/ic_launcher"
android:allowBackup="true"
android:hasCode="true" >
<activity android:name=".JSNativeActivity"
android:label="#string/app_name"
android:configChanges="orientation|keyboardHidden"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
<meta-data android:name="android.app.lib_name"
android:value="PathOfLight" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
It seems like a device issue, but I have another (similar) application which runs on the same device well.
How can I solve it?
The real problem was that there were another application with the same package name on device (I tried a sample and gave it my real app package name)! When I removed it everything became working right!

calling activity in another package

so i have an application which has a default package as com.android.
within this package i have two packages as android.audio and android.video.
now i need to call activity1 from android.audio from activity2 in android.video.
i have tried using something like
Intent i = new Intent();
i.setClassName("android.video","android.audio.activity1");
startActivity(i);
but this doesnt seem to work.
what is the right way to do it? where have i gone wrong?
i m not able to navigate to any activity outside the package.
EDIT:
this is how it is declared in the manifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.RECORD_VIDEO" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_title" >
<activity
android:label="#string/app_title"
android:name=".WeaveActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="android.login.LoginActivity"></activity>
<activity android:name="android.login.RegisterActivity"></activity>
<activity android:name="android.video.activity2"></activity>
<activity android:name="android.audio.activity1"></activity>
</application>
Intent i = new Intent();
i.setClassName(activity2.this,activity1.class);
startActivity(i);
use above code and add these activity in your manifeast file.
AS you told your package name is com.android
<activity android:name=".audio.activity1"></activity>
<activity android:name=".video.activity2"></activity>
or use complete path as below
<activity android:name="com.android.audio.activity1"></activity>
<activity android:name="com.android.video.activity2"></activity>
and a small suggestion for you never use your package name as com.android because if use then while submitting the app to Google Play it wont accept it as the package com.android is used for android SDK.
in manifest decalre like
<activity android:name=”.activity1”
android:label=”Activity 1”>
<intent-filter>
<action android:name=”android.audio.activity1”/>
<category android:name=”android.intent.category.DEFAULT”/>
</intent-filter>
</activity>
and while calling from any activity...
startActivity(new Intent(“android.audio.activity1”));
hope this will help.
Check your package name.
I think you gave only "audi" instead of "audio"
I rewrote my entire package structure by giving project package name as com.android and rest of the sub packages as com.android.audio and com.android.video and now it seems to work. thanks for all your help.

Urban Airship config Android app manifest file

I want to use an Urban Airship service in my Android app.
I've already registered a sender email following this tutorial.
Now when I've got my C2DM AUTH_TOKEN I've created an app on my UA account and pasted the TOKEN along with the package name of my app (which is "com.neo.ovs") .
Now onCreate method I've added those lines of code :
PushManager.enablePush();
PushPreferences prefs = PushManager.shared().getPreferences();
Logger.info("My Application onCreate - App APID: " + prefs.getPushId());
Now of course I get an error becouse of various permissions I didn't write in my manifest.xml file.
But I'm a bit confused about the package names and prefixes I should alter following this manifest example.
how should my manifest look ?
write now it looks like this :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.neo.ovs"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:icon="#drawable/logo"
android:label="OVS" >
<activity
android:name=".LoginActivity"
android:label="OVS"
android:theme="#android:style/Theme.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Entry for MyListActivity.class -->
<activity
android:name="com.neo.ovs.MyListActivity"
android:label="My List Activity"
android:theme="#android:style/Theme.NoTitleBar" >
</activity>
<activity
android:name=".VideoScreen"
android:configChanges="orientation|keyboardHidden"
android:label="Video View Demo"
android:screenOrientation="landscape"
android:theme="#android:style/Theme.NoTitleBar" >
</activity>
</application>
</manifest>

Categories

Resources