Xamarin Forms - PCL project The app could not be started - android

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

Related

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

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.

java.lang.NoClassDefFoundError: com.millennialmedia.android.MMAdView

I am Using Millenial media in my app. i have several apps running with following code but now when i try to copy paste running code for new apps it shows the error java.lang.NoClassDefFoundError: com.millennialmedia.android.MMAdView
this is how i am creating MMAdView object and inserting it in my Linear Layout.
LinearLayout myLayout = (LinearLayout) findViewById(R.id.layoutadd);
adview = new MMAdView(MyClass.this, MYAPID,"MMBannerAdBottom", 30);
myLayout.addView(adview, new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT));
MMAdListener listener = new MyAdListener();
adview.setListener(listener);
adview.callForAd();
this is the xml declaration
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xxx.xxx"
android:versionCode="1"
android:versionName="1.0"
android:installLocation="auto">
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".MyClass"
android:label="#string/app_name"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.millennialmedia.android.MMAdViewOverlayActivity">
</activity>
<activity android:name="com.millennialmedia.android.VideoPlayer"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:configChanges="keyboardHidden|orientation|keyboard" >
</activity>
</application>
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<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" />
</manifest>
i have also imported liabrary...
THIS THING IS WORKING IN MY OTHER APPS JUST IS THAT FROM FEW DAYS ITS NOT WORKING PROPERLY FOR NEW APPS.
This usually happens when the JAR file isn't copied onto the device. On Millennial Media's wiki page, they show you how to add the JAR to your project. After you select the library (9th bullet point), but before you hit "OK", go to the "Order and Export" tab and make sure the checkbox next to MMAdView.jar is checked. By default, it isn't. Push OK and try running your program.

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.

Contact permissions problem in android manifest

I need to set the permission in the manifest to read, I manually edited the manifest after having problems trying to use the android manifest editor. My code is below and is currently proving to be erroneous. Any help appreciated. :)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ac.uk.d"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".Quiz"
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>
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.READ_CONTACTS"/>
</manifest>
The issue is that you have not cleaned the project. To clean the project, select 'Project' on the top menu bar then you'll find clean upon which you clean the selected project or clean all projects as per your needs..

APK Deployment Issue

I have been able to create a *.apk file from my code, place the file
in IIS, and download it onto a number of Android phones. Upon the
install, the application works exactly as expected.
However, after a phone is rebooted, the application name is changed to
the fully-qualified Java class name of the activity in the menu (so
"MyActivity" becomes "com.mycompany.MyActivity"), and when I try to go
to Menu > Settings, I get an error that causes android to force close
my application.
Looking into DDMS, I see that I get an error indicating that it can
not find my Preferences activity, despite the fact upon initial
install, it works properly.
I'm using Eclipse on Windows XP, and have several Android devices at
my disposal to test with.
Any idea what's going on?
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.company.app"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/logo" android:label="#string/app_name"> <!--android:debuggable="true">-->
<activity android:name="com.company.app.ActivityMain"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.company.app.Preferences"
android:label="#string/app_settings">
<intent-filter>
<category android:name="android.intent.category.PREFERENCE"></category>
<action android:name="android.intent.action.MAIN"></action>
</intent-filter>
</activity>
<service android:name="com.company.app.Service"></service>
</application>
<uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
</manifest>
So I finally got this to work. I think that the package installer on the HTC Hero (and maybe the HTC Droid Eris) has some issues.
I uninstalled my application from the phone, changed the name of my main activity, and re-deployed it onto the Hero. I started to immediately get a "Force Close." I connected the device to DDMS and looked at the error. It was still looking for my old activity name. I factory reset the device and reinstalled the same package (with the updated name) and everything works as expected.
So it seems that the package installer is caching some part of the old manifest or something, not really sure what exactly is going on there. I may play with it some more if I get time.
I don't know if someone else could verify this problem, maybe it's something that should be taken up with HTC?
try to use this manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.company.app"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/logo" android:label="#string/app_name"> <!--android:debuggable="true">-->
<activity android:name=".ActivityMain"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Preferences"
android:label="#string/app_settings">
<intent-filter>
<category android:name="android.intent.category.PREFERENCE"></category>
<action android:name="android.intent.action.MAIN"></action>
</intent-filter>
</activity>
<service android:name=".Service"></service>
</application>
<uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
</manifest>

Categories

Resources