I'm trying to receive files from external apps using Intent and Action.Send. I chose my app at chooser list and then app trying to start but it crashes:
java.lang.ClassNotFoundException: Didn't find class "net.inlu.Incrypta.MainActivity" on path: DexPathList[[zip file "/data/app/net.inlu.Incrypta-1.apk"],nativeLibraryDirectories=[/data/app-lib/net.inlu.Incrypta-1, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:497) at java.lang.ClassLoader.loadClass(ClassLoader.java:457) at 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) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:604) at dalvik.system.NativeStart.main(Native Method)
my manifest file:
<?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>
I've seen a lot of such issues for Android, but didn't find anuthing exactly for Xamarin.Android. May be anyone knows how to fix it.
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));
}
}
}
}
Try to explicitly change the ACW(Android Callable Wrapper) name of your MainActivity
. This can be done multiple ways, but the easiest way would be to use the Name
property inside the [Activity]
attribute to specify a name. You would then set that name to the name it's looking for.
i.e.
[Activity(Name="net.inlu.incrypta.MainActivity")]
Note: Ensure your namespace follows Java conventions in the sense of a fully qualified name.
EX: com.my.package.ClassName