I am working on a project which has two modules , server and client.
Server will be running on OTT devices (Android based) as an background service and will be responsible to actuate/inject keyevents and client will be sending keyevents over wifi.
Now i am able to control single application which includes the Server service or I can say that i am able to control all those app which I have developed (using broadcast receiver , Instrumentation...etc).
Now i have to control other apps also , I mean I have to send the keyevents on global level
I have gone through several tutorials but still stuck at this.
Last thing which i need to try is to inject key events at low level using JNI but i am alien to JNI and low level linux subsystem !!
is there any other workaround ? any lead would be helpful
Thanks :D
these are my logcat values :-
03-25 16:12:06.422: E/Key Value(7679): 343
03-25 16:12:06.752: E/JavaBinder(8556): Unknown binder error code. 0xfffffff7
03-25 16:12:06.752: E/ServiceManager(8556): error in getService
03-25 16:12:06.752: E/ServiceManager(8556): android.os.RemoteException: Unknown binder error code. 0xfffffff7
03-25 16:12:06.752: E/ServiceManager(8556): at android.os.BinderProxy.transact(Native Method)
03-25 16:12:06.752: E/ServiceManager(8556): at android.os.ServiceManagerProxy.getService(ServiceManagerNative.java:123)
03-25 16:12:06.752: E/ServiceManager(8556): at android.os.ServiceManager.getService(ServiceManager.java:55)
03-25 16:12:06.752: E/ServiceManager(8556): at android.app.ActivityManagerNative$1.create(ActivityManagerNative.java:1832)
03-25 16:12:06.752: E/ServiceManager(8556): at android.app.ActivityManagerNative$1.create(ActivityManagerNative.java:1830)
03-25 16:12:06.752: E/ServiceManager(8556): at android.util.Singleton.get(Singleton.java:34)
03-25 16:12:06.752: E/ServiceManager(8556): at android.app.ActivityManagerNative.getDefault(ActivityManagerNative.java:74)
03-25 16:12:06.752: E/ServiceManager(8556): at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:76)
03-25 16:12:06.752: E/ServiceManager(8556): at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
03-25 16:12:06.752: E/ServiceManager(8556): at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
03-25 16:12:06.752: E/ServiceManager(8556): at dalvik.system.NativeStart.main(Native Method)
03-25 16:12:06.752: E/AndroidRuntime(8556): *** FATAL EXCEPTION IN SYSTEM PROCESS: main
03-25 16:12:06.752: E/AndroidRuntime(8556): java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission
03-25 16:12:06.752: E/AndroidRuntime(8556): at android.os.Parcel.readException(Parcel.java:1425)
03-25 16:12:06.752: E/AndroidRuntime(8556): at android.os.Parcel.readException(Parcel.java:1379)
03-25 16:12:06.752: E/AndroidRuntime(8556): at android.hardware.input.IInputManager$Stub$Proxy.injectInputEvent(IInputManager.java:356)
03-25 16:12:06.752: E/AndroidRuntime(8556): at android.hardware.input.InputManager.injectInputEvent(InputManager.java:619)
03-25 16:12:06.752: E/AndroidRuntime(8556): at com.android.commands.input.Input.injectKeyEvent(Input.java:201)
03-25 16:12:06.752: E/AndroidRuntime(8556): at com.android.commands.input.Input.sendKeyEvent(Input.java:163)
03-25 16:12:06.752: E/AndroidRuntime(8556): at com.android.commands.input.Input.run(Input.java:64)
03-25 16:12:06.752: E/AndroidRuntime(8556): at com.android.commands.input.Input.main(Input.java:41)
03-25 16:12:06.752: E/AndroidRuntime(8556): at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
03-25 16:12:06.752: E/AndroidRuntime(8556): at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:235)
03-25 16:12:06.752: E/AndroidRuntime(8556): at dalvik.system.NativeStart.main(Native Method)
03-25 16:12:06.762: E/AndroidRuntime(8556): Error reporting crash
03-25 16:12:06.762: E/AndroidRuntime(8556): java.lang.NullPointerException
03-25 16:12:06.762: E/AndroidRuntime(8556): at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:76)
03-25 16:12:06.762: E/AndroidRuntime(8556): at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
03-25 16:12:06.762: E/AndroidRuntime(8556): at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
03-25 16:12:06.762: E/AndroidRuntime(8556): at dalvik.system.NativeStart.main(Native Method)
Related
I have a wishlist in menu.xml. I click on wishlist menu item and the activity is opened but when click the back arrow in the top. I am getting the following error:
03-25 01:13:28.278: E/NavUtils(15464): getParentActivityIntent: bad parentActivityName 'com.ylg.link.Ylg_GridViewActivity' in manifest
03-25 01:13:28.278: D/AndroidRuntime(15464): Shutting down VM
03-25 01:13:28.278: W/dalvikvm(15464): threadid=1: thread exiting with uncaught exception (group=0x417c3700)
03-25 01:13:28.286: E/AndroidRuntime(15464): FATAL EXCEPTION: main
03-25 01:13:28.286: E/AndroidRuntime(15464): java.lang.IllegalArgumentException: Activity Ylg_Wishlist does not have a parent activity name specified. (Did you forget to add the android.support.PARENT_ACTIVITY <meta-data> element in your manifest?)
03-25 01:13:28.286: E/AndroidRuntime(15464): at android.support.v4.app.NavUtils.navigateUpFromSameTask(NavUtils.java:178)
03-25 01:13:28.286: E/AndroidRuntime(15464): at com.ylg.link.Ylg_Wishlist.onOptionsItemSelected(YLG_Wishlist.java:47)
03-25 01:13:28.286: E/AndroidRuntime(15464): at android.app.Activity.onMenuItemSelected(Activity.java:2566)
03-25 01:13:28.286: E/AndroidRuntime(15464): at com.android.internal.widget.ActionBarView$3.onClick(ActionBarView.java:171)
03-25 01:13:28.286: E/AndroidRuntime(15464): at android.view.View.performClick(View.java:4240)
03-25 01:13:28.286: E/AndroidRuntime(15464): at android.view.View$PerformClick.run(View.java:17721)
03-25 01:13:28.286: E/AndroidRuntime(15464): at android.os.Handler.handleCallback(Handler.java:730)
03-25 01:13:28.286: E/AndroidRuntime(15464): at android.os.Handler.dispatchMessage(Handler.java:92)
03-25 01:13:28.286: E/AndroidRuntime(15464): at android.os.Looper.loop(Looper.java:137)
03-25 01:13:28.286: E/AndroidRuntime(15464): at android.app.ActivityThread.main(ActivityThread.java:5103)
03-25 01:13:28.286: E/AndroidRuntime(15464): at java.lang.reflect.Method.invokeNative(Native Method)
03-25 01:13:28.286: E/AndroidRuntime(15464): at java.lang.reflect.Method.invoke(Method.java:525)
03-25 01:13:28.286: E/AndroidRuntime(15464): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
03-25 01:13:28.286: E/AndroidRuntime(15464): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
03-25 01:13:28.286: E/AndroidRuntime(15464): at dalvik.system.NativeStart.main(Native Method)
Please not that Parent_Acitivty is a fragment. And I have the below intent in the FragmentActivity
Intent intent = new Intent(this, Ylg_Wishlist.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
When I click on the back top button it should direct me to fragment but instead i am getting the above error.
Here is the manifest I am declaring:
<activity
android:name="com.ylg.link.Ylg_Wishlist"
android:label="#string/wishlist"
android:screenOrientation="portrait" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.ylg.link.Ylg_GridViewActivity" />
</activity>
Can somebody help me fix this? How do I call the back button to call the fragment rather an activity?
Thanks!
Make sure that com.ylg.link.Ylg_GridViewActivity is an activity and not a fragment, you can only specify Activities in the android.support.PARENT_ACTIVITY meta data.
Also, I find it a bit odd that the name is com.ylg.link.Ylg_GridViewActivity in the manifest and com.ylg.link.ylg_GridViewActivity in the stack trace (different case for the letter 'Y' in ylg_GridViewActivity). It could also be related to your problem.
i set values and inserted to database but i got the following errors in logcat.why
03-25 17:41:23.802: E/SQLiteDatabase(10095): Error inserting devicename=iname alarm=ON uuid=00000000-5f53-54ae-5f53-54ae00000000 light=ON
03-25 17:41:23.802: E/SQLiteDatabase(10095): android.database.sqlite.SQLiteConstraintException: column uuid is not unique (code 19)
03-25 17:41:23.802: E/SQLiteDatabase(10095): at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
03-25 17:41:23.802: E/SQLiteDatabase(10095): at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:782)
03-25 17:41:23.802: E/SQLiteDatabase(10095): at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788)
03-25 17:41:23.802: E/SQLiteDatabase(10095): at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
03-25 17:41:23.802: E/SQLiteDatabase(10095): at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1469)
03-25 17:41:23.802: E/SQLiteDatabase(10095): at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1339)
03-25 17:41:23.802: E/SQLiteDatabase(10095): at com.iname.bpowerbank.DataBaseAdapter.insertData(DataBaseAdapter.java:97)
03-25 17:41:23.802: E/SQLiteDatabase(10095): at com.iname.bpowerbank.EditPreview.onCreate(EditPreview.java:68)
03-25 17:41:23.802: E/SQLiteDatabase(10095): at android.app.Activity.performCreate(Activity.java:5231)
03-25 17:41:23.802: E/SQLiteDatabase(10095): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
03-25 17:41:23.802: E/SQLiteDatabase(10095): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
03-25 17:41:23.802: E/SQLiteDatabase(10095): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
03-25 17:41:23.802: E/SQLiteDatabase(10095): at android.app.ActivityThread.access$800(ActivityThread.java:135)
03-25 17:41:23.802: E/SQLiteDatabase(10095): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
03-25 17:41:23.802: E/SQLiteDatabase(10095): at android.os.Handler.dispatchMessage(Handler.java:102)
03-25 17:41:23.802: E/SQLiteDatabase(10095): at android.os.Looper.loop(Looper.java:136)
03-25 17:41:23.802: E/SQLiteDatabase(10095): at android.app.ActivityThread.main(ActivityThread.java:5017)
03-25 17:41:23.802: E/SQLiteDatabase(10095): at java.lang.reflect.Method.invokeNative(Native Method)
03-25 17:41:23.802: E/SQLiteDatabase(10095): at java.lang.reflect.Method.invoke(Method.java:515)
03-25 17:41:23.802: E/SQLiteDatabase(10095): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-25 17:41:23.802: E/SQLiteDatabase(10095): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-25 17:41:23.802: E/SQLiteDatabase(10095): at dalvik.system.NativeStart.main(Native Method)
You violated a constraint on your uuid column. It must be unique. Insert always unique values.
Check this post to see sqlite error descriptions
Yours is #19.
There are two possible fixes,
1. Remove UNIQUE or PRIMARY KEY property for the column "uuid"
or
2. use INSERT OR REPLACE INTO table_name (UUID,name) VALUES ('uuid_value','name_value')
Android newbie here trying to use my favorite Java testing tools in Android. I am attempting to use Mockito 1.9.5 as outlined in the following blog post but cannot get the tests to run on my emulator (I currently do not have a physical device to test with either).
Mockit-Android Tutorial: http://www.paulbutcher.com/2012/05/mockito-on-android-step-by-step/
I am able to execute all my normal Junit tests without issue however any of the tests I have leveraged Mockito for I receive the following:
Can't open dex cache '/data/dalvik-cache/data#data#com.trendium.peg#cache#Generated-621101.jar#classes.dex': No such file or directory
Unable to open or create cache for /data/data/com.trendium.peg/cache/Generated-621101.jar (/data/dalvik-cache/data#data#com.trendium.peg#cache#Generated-621101.jar#classes.dex)
failed: testStartable(com.trendium.peg.services.RatingServiceTest)
java.lang.AssertionError: java.lang.ClassNotFoundException: RemoteRestTask_Proxy in loader dalvik.system.DexClassLoader#40a4b610
I've done a great deal of Googling these exceptions, rebuilt my emulator, rebuilt projects, and a number of other various ideas but haven't had any luck in resolving this.
Side note: I am targeting SDK 11 and up, doubt this has impact but worth noting. My existing unit tests that do not leverage Mockito run without issue in same test run (28/28 ran, 7 failures).
Further analysis of the LogCat reveals a mockito cglib is evidently not on the classpath, however I am unsure of the next step at this moment:
03-25 09:10:42.990: W/dalvikvm(411): Unable to resolve superclass of Lorg/mockito/cglib/transform/AbstractProcessTask; (637)
03-25 09:10:43.000: W/dalvikvm(411): Link of class 'Lorg/mockito/cglib/transform/AbstractProcessTask;' failed
03-25 09:10:43.029: D/dalvikvm(411): GC_CONCURRENT freed 618K, 9% free 9226K/10055K, paused 4ms+6ms
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): Cannot load class. Make sure it is in your apk. Class name: 'org.mockito.cglib.transform.AbstractProcessTask'. Message: org.mockito.cglib.transform.AbstractProcessTask
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): java.lang.ClassNotFoundException: org.mockito.cglib.transform.AbstractProcessTask
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at java.lang.Class.classForName(Native Method)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at java.lang.Class.forName(Class.java:234)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at android.test.ClassPathPackageInfoSource.createPackageInfo(ClassPathPackageInfoSource.java:89)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at android.test.ClassPathPackageInfoSource.access$000(ClassPathPackageInfoSource.java:40)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:51)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:48)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at android.test.SimpleCache.get(SimpleCache.java:31)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at android.test.ClassPathPackageInfoSource.getPackageInfo(ClassPathPackageInfoSource.java:73)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at android.test.ClassPathPackageInfo.getSubpackages(ClassPathPackageInfo.java:48)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at android.test.ClassPathPackageInfo.addTopLevelClassesTo(ClassPathPackageInfo.java:61)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at android.test.ClassPathPackageInfo.getTopLevelClassesRecursive(ClassPathPackageInfo.java:55)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at android.test.suitebuilder.TestGrouping.testCaseClassesInPackage(TestGrouping.java:156)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at android.test.suitebuilder.TestGrouping.addPackagesRecursive(TestGrouping.java:117)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at android.test.suitebuilder.TestSuiteBuilder.includePackages(TestSuiteBuilder.java:102)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:356)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3550)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at android.app.ActivityThread.access$2200(ActivityThread.java:123)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1031)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at android.os.Handler.dispatchMessage(Handler.java:99)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at android.os.Looper.loop(Looper.java:126)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at android.app.ActivityThread.main(ActivityThread.java:3997)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at java.lang.reflect.Method.invokeNative(Native Method)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at java.lang.reflect.Method.invoke(Method.java:491)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at dalvik.system.NativeStart.main(Native Method)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): Caused by: java.lang.NoClassDefFoundError: org.mockito.cglib.transform.AbstractProcessTask
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): ... 26 more
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): Caused by: java.lang.ClassNotFoundException: org.mockito.cglib.transform.AbstractProcessTask in loader dalvik.system.PathClassLoader[/system/framework/android.test.runner.jar:/data/app/com.example.mine.test-1.apk:/data/app/com.example.mine-1.apk]
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:251)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at java.lang.ClassLoader.loadClass(ClassLoader.java:548)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): at java.lang.ClassLoader.loadClass(ClassLoader.java:508)
03-25 09:10:43.040: W/ClassPathPackageInfoSource(411): ... 26 more
Based on this error message I look at the Mockito source and note that it is using Ant's Task. However, I don't see Ant as a dependency of Mockito...
https://fisheye2.atlassian.com/browse/mockito/trunk/cglib-and-asm/src/org/mockito/cglib/transform/AbstractProcessTask.java?r=1430
Further debugging and I am blocked again with the following:
03-25 15:07:01.726: I/dalvikvm(703): Failed resolving Lorg/junit/internal/AssumptionViolatedException; interface 693 'Lorg/hamcrest/SelfDescribing;'
03-25 15:07:01.726: W/dalvikvm(703): Link of class 'Lorg/junit/internal/AssumptionViolatedException;' failed
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): Cannot load class. Make sure it is in your apk. Class name: 'org.junit.internal.AssumptionViolatedException'. Message: org.junit.internal.AssumptionViolatedException
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): java.lang.ClassNotFoundException: org.junit.internal.AssumptionViolatedException
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): at java.lang.Class.classForName(Native Method)
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): at java.lang.Class.forName(Class.java:234)
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): at android.test.ClassPathPackageInfoSource.createPackageInfo(ClassPathPackageInfoSource.java:89)
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): at android.test.ClassPathPackageInfoSource.access$000(ClassPathPackageInfoSource.java:40)
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:51)
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:48)
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): at android.test.SimpleCache.get(SimpleCache.java:31)
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): at android.test.ClassPathPackageInfoSource.getPackageInfo(ClassPathPackageInfoSource.java:73)
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): at android.test.ClassPathPackageInfo.getSubpackages(ClassPathPackageInfo.java:48)
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): at android.test.ClassPathPackageInfo.addTopLevelClassesTo(ClassPathPackageInfo.java:61)
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): at android.test.ClassPathPackageInfo.getTopLevelClassesRecursive(ClassPathPackageInfo.java:55)
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): at android.test.suitebuilder.TestGrouping.testCaseClassesInPackage(TestGrouping.java:156)
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): at android.test.suitebuilder.TestGrouping.addPackagesRecursive(TestGrouping.java:117)
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): at android.test.suitebuilder.TestSuiteBuilder.includePackages(TestSuiteBuilder.java:102)
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:356)
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3550)
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): at android.app.ActivityThread.access$2200(ActivityThread.java:123)
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1031)
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): at android.os.Handler.dispatchMessage(Handler.java:99)
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): at android.os.Looper.loop(Looper.java:126)
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): at android.app.ActivityThread.main(ActivityThread.java:3997)
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): at java.lang.reflect.Method.invokeNative(Native Method)
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): at java.lang.reflect.Method.invoke(Method.java:491)
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): at dalvik.system.NativeStart.main(Native Method)
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): Caused by: java.lang.NoClassDefFoundError: org.junit.internal.AssumptionViolatedException
03-25 15:07:01.746: W/ClassPathPackageInfoSource(703): ... 26 more
This would indicate that the hamcrst-core jar is not on the classpath, however I have properly added it the the test-project's libs directory:
https://github.com/junit-team/junit/blob/r4.11/src/main/java/org/junit/internal/AssumptionViolatedException.java
Please note that I am using the correct (from my understanding) jars for Junit-4.11 in regards to Mockito 1.9.5.
https://code.google.com/p/mockito/wiki/DeclaringMockitoDependency
You have to make sure th Mockito's JAR is part of you APK dependencies.
If you are using Intellij, open project settings, and Module->Dependencies, and add Mockito as part of dependency.
If you are using obfuscation, you also have to make sure its not obfuscating mockito's class from your built apk.
I had the same issues while I'm calling a native API without the mocking them -- make sure you have a mock of the native calls.
Check also the linkage error and not only the Mockito exception.
This issue may be caused by not having the libraries on your actual android device, even though you may have added them to Eclipse or Android Studio.
In my android test project I was able to fix this problem by creating a libs folder and putting the three required libraries in it. Be sure the name of your created folder is actually "libs" and NOT "lib"
Here's a link from the android developer site with more detailed directions for adding support libraries.
http://developer.android.com/tools/support-library/setup.html
I have been trying to add a map to my application, I have followed instructions on the android developers HelloGoogleMaps tutorial but my map is just force closing when I run the maps option. I have obtained my api key logged permissions in manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.MappDemo.mymaps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" android:debuggable="true" >
<activity
android:name=".MappingDemoActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<uses-library android:name="com.google.android.maps" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ShowTheMap" android:label="Lat/Long Location"> </activity>
<activity android:name=".MapMe" android:label="Track Present Location"> </activity>
<uses-library android:name="com.google.android.maps" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
</application>
</manifest>
Can some one tell if any thing needs to be configured in addition to run the code?
03-25 11:50:52.217: I/Process(687): Sending signal. PID: 687 SIG: 9
03-25 11:51:00.557: D/AndroidRuntime(729): Shutting down VM
03-25 11:51:00.567: W/dalvikvm(729): threadid=1: thread exiting with uncaught exception (group=0x40015560)
03-25 11:51:00.627: E/AndroidRuntime(729): FATAL EXCEPTION: main
03-25 11:51:00.627: E/AndroidRuntime(729): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.MappDemo.mymaps/com.MappDemo.mymaps.MappingDemoActivity}: java.lang.ClassCastException: com.MappDemo.mymaps.MappingDemoActivity
03-25 11:51:00.627: E/AndroidRuntime(729): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
03-25 11:51:00.627: E/AndroidRuntime(729): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
03-25 11:51:00.627: E/AndroidRuntime(729): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-25 11:51:00.627: E/AndroidRuntime(729): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
03-25 11:51:00.627: E/AndroidRuntime(729): at android.os.Handler.dispatchMessage(Handler.java:99)
03-25 11:51:00.627: E/AndroidRuntime(729): at android.os.Looper.loop(Looper.java:123)
03-25 11:51:00.627: E/AndroidRuntime(729): at android.app.ActivityThread.main(ActivityThread.java:3683)
03-25 11:51:00.627: E/AndroidRuntime(729): at java.lang.reflect.Method.invokeNative(Native Method)
03-25 11:51:00.627: E/AndroidRuntime(729): at java.lang.reflect.Method.invoke(Method.java:507)
03-25 11:51:00.627: E/AndroidRuntime(729): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-25 11:51:00.627: E/AndroidRuntime(729): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-25 11:51:00.627: E/AndroidRuntime(729): at dalvik.system.NativeStart.main(Native Method)
03-25 11:51:00.627: E/AndroidRuntime(729): Caused by: java.lang.ClassCastException: com.MappDemo.mymaps.MappingDemoActivity
03-25 11:51:00.627: E/AndroidRuntime(729): at com.MappDemo.mymaps.MappingDemoActivity.onCreate(MappingDemoActivity.java:19)
03-25 11:51:00.627: E/AndroidRuntime(729): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-25 11:51:00.627: E/AndroidRuntime(729): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
03-25 11:51:00.627: E/AndroidRuntime(729): ... 11 more
03-25 11:51:10.013: I/Process(729): Sending signal. PID: 729 SIG: 9
03-25 11:52:16.817: D/AndroidRuntime(782): Shutting down VM
03-25 11:52:16.817: W/dalvikvm(782): threadid=1: thread exiting with uncaught exception (group=0x40015560)
03-25 11:52:16.877: E/AndroidRuntime(782): FATAL EXCEPTION: main
03-25 11:52:16.877: E/AndroidRuntime(782): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.MappDemo.mymaps/com.MappDemo.mymaps.MappingDemoActivity}: java.lang.ClassCastException: com.MappDemo.mymaps.MappingDemoActivity
03-25 11:52:16.877: E/AndroidRuntime(782): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
03-25 11:52:16.877: E/AndroidRuntime(782): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
03-25 11:52:16.877: E/AndroidRuntime(782): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-25 11:52:16.877: E/AndroidRuntime(782): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
03-25 11:52:16.877: E/AndroidRuntime(782): at android.os.Handler.dispatchMessage(Handler.java:99)
03-25 11:52:16.877: E/AndroidRuntime(782): at android.os.Looper.loop(Looper.java:123)
03-25 11:52:16.877: E/AndroidRuntime(782): at android.app.ActivityThread.main(ActivityThread.java:3683)
03-25 11:52:16.877: E/AndroidRuntime(782): at java.lang.reflect.Method.invokeNative(Native Method)
03-25 11:52:16.877: E/AndroidRuntime(782): at java.lang.reflect.Method.invoke(Method.java:507)
03-25 11:52:16.877: E/AndroidRuntime(782): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-25 11:52:16.877: E/AndroidRuntime(782): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-25 11:52:16.877: E/AndroidRuntime(782): at dalvik.system.NativeStart.main(Native Method)
03-25 11:52:16.877: E/AndroidRuntime(782): Caused by: java.lang.ClassCastException: com.MappDemo.mymaps.MappingDemoActivity
03-25 11:52:16.877: E/AndroidRuntime(782): at com.MappDemo.mymaps.MappingDemoActivity.onCreate(MappingDemoActivity.java:19)
03-25 11:52:16.877: E/AndroidRuntime(782): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-25 11:52:16.877: E/AndroidRuntime(782): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
03-25 11:52:16.877: E/AndroidRuntime(782): ... 11 more
this is what I can see in logcat..
this what I have in mappingDemoActivity.java
public class MappingDemoActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//add listners for all buttons
View firstbutton= findViewById(R.id.geocode_button);
firstbutton.setOnClickListener((OnClickListener) this);
View secondButton = findViewById(R.id.latlong_button);
secondButton.setOnClickListener((OnClickListener) this);
View thirdButton = findViewById(R.id.presentLocation_button);
thirdButton.setOnClickListener((OnClickListener) this);
}
public void onClick(View v)
{
switch(v.getId())
{
case R.id.geocode_button:
Log.i("Button","Button 1 pushed");
Intent j = new Intent(this, ShowTheMap.class);
startActivity(j);
break;
case R.id.latlong_button:
Log.i("Button","Button 2 pushed");
Intent k = new Intent(this, ShowTheMap.class);
startActivity(k);
break;
case R.id.presentLocation_button:
Log.i("Button","Button 3 pushed");
Intent m = new Intent(this, MapMe.class);
startActivity(m);
break;
}
}
<uses-permission> tag needs to be a child of <manifest>, not <application>.
Try change <uses-permission> position, it can help.
Remove this code which is inside <intent-filter>
`<uses-library android:name="com.google.android.maps" />`
Because it is Already there in Below Quote.
Have a look at the Google MapsDemo that is included in the SDK my path is:
C:\android-sdk\add-ons\addon-google_apis-google_inc_-10\samples\MapsDemo
I had a quite anoying problem (MapActivity crashes on some devices) that was only showing up on certain(!) Android devices and also not in the Emulator. What I did was, to strip down the working demo until it was similar to my basic example. Then it turned out that Samsung phones don't accept package names not starting with com., while other devices (HTC Flyer) do! But this is not your problem, since you are using a com. package name.
There might be one more thing that comes to my mind. You didn't post your main.xml. If you use a nested LinearLayout below the MapView this also crashes the app. On top of the MapView it works fine. So in case you are using something like:
<LinearLayout ... >
<com.google.android.maps.MapView ... />
<LinearLayout ... >
<Button .../>
</LinearLayout>
</LinearLayout>
This could cause your problem. This is reproducable and throws exactly the same java.lang.ClassCastException error.
Also be sure to have your < uses-permission > and < uses-library > statements in the right place, as the guys said before. The first one must be a direct child of the < manifest > node. The second one must be a direct child of the < application > node.
I hope this helps you. I was going crazy with this stuff.
Bernd
I coded an app with several textview and checkbox.
Now I'm trying to add a new checkbox:
if I add it before a textview I get a runtime error,
if i add after it, there are no runtime error.
CODE:
In this way it does work
<TextView
android:id="#+id/tvInstructions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="#string/impostazioni_19"
android:textColor="#FF0000"
android:textStyle="bold" />
<CheckBox
android:id="#+id/cbPowerSavingMode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/light_sens_9" >
</CheckBox>
In this way it doesn't work:
<CheckBox
android:id="#+id/cbPowerSavingMode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/light_sens_9" >
</CheckBox>
<TextView
android:id="#+id/tvInstructions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="#string/impostazioni_19"
android:textColor="#FF0000"
android:textStyle="bold" />
What's the problem?
03-25 10:18:25.955: E/AndroidRuntime(1546): FATAL EXCEPTION: main
03-25 10:18:25.955: E/AndroidRuntime(1546): java.lang.RuntimeException: Unable to start activity ComponentInfo{it.android.smartscreenoffpro/it.android.smartscreenoffpro.ActivityImpostazioni}: java.lang.ClassCastException: android.widget.TextView
03-25 10:18:25.955: E/AndroidRuntime(1546): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1768)
03-25 10:18:25.955: E/AndroidRuntime(1546): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
03-25 10:18:25.955: E/AndroidRuntime(1546): at android.app.ActivityThread.access$1500(ActivityThread.java:123)
03-25 10:18:25.955: E/AndroidRuntime(1546): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
03-25 10:18:25.955: E/AndroidRuntime(1546): at android.os.Handler.dispatchMessage(Handler.java:99)
03-25 10:18:25.955: E/AndroidRuntime(1546): at android.os.Looper.loop(Looper.java:130)
03-25 10:18:25.955: E/AndroidRuntime(1546): at android.app.ActivityThread.main(ActivityThread.java:3835)
03-25 10:18:25.955: E/AndroidRuntime(1546): at java.lang.reflect.Method.invokeNative(Native Method)
03-25 10:18:25.955: E/AndroidRuntime(1546): at java.lang.reflect.Method.invoke(Method.java:507)
03-25 10:18:25.955: E/AndroidRuntime(1546): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
03-25 10:18:25.955: E/AndroidRuntime(1546): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
03-25 10:18:25.955: E/AndroidRuntime(1546): at dalvik.system.NativeStart.main(Native Method)
03-25 10:18:25.955: E/AndroidRuntime(1546): Caused by: java.lang.ClassCastException: android.widget.TextView
03-25 10:18:25.955: E/AndroidRuntime(1546): at it.android.smartscreenoffpro.ActivityImpostazioni.onCreate(ActivityImpostazioni.java:51)
03-25 10:18:25.955: E/AndroidRuntime(1546): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-25 10:18:25.955: E/AndroidRuntime(1546): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
03-25 10:18:25.955: E/AndroidRuntime(1546): ... 11 more
Try cleaning your project and recompiling will solve the issue.
Below is the step required for cleaning the project.
Goto Project Window and click Clean... menu item. A dialog will come which will show you the project to clean