本文介绍了在Xamarin表单中进行深层链接时,获取类未发现异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试向我的项目添加深层链接功能。
I am trying to add deeplinking feature to my project.
我在Androidmanifest.xml中的代码
My code in Androidmanifest.xml
<?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.companyname.sample">
<uses-sdk android:minSdkVersion="15" />
<application android:label="sample.Android">
<activity android:icon="@drawable/icon" android:name="sample.Droid.MainActivity" android:label="sample">
<intent-filter>
<data android:scheme="http" android:host="www.sample.com" android:pathPrefix="/code" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
</application>
</manifest>
Mainactivity.cs
Mainactivity.cs
using Android.App;
using Android.Content.PM;
using Android.OS;
namespace sample.Droid
{
[Activity(Label = "sample", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
}
}
}
以下是示例网址I正在使用
Here is the sample url I am using http://www.sample.com/code/hi
当我点击此URL时,出现以下异常:
When I tap on this url I am getting the following Exception:
02-08 13:16:25.168 E/AndroidRuntime(12130): FATAL EXCEPTION: main
02-08 13:16:25.168 E/AndroidRuntime(12130): Process: com.companyname.sample, PID: 12130
02-08 13:16:25.168 E/AndroidRuntime(12130): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.companyname.sample/sample.Droid.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "sample.Droid.MainActivity" on path: DexPathList[[zip file "/mnt/asec/com.companyname.sample-2/base.apk"],nativeLibraryDirectories=[/mnt/asec/com.companyname.sample-2/lib/arm, /vendor/lib, /system/lib]]
02-08 13:16:25.168 E/AndroidRuntime(12130): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2236)
02-08 13:16:25.168 E/AndroidRuntime(12130): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
02-08 13:16:25.168 E/AndroidRuntime(12130): at android.app.ActivityThread.access$800(ActivityThread.java:151)
02-08 13:16:25.168 E/AndroidRuntime(12130): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
02-08 13:16:25.168 E/AndroidRuntime(12130): at android.os.Handler.dispatchMessage(Handler.java:102)
02-08 13:16:25.168 E/AndroidRuntime(12130): at android.os.Looper.loop(Looper.java:135)
02-08 13:16:25.168 E/AndroidRuntime(12130): at android.app.ActivityThread.main(ActivityThread.java:5254)
02-08 13:16:25.168 E/AndroidRuntime(12130): at java.lang.reflect.Method.invoke(Native Method)
02-08 13:16:25.168 E/AndroidRuntime(12130): at java.lang.reflect.Method.invoke(Method.java:372)
02-08 13:16:25.168 E/AndroidRuntime(12130): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902)
02-08 13:16:25.168 E/AndroidRuntime(12130): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:697)
02-08 13:16:25.168 E/AndroidRuntime(12130): Caused by: java.lang.ClassNotFoundException: Didn't find class "sample.Droid.MainActivity" on path: DexPathList[[zip file "/mnt/asec/com.companyname.sample-2/base.apk"],nativeLibraryDirectories=[/mnt/asec/com.companyname.sample-2/lib/arm, /vendor/lib, /system/lib]]
02-08 13:16:25.168 E/AndroidRuntime(12130): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
02-08 13:16:25.168 E/AndroidRuntime(12130): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
02-08 13:16:25.168 E/AndroidRuntime(12130): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
02-08 13:16:25.168 E/AndroidRuntime(12130): at android.app.Instrumentation.newActivity(Instrumentation.java:1066)
02-08 13:16:25.168 E/AndroidRuntime(12130): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2226)
02-08 13:16:25.168 E/AndroidRuntime(12130): ... 10 more
02-08 13:16:25.168 E/AndroidRuntime(12130): Suppressed: java.lang.ClassNotFoundException: sample.Droid.MainActivity
02-08 13:16:25.168 E/AndroidRuntime(12130): at java.lang.Class.classForName(Native Method)
02-08 13:16:25.168 E/AndroidRuntime(12130): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
02-08 13:16:25.168 E/AndroidRuntime(12130): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
02-08 13:16:25.168 E/AndroidRuntime(12130): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
02-08 13:16:25.168 E/AndroidRuntime(12130): ... 13 more
02-08 13:16:25.168 E/AndroidRuntime(12130): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
02-08 13:16:25.186 I/Process (12130): Sending signal. PID: 12130 SIG: 9
任何人,请帮助我解决此问题。
Anybody, please help me to solve this issue. Already lost a lot of days for this.
在google驱动器中上传了一个示例项目,下面是其链接:
https://drive.google.com/file/d/1aSuwb_SuCIdC1E_BCFBdi4y7NRP5275y/view?usp=sha a>
推荐答案
In android manifest set android:name like below:
android:name=".MainActivity"
And in Mainactivity add Name like below:
[Activity(Name = "packagename.MainActivity")]
这篇关于在Xamarin表单中进行深层链接时,获取类未发现异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!