我不能从一个jar文件调用活动 [英] I can´t call an activity from a jar file

查看:198
本文介绍了我不能从一个jar文件调用活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的场景:我有了一个jar文件(即提供了一些信息,以主要的一个辅助项目)主要项目。我创建的JAR文件跟随着这个政党成员和然后将jar文件添加到/库主体工程,然后将其添加在构建路径。

I have this scenario: I have a main project that has a jar file (a secondary project that gives some info to the main one). I created the jar file followin this tuto and then add the jar file to the main project in /libs and then add it in the Build Path.

在我所说的活动从jar文件中有一个致命异常

When I call the activity from the jar file there is a Fatal Exception

这是logcat的

03-22 12:47:09.509: D/AndroidRuntime(13341): Shutting down VM
03-22 12:47:09.509: W/dalvikvm(13341): threadid=1: thread exiting with uncaught exception (group=0x40018578)
03-22 12:47:09.529: E/AndroidRuntime(13341): FATAL EXCEPTION: main
03-22 12:47:09.529: E/AndroidRuntime(13341): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.XXX.YYY/com.XXX.YYY.Subscription}; have you declared this activity in your AndroidManifest.xml?
03-22 12:47:09.529: E/AndroidRuntime(13341):    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405)
03-22 12:47:09.529: E/AndroidRuntime(13341):    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
03-22 12:47:09.529: E/AndroidRuntime(13341):    at android.app.Activity.startActivityForResult(Activity.java:2827)
03-22 12:47:09.529: E/AndroidRuntime(13341):    at com.example.principal.Principal$1.onClick(Principal.java:40)
03-22 12:47:09.529: E/AndroidRuntime(13341):    at android.view.View.performClick(View.java:2485)
03-22 12:47:09.529: E/AndroidRuntime(13341):    at android.view.View$PerformClick.run(View.java:9080)
03-22 12:47:09.529: E/AndroidRuntime(13341):    at android.os.Handler.handleCallback(Handler.java:587)
03-22 12:47:09.529: E/AndroidRuntime(13341):    at android.os.Handler.dispatchMessage(Handler.java:92)
03-22 12:47:09.529: E/AndroidRuntime(13341):    at android.os.Looper.loop(Looper.java:130)
03-22 12:47:09.529: E/AndroidRuntime(13341):    at android.app.ActivityThread.main(ActivityThread.java:3687)
03-22 12:47:09.529: E/AndroidRuntime(13341):    at java.lang.reflect.Method.invokeNative(Native Method)
03-22 12:47:09.529: E/AndroidRuntime(13341):    at java.lang.reflect.Method.invoke(Method.java:507)
03-22 12:47:09.529: E/AndroidRuntime(13341):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
03-22 12:47:09.529: E/AndroidRuntime(13341):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
03-22 12:47:09.529: E/AndroidRuntime(13341):    at dalvik.system.NativeStart.main(Native Method)

这是我如何调用在主项目活动

This is how I call the activity in the main project

final Intent intent = new Intent();

        Button juego1Btn = (Button) findViewById(R.id.juego1Btn);

        juego1Btn.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                /*Intent intent = new Intent(getBaseContext(), Subscription.class);
                startActivity(intent);*/
                intent.setAction(Intent.ACTION_MAIN);
                intent.setClassName("com.XXX.YYY", "com.XXX.YYY.Subscription");
                intent.putExtra("code", codigo);
                intent.putExtra("keyword", keyword);
                startActivityForResult(intent, 1);
            }
        });

和,这是明显的

<activity
            android:name="com.XXX.YYY.Subscription"
            android:label="@string/app_name">
</activity>

为什么我有一个例外?任何想法

Any idea about why I have that Exception??

非常感谢你!

推荐答案

问题是我创建的库的方式,通过下面一步该政党成员一步,它工作正常的 http://es.slideshare.net/ajdgeniz/como-hacer-un-archivo-jar-en-eclipse

The problem was in the way I created the library, via following this tuto step by step it works fine http://es.slideshare.net/ajdgeniz/como-hacer-un-archivo-jar-en-eclipse

谢谢大家。

这篇关于我不能从一个jar文件调用活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆