I am receiving this error when trying to launch a Xamarin forms application on Android from a text message URL. I have been following the steps noted in THIS article.
Here the application node in my AppManifest.xml
<application android:label="Label A">
<activity android:icon="@drawable/Icon" android:label="LabelB" android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="superduperapp" />
</intent-filter>
</activity>
</application>
According to the article I need to do something with intent objects to get the OnCreate override to fire but I think I am not matching something up right with my manifest and the naming convention for a class I created below.
[Activity(Label = "urlentryclass")]
public class OpenFromURI : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
Intent outsideIntent = Intent;
var x = Intent.Data.EncodedAuthority;
}
}
So, with the above code added to my xamarin solution I also have a webpage with the code below..
<a href="superduperapp://QueryStringParamsGoHere"></a>
and when i click the link above from my mobile browser it touches the mobile app because I get the error below
MyApp.Mobile.Droid.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "MyApp.Mobile.Droid.MainActivity" on path: DexPathList[[zip file "/data/app/MyApp.Mobile.Droid-1/base.apk"],nativeLibraryDirectories=[/data/app/MyApp.Mobile.Droid-1/lib/arm64, /data/app/MyApp.Mobile.Droid-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]] occurred
MyApp.Mobile.Droid.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "MyApp.Mobile.Droid.MainActivity"
Xamarin.Android
, by default, generates the Java wrappers using MD5-based class names to avoid Java class name clashing, such as:
md579731053346ff64fcf21847b09163ce1.MainActivity
You have hard-coded a android:name=".MainActivity"
in your manifest but the generated class will be MD5-based by default.
Open up your MainActivity
and within the ActivityAttribute
on your MainActvity
class, add a fully qualified name within a Name
parameter of that attribute, this will force the Xamarin.Android
build process to use a Java-class name of your choosing vs. the MD5-based one and thus it will match your manifest entry.
[Activity(Name = "MyApp.Mobile.Droid.MainActivity", Label = "MySuperDuperApp", MainLauncher = true, Icon = "@mipmap/icon")]
public class MainActivity : Activity
{
~~~
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With