我試圖從外部應用程序使用Intent和Action.Send接收文件。我選擇我的應用程序在選擇器列表,然後應用程序試圖啓動,但它崩潰:Xamarin.Android java.lang.ClassNotFoundException
拋出java.lang.ClassNotFoundException:找不到類的路徑 「net.inlu.Incrypta.MainActivity」:DexPathList [ zip文件 「/data/app/net.inlu.Incrypta-1.apk"],nativeLibraryDirectories=[/data/app-lib/net.inlu.Incrypta-1, /vendor/lib,/ system/lib] ]在 dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) 在java.lang.ClassLoader.loadClass(ClassLoader.java:497)在 java.lang.ClassLoader.loadClass(ClassLoader.java:457)在 android.app.Instrumentation.newActivity(Instrumentation.java:1084)at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2115) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2248) at android.app.ActivityThread.access $ 800(ActivityThread.java:138)at android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1199) at android.os.Handler.dispatchMessage(Handler.java:102)at android.os.Looper.loop(Looper.java:136)at android.app.ActivityThread.main(ActivityThread.java:5054)at java.lang.reflect.Method.invokeNative(Native Method)at java.lang.reflect.Method.invoke(Method.java:515)at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:788) 在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:604)在 dalvik.system.NativeStart.main(本機方法)
我的清單文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="6" android:versionName="1.0.1" package="net.inlu.Incrypta" android:installLocation="auto">
<uses-sdk android:minSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<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" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<application android:allowBackup="true" android:label="@string/app_name" android:logo="@drawable/Logo" android:theme="@style/StartTheme" android:windowSoftInputMode="stateVisible|adjustPan" android:icon="@drawable/Logo">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
</activity>
</application>
</manifest>
我已經看到了很多Android的這些問題,但沒有找到準確的Xamarin.Android。可能有人知道如何解決它。
MainActivity:
namespace Android.App
{
[Activity (MainLauncher = true, Icon = "@drawable/Logo", NoHistory = true)]
public class MainActivity : Activity
{
protected override async void OnCreate (Bundle savedInstanceState)
{
BootStrapper.RegisterDependencies(new IoCModule());
Intent intent = Intent;
string action = intent.Action;
string type = intent.Type;
//Xamarin.Insights.Initialize (XamarinInsights.ApiKey, this);
base.OnCreate (savedInstanceState);
//SetContentView(Resource.Layout.splash);
try
{
var srv= BootStrapper.Container.Resolve<IServiceManager>();
var credentials = await srv.ConnectAsync();
StartActivity(credentials != null ? typeof(BaseActivity) : typeof(LoginActivity));
}
catch (Exception)
{
StartActivity(typeof(LoginActivity));
}
}
}
}
請出示你的'.BaseActivity'類的代碼 - 投訴/錯誤是,這個類是找不到的。 – ishmaelMakitla
@ishmaelMakitla,添加 –
您是否已將[Activity]屬性附加到您的「BaseActivity」中? –