3

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));
            }
        }
    }
} 
6
  • Please show the code for your .BaseActivity class - the complaint/error is that this class is not found. Commented Jun 21, 2016 at 14:25
  • @ishmaelMakitla, added Commented Jun 21, 2016 at 14:34
  • Do you have attached the [Activity]-attribute to your "BaseActivity"? Commented Jun 21, 2016 at 14:44
  • @StefanWanitzek, yes, of course, currently MainActivity = BaseActivity, sorry for confusing. Commented Jun 21, 2016 at 14:48
  • I don't understand the call to StartActivity in the OnCreate-method of the activity completely. However, I ran into some problems with namespace-names that have uppercase letters in the past. Can you try to change your namespace from net.inlu.Incrypta.BaseActivity to net.inlu.incrypta.BaseActivity? (notice the lowercase I in "Incrypta"). Commented Jun 21, 2016 at 14:51

2 Answers 2

3

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

https://developer.xamarin.com/releases/android/xamarin.android_5/xamarin.android_5.1/#Android_Callable_Wrapper_Naming

Sign up to request clarification or add additional context in comments.

2 Comments

@JonDouglas I have the same problem. I am using a SplashActivity that calls StartActivity(typeof(MainActivity)); and I have this ClassNotFoundException MainActivity... what can be?
It works for me, for testing purpose, I added the url as a message and tap the url from the message. My problem is app open on the message tab, no new tab is open for the app.
0

My case: I referenced Symbol.Xamarin.EMDK. (this is a third-party library) in the Android project. I removed it and the exception disappeared, so your problem may be caused by a third-party library. Or your third-party library does not have the correct permission configuration.

Below is the configuration of my third-party library, it can also solve this issue:

<uses-permission android:name="com.symbol.emdk.permission.EMDK" />
<application android:label="@string/app_name" android:icon="@mipmap/icon">
        <uses-library android:name="com.symbol.emdk" android:required="false" />
</application>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.