我有一个lib.apk,由服务器发送并由我的应用程序接收,然后保存在sdcard.now我想在我的库中运行活动,但是当我尝试这样做时,它给我错误你定义活动吗?表现。我在我的lib的清单中添加了活动标签,但它仍然无效。任何人都可以提出任何想法吗?
我的lib的清单文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.lib"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.lib.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
</application>
</manifest>
logcat错误
11-20 05:16:49.918: W/System.err(6721): java.lang.reflect.InvocationTargetException
11-20 05:16:49.938: W/System.err(6721): at java.lang.reflect.Method.invokeNative(Native Method)
11-20 05:16:49.948: W/System.err(6721): at java.lang.reflect.Method.invoke(Method.java:511)
11-20 05:16:49.948: W/System.err(6721): at com.example.myapp2.MainActivity.onCreate(MainActivity.java:29)
11-20 05:16:49.948: W/System.err(6721): at android.app.Activity.performCreate(Activity.java:5104)
11-20 05:16:49.948: W/System.err(6721): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
11-20 05:16:49.948: W/System.err(6721): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
11-20 05:16:49.958: W/System.err(6721): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
11-20 05:16:49.958: W/System.err(6721): at android.app.ActivityThread.access$600(ActivityThread.java:141)
11-20 05:16:49.958: W/System.err(6721): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
11-20 05:16:49.958: W/System.err(6721): at android.os.Handler.dispatchMessage(Handler.java:99)
11-20 05:16:49.969: W/System.err(6721): at android.os.Looper.loop(Looper.java:137)
11-20 05:16:49.969: W/System.err(6721): at android.app.ActivityThread.main(ActivityThread.java:5041)
11-20 05:16:49.969: W/System.err(6721): at java.lang.reflect.Method.invokeNative(Native Method)
11-20 05:16:49.969: W/System.err(6721): at java.lang.reflect.Method.invoke(Method.java:511)
11-20 05:16:49.969: W/System.err(6721): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
11-20 05:16:49.978: W/System.err(6721): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
11-20 05:16:49.978: W/System.err(6721): at dalvik.system.NativeStart.main(Native Method)
11-20 05:16:49.978: W/System.err(6721): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.myapp2/com.example.lib.MainActivity}; have you declared this activity in your AndroidManifest.xml?
11-20 05:16:49.988: W/System.err(6721): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1618)
11-20 05:16:50.000: W/System.err(6721): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
11-20 05:16:50.008: W/System.err(6721): at android.app.Activity.startActivityForResult(Activity.java:3370)
11-20 05:16:50.008: W/System.err(6721): at android.app.Activity.startActivityForResult(Activity.java:3331)
11-20 05:16:50.008: W/System.err(6721): at android.app.Activity.startActivity(Activity.java:3566)
11-20 05:16:50.019: W/System.err(6721): at android.app.Activity.startActivity(Activity.java:3534)
11-20 05:16:50.028: W/System.err(6721): at com.example.lib.Main.onCreate(Main.java:32)
答案 0 :(得分:1)
您无法运行手机上尚未安装的活动。只在SD卡上安装APK是不够的。此APK需要安装在设备上。