Reputation: 23
Good day!
I have a JAR file with a MainActivity on it. I've created a new Android Application for testing the Intent code. Below is my code for the button.
public void doSomething(View v) {
Intent i = new Intent(this, com.testing1234.apptest.MainActivity.class);
startActivity(i);
}
the com.testing1234.apptest is my JAR file. When I try to run this, the first form with a button shows up. After clicking the button to run the JAR file, the application terminates.
On the logcat it displays an error "Could not find class 'com.testing1234.apptest.MainActivity'"
Or its not impossible? I did make sure that I included the JAR file in my project. Please help me. Feel free to provide me with some helpful tips on this. Thanks.
Edit:
I tried it with another JAR file and below is my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.wodota.test123"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.viva.demo.MainActivity" />
</application>
</manifest>
Edit 2: Logcat
08-19 19:17:30.940: D/dalvikvm(26519): VFY: replacing opcode 0x1c at 0x0002
08-19 19:17:30.950: D/dalvikvm(2614): GC_EXPLICIT freed <1K, 27% free 6422K/8771K, paused 0ms+0ms
08-19 19:17:30.950: D/dalvikvm(2614): GC_EXPLICIT freed <1K, 27% free 6422K/8771K, paused 0ms+0ms
08-19 19:17:30.960: W/InputManagerService(2624): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@b32849d0 (uid=1000 pid=26271)
08-19 19:17:30.970: I/PGA(26519): New SOCKET connection: .wodota.test123 (pid 26519, tid 26519)
08-19 19:17:30.980: I/ActivityManager(2624): Displayed com.wodota.test123/.MainActivity: +80ms
08-19 19:17:33.660: E/InputDispatcher(2624): Motion event has invalid pointer count 0; value must be between 1 and 16.
08-19 19:17:33.730: E/InputDispatcher(2624): Motion event has invalid pointer count 0; value must be between 1 and 16.
08-19 19:17:33.730: D/AndroidRuntime(26519): Shutting down VM
08-19 19:17:33.730: W/dalvikvm(26519): threadid=1: thread exiting with uncaught exception (group=0xb2c63180)
08-19 19:17:33.730: D/BstCommandProcessor-Application(2806): Application crash has been observed.
08-19 19:17:33.730: I/Process(26519): Sending signal. PID: 26519 SIG: 9
08-19 19:17:33.730: D/AndroidRuntime(26519): procName from cmdline: com.wodota.test123
08-19 19:17:33.730: E/AndroidRuntime(26519): in writeCrashedAppName, pkgName :com.wodota.test123
08-19 19:17:33.730: D/AndroidRuntime(26519): file written successfully with content: com.wodota.test123 StringBuffer : ;com.wodota.test123
08-19 19:17:33.730: E/AndroidRuntime(26519): FATAL EXCEPTION: main
08-19 19:17:33.730: E/AndroidRuntime(26519): java.lang.IllegalStateException: Could not execute method of the activity
08-19 19:17:33.730: E/AndroidRuntime(26519): at android.view.View$1.onClick(View.java:3044)
08-19 19:17:33.730: E/AndroidRuntime(26519): at android.view.View.performClick(View.java:3511)
08-19 19:17:33.730: E/AndroidRuntime(26519): at android.view.View$PerformClick.run(View.java:14105)
08-19 19:17:33.730: E/AndroidRuntime(26519): at android.os.Handler.handleCallback(Handler.java:605)
08-19 19:17:33.730: E/AndroidRuntime(26519): at android.os.Handler.dispatchMessage(Handler.java:92)
08-19 19:17:33.730: E/AndroidRuntime(26519): at android.os.Looper.loop(Looper.java:137)
08-19 19:17:33.730: E/AndroidRuntime(26519): at android.app.ActivityThread.main(ActivityThread.java:4424)
08-19 19:17:33.730: E/AndroidRuntime(26519): at java.lang.reflect.Method.invokeNative(Native Method)
08-19 19:17:33.730: E/AndroidRuntime(26519): at java.lang.reflect.Method.invoke(Method.java:511)
08-19 19:17:33.730: E/AndroidRuntime(26519): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:825)
08-19 19:17:33.730: E/AndroidRuntime(26519): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:592)
08-19 19:17:33.730: E/AndroidRuntime(26519): at dalvik.system.NativeStart.main(Native Method)
08-19 19:17:33.730: E/AndroidRuntime(26519): Caused by: java.lang.reflect.InvocationTargetException
08-19 19:17:33.730: E/AndroidRuntime(26519): at java.lang.reflect.Method.invokeNative(Native Method)
08-19 19:17:33.730: E/AndroidRuntime(26519): at java.lang.reflect.Method.invoke(Method.java:511)
08-19 19:17:33.730: E/AndroidRuntime(26519): at android.view.View$1.onClick(View.java:3039)
08-19 19:17:33.730: E/AndroidRuntime(26519): ... 11 more
08-19 19:17:33.730: E/AndroidRuntime(26519): Caused by: java.lang.NoClassDefFoundError: com.viva.demo.MainActivity
08-19 19:17:33.730: E/AndroidRuntime(26519): at com.wodota.test123.MainActivity.doSomething(MainActivity.java:26)
08-19 19:17:33.730: E/AndroidRuntime(26519): ... 14 more
08-19 19:17:33.740: I/WindowManager(2624): WIN DEATH: Window{b341f500 com.wodota.test123/com.wodota.test123.MainActivity paused=false}
08-19 19:17:33.740: I/ActivityManager(2624): Process com.wodota.test123 (pid 26519) has died.
08-19 19:17:33.740: W/ActivityManager(2624): Force removing ActivityRecord{b30ace88 com.wodota.test123/.MainActivity}: app died, no saved state
08-19 19:17:33.740: D/ActivityManager(2624): TopActivityInfo, pkgName: com.android.settings activityName: com.android.settings/.Settings bstSpecialAppKeyboardHandlingEnabled = false
08-19 19:17:33.740: D/ActivityManager(2624): Showing guidance for pkgName: com.android.settings
08-19 19:17:33.750: V/AudioHardware(515): open playback normal
08-19 19:17:33.750: V/AudioHardware(515): write() wakeup setting route SPK
08-19 19:17:33.750: D/GuidanceScreen(2777): hiding guidance
08-19 19:17:33.750: D/GuidanceScreen(2777): event === app_launch
08-19 19:17:33.750: D/GuidanceScreen(2777): hardKeyboard = 1
08-19 19:17:33.750: D/GuidanceScreen(2777): controllerType === DualAction
08-19 19:17:33.750: D/GuidanceScreen(2777): appName: Settings, currentPkg: com.android.settings, event: app_launch, controller: DualAction
08-19 19:17:33.750: D/GuidanceScreen(2777): appName: Settings
08-19 19:17:33.750: D/GuidanceScreen(2777): no guidance for com.android.settings.
08-19 19:17:33.770: I/ManageApplications(26271): onCreateOptionsMenu in ManageApplications{b3502558 #1 id=0x10202d4}: com.android.internal.view.menu.MenuBuilder@b3549888
08-19 19:17:33.780: D/VoldCmdListener(507): asec fspath air.com.playtika.slotomania-2
08-19 19:17:33.780: W/InputManagerService(2624): Got RemoteException sending setActive(false) notification to pid 26519 uid 10055
08-19 19:17:33.790: D/VoldCmdListener(507): asec fspath com.igg.bzbee.slotsdeluxe-2
08-19 19:17:33.790: D/VoldCmdListener(507): asec fspath com.kingsky.moto3dAndroid-1
08-19 19:17:36.770: D/AudioHardware(515): AudioHardware pcm playback is going to standby.
08-19 19:17:42.290: W/ActivityManager(2624): Activity destroy timeout for ActivityRecord{b319b598 com.android.packageinstaller/.UninstallAppProgress}
08-19 19:17:43.860: I/ActivityManager(2624): No longer want com.google.android.partnersetup (pid 26421): hidden #9
08-19 19:17:45.640: D/Finsky(26435): [1] 5.onFinished: Installation state replication succeeded.
08-19 19:18:20.210: D/dalvikvm(3343): GC_CONCURRENT freed 1914K, 40% free 6446K/10691K, paused 0ms+0ms
Upvotes: 0
Views: 1636
Reputation: 2288
You need to Add the Activity to the Manifest. Every Activity you want to run must be added to the Manifest.
add this :
<activity android:name="com.testing1234.apptest.MainActivity" />
Upvotes: 2