Having trouble when import jar file into Android Studio

cheeseburgercheeseburger Member ✭✭

I want to import jar file into Android studio from Xamarin Android Class Library following the tutorial in Xamarin Getting Started in Android(I can't insert link here yet). I follow the exact same in the tutorial but I met problems when I import jar file into Android studio. aar file works.

These are the errors I met in android studio:

            E/AndroidRuntime: FATAL EXCEPTION: main
                Process: com.example.username.hello_from_csharp, PID: 3800
                java.lang.RuntimeException: Unable to resume activity ``````````````````{com.example.username.hello_from_csharp/com.example.username.hello_from_csharp.MainActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.username.hello_from_csharp/hello_from_csharp.HelloActivity}; have you declared this activity in your AndroidManifest.xml?``````````````````
                    at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3429)
                    at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3469)
                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2732)
                    at android.app.ActivityThread.-wrap12(ActivityThread.java)
                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
                    at android.os.Handler.dispatchMessage(Handler.java:102)
                    at android.os.Looper.loop(Looper.java:154)
                    at android.app.ActivityThread.main(ActivityThread.java:6119)
                    at java.lang.reflect.Method.invoke(Native Method)
                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
                 Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.username.hello_from_csharp/hello_from_csharp.HelloActivity}; have you declared this activity in your AndroidManifest.xml?
                    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1805)
                    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1523)
                    at android.app.Activity.startActivityForResult(Activity.java:4225)
                    at android.support.v4.app.BaseFragmentActivityApi16.startActivityForResult(BaseFragmentActivityApi16.java:54)
                    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:68)
                    at android.app.Activity.startActivityForResult(Activity.java:4183)
                    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:751)
                    at android.app.Activity.startActivity(Activity.java:4522)
                    at android.app.Activity.startActivity(Activity.java:4490)
                    at com.example.khortsuming.hello_from_csharp.MainActivity.onResume(MainActivity.java:21)
                    at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1269)
                    at android.app.Activity.performResume(Activity.java:6783)
                    at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3406)

I googled for the error and it says there should be a [Activity] attributes in Xamarin C#

        [Activity(Label = "HelloActivity"),
            Register("hello_from_csharp.HelloActivity")]
        public class HelloActivity : Activity
        {
            protected override void OnCreate(Bundle savedInstanceState)
            {
                base.OnCreate(savedInstanceState);

                SetContentView(Resource.Layout.hello);
            }
        }

The codes provided in the tutorial contains the Activity label.
Please help, thanks

Tagged:
Sign In or Register to comment.