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
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 want to use espresso tests with gradle. To do that I tried to use double-espresso by Jake Wharton, but it doesn't work.
I've read that it could be duplicated dependencies, but I have excluded Dagger and Support-v4 libs, like Jake wrote in his README.
Can anyone give me advice on what could be wrong here?
test class:
package info.korzeniowski.myapp.test;
import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.LargeTest;
import info.korzeniowski.myapp.R;
import info.korzeniowski.myapp.activity.MainActivity_;
import static com.google.android.apps.common.testing.ui.espresso.Espresso.onView;
import static com.google.android.apps.common.testing.ui.espresso.assertion.ViewAssertions.matches;
import static com.google.android.apps.common.testing.ui.espresso.contrib.DrawerActions.closeDrawer;
import static com.google.android.apps.common.testing.ui.espresso.contrib.DrawerActions.openDrawer;
import static com.google.android.apps.common.testing.ui.espresso.contrib.DrawerMatchers.isClosed;
import static com.google.android.apps.common.testing.ui.espresso.contrib.DrawerMatchers.isOpen;
import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withId;
public class BasicTest extends ActivityInstrumentationTestCase2<MainActivity_> {
public BasicTest() {
super(MainActivity_.class);
}
#Override
protected void setUp() throws Exception {
super.setUp();
getActivity();
}
#LargeTest
public void testOpenAndCloseDrawer() {
onView(withId(R.id.drawer_layout)).check(matches(isClosed()));
openDrawer(R.id.drawer_layout);
onView(withId(R.id.drawer_layout)).check(matches(isOpen()));
closeDrawer(R.id.drawer_layout);
onView(withId(R.id.drawer_layout)).check(matches(isClosed()));
}
}
build.gradle:
buildscript {
def androidGradlePluginVersion= '0.9.+'
def androidAptVersion = '1.2+'
repositories {
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:${androidGradlePluginVersion}"
classpath "com.neenbedankt.gradle.plugins:android-apt:${androidAptVersion}"
}
}
repositories {
mavenCentral()
mavenLocal()
}
apply plugin: 'android'
apply plugin: 'android-apt'
apt {
arguments {
androidManifestFile variant.processResources.manifestFile
resourcePackageName 'info.korzeniowski.myapp'
}
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
lintOptions {
abortOnError false
}
packagingOptions {
exclude 'LICENSE.txt'
}
}
def androidSupportVersion = '19.0.+'
def greenDaoVersion = '1.3.+'
def androidAnnotationsVersion = '2.7.1'
def daggerVersion = '1.2.1'
dependencies {
// Android Support
compile "com.android.support:support-v4:${androidSupportVersion}"
compile "com.android.support:appcompat-v7:${androidSupportVersion}"
// Android Annotations
apt "com.googlecode.androidannotations:androidannotations:${androidAnnotationsVersion}"
compile "com.googlecode.androidannotations:androidannotations-api:${androidAnnotationsVersion}"
// Dagger
apt "com.squareup.dagger:dagger-compiler:${daggerVersion}"
compile "com.squareup.dagger:dagger:${daggerVersion}"
// Espresso
androidTestCompile ('com.jakewharton.espresso:espresso:1.1-r2') {
exclude group: 'com.squareup.dagger', module: 'dagger'
}
androidTestCompile ('com.jakewharton.espresso:espresso-support-v4:1.1-r2') {
exclude group: 'com.android.support', module: 'support-v4'
}
}
Test results:
Running tests
Test running started
Test failed to run to completion. Reason: 'Instrumentation run failed due to 'java.lang.IllegalAccessError''. Check device logcat for details
Test running failed: Instrumentation run failed due to 'java.lang.IllegalAccessError'
Logcat:
3-18 12:52:12.168 274-443/system_process I/ActivityManager﹕ Start proc info.korzeniowski.myapp for added application info.korzeniowski.myapp: pid=2998 uid=10049 gids={50049, 1028}
03-18 12:52:27.417 2998-2998/? I/dalvikvm﹕ Failed resolving Lorg/hamcrest/integration/EasyMock2Adapter; interface 2417 'Lorg/easymock/IArgumentMatcher;'
03-18 12:52:27.417 2998-2998/? W/dalvikvm﹕ Link of class 'Lorg/hamcrest/integration/EasyMock2Adapter;' failed
03-18 12:52:27.537 2998-2998/? W/ClassPathPackageInfoSource﹕ Cannot load class. Make sure it is in your apk. Class name: 'org.hamcrest.integration.EasyMock2Adapter'. Message: org.hamcrest.integration.EasyMock2Adapter
java.lang.ClassNotFoundException: org.hamcrest.integration.EasyMock2Adapter
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:204)
at android.test.ClassPathPackageInfoSource.createPackageInfo(ClassPathPackageInfoSource.java:88)
at android.test.ClassPathPackageInfoSource.access$000(ClassPathPackageInfoSource.java:39)
at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:50)
at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:47)
at android.test.SimpleCache.get(SimpleCache.java:31)
at android.test.ClassPathPackageInfoSource.getPackageInfo(ClassPathPackageInfoSource.java:72)
at android.test.ClassPathPackageInfo.getSubpackages(ClassPathPackageInfo.java:48)
at android.test.ClassPathPackageInfo.addTopLevelClassesTo(ClassPathPackageInfo.java:61)
at android.test.ClassPathPackageInfo.getTopLevelClassesRecursive(ClassPathPackageInfo.java:55)
at android.test.suitebuilder.TestGrouping.testCaseClassesInPackage(TestGrouping.java:156)
at android.test.suitebuilder.TestGrouping.addPackagesRecursive(TestGrouping.java:117)
at android.test.suitebuilder.TestSuiteBuilder.includePackages(TestSuiteBuilder.java:102)
at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:366)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4435)
at android.app.ActivityThread.access$1300(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoClassDefFoundError: org/hamcrest/integration/EasyMock2Adapter
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:204)
at android.test.ClassPathPackageInfoSource.createPackageInfo(ClassPathPackageInfoSource.java:88)
at android.test.ClassPathPackageInfoSource.access$000(ClassPathPackageInfoSource.java:39)
at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:50)
at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:47)
at android.test.SimpleCache.get(SimpleCache.java:31)
at android.test.ClassPathPackageInfoSource.getPackageInfo(ClassPathPackageInfoSource.java:72)
at android.test.ClassPathPackageInfo.getSubpackages(ClassPathPackageInfo.java:48)
at android.test.ClassPathPackageInfo.addTopLevelClassesTo(ClassPathPackageInfo.java:61)
at android.test.ClassPathPackageInfo.getTopLevelClassesRecursive(ClassPathPackageInfo.java:55)
at android.test.suitebuilder.TestGrouping.testCaseClassesInPackage(TestGrouping.java:156)
at android.test.suitebuilder.TestGrouping.addPackagesRecursive(TestGrouping.java:117)
at android.test.suitebuilder.TestSuiteBuilder.includePackages(TestSuiteBuilder.java:102)
at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:366)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4435)
at android.app.ActivityThread.access$1300(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.hamcrest.integration.EasyMock2Adapter" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/info.korzeniowski.myapp.test-1.apk", zip file "/data/app/info.korzeniowski.myapp-1.apk"],nativeLibraryDirectories=[/data/app-lib/info.korzeniowski.myapp.test-1, /data/app-lib/info.korzeniowski.myapp-1, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:204)
at android.test.ClassPathPackageInfoSource.createPackageInfo(ClassPathPackageInfoSource.java:88)
at android.test.ClassPathPackageInfoSource.access$000(ClassPathPackageInfoSource.java:39)
at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:50)
at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:47)
at android.test.SimpleCache.get(SimpleCache.java:31)
at android.test.ClassPathPackageInfoSource.getPackageInfo(ClassPathPackageInfoSource.java:72)
at android.test.ClassPathPackageInfo.getSubpackages(ClassPathPackageInfo.java:48)
at android.test.ClassPathPackageInfo.addTopLevelClassesTo(ClassPathPackageInfo.java:61)
at android.test.ClassPathPackageInfo.getTopLevelClassesRecursive(ClassPathPackageInfo.java:55)
at android.test.suitebuilder.TestGrouping.testCaseClassesInPackage(TestGrouping.java:156)
at android.test.suitebuilder.TestGrouping.addPackagesRecursive(TestGrouping.java:117)
at android.test.suitebuilder.TestSuiteBuilder.includePackages(TestSuiteBuilder.java:102)
at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:366)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4435)
at android.app.ActivityThread.access$1300(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
03-18 12:52:27.537 2998-2998/? I/dalvikvm﹕ Failed resolving Lorg/hamcrest/integration/JMock1Adapter; interface 2468 'Lorg/jmock/core/Constraint;'
03-18 12:52:27.537 2998-2998/? W/dalvikvm﹕ Link of class 'Lorg/hamcrest/integration/JMock1Adapter;' failed
03-18 12:52:27.587 2998-2998/? W/ClassPathPackageInfoSource﹕ Cannot load class. Make sure it is in your apk. Class name: 'org.hamcrest.integration.JMock1Adapter'. Message: org.hamcrest.integration.JMock1Adapter
java.lang.ClassNotFoundException: org.hamcrest.integration.JMock1Adapter
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:204)
at android.test.ClassPathPackageInfoSource.createPackageInfo(ClassPathPackageInfoSource.java:88)
at android.test.ClassPathPackageInfoSource.access$000(ClassPathPackageInfoSource.java:39)
at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:50)
at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:47)
at android.test.SimpleCache.get(SimpleCache.java:31)
at android.test.ClassPathPackageInfoSource.getPackageInfo(ClassPathPackageInfoSource.java:72)
at android.test.ClassPathPackageInfo.getSubpackages(ClassPathPackageInfo.java:48)
at android.test.ClassPathPackageInfo.addTopLevelClassesTo(ClassPathPackageInfo.java:61)
at android.test.ClassPathPackageInfo.getTopLevelClassesRecursive(ClassPathPackageInfo.java:55)
at android.test.suitebuilder.TestGrouping.testCaseClassesInPackage(TestGrouping.java:156)
at android.test.suitebuilder.TestGrouping.addPackagesRecursive(TestGrouping.java:117)
at android.test.suitebuilder.TestSuiteBuilder.includePackages(TestSuiteBuilder.java:102)
at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:366)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4435)
at android.app.ActivityThread.access$1300(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoClassDefFoundError: org/hamcrest/integration/JMock1Adapter
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:204)
at android.test.ClassPathPackageInfoSource.createPackageInfo(ClassPathPackageInfoSource.java:88)
at android.test.ClassPathPackageInfoSource.access$000(ClassPathPackageInfoSource.java:39)
at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:50)
at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:47)
at android.test.SimpleCache.get(SimpleCache.java:31)
at android.test.ClassPathPackageInfoSource.getPackageInfo(ClassPathPackageInfoSource.java:72)
at android.test.ClassPathPackageInfo.getSubpackages(ClassPathPackageInfo.java:48)
at android.test.ClassPathPackageInfo.addTopLevelClassesTo(ClassPathPackageInfo.java:61)
at android.test.ClassPathPackageInfo.getTopLevelClassesRecursive(ClassPathPackageInfo.java:55)
at android.test.suitebuilder.TestGrouping.testCaseClassesInPackage(TestGrouping.java:156)
at android.test.suitebuilder.TestGrouping.addPackagesRecursive(TestGrouping.java:117)
at android.test.suitebuilder.TestSuiteBuilder.includePackages(TestSuiteBuilder.java:102)
at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:366)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4435)
at android.app.ActivityThread.access$1300(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.hamcrest.integration.JMock1Adapter" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/info.korzeniowski.myapp.test-1.apk", zip file "/data/app/info.korzeniowski.myapp-1.apk"],nativeLibraryDirectories=[/data/app-lib/info.korzeniowski.myapp.test-1, /data/app-lib/info.korzeniowski.myapp-1, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:204)
at android.test.ClassPathPackageInfoSource.createPackageInfo(ClassPathPackageInfoSource.java:88)
at android.test.ClassPathPackageInfoSource.access$000(ClassPathPackageInfoSource.java:39)
at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:50)
at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:47)
at android.test.SimpleCache.get(SimpleCache.java:31)
at android.test.ClassPathPackageInfoSource.getPackageInfo(ClassPathPackageInfoSource.java:72)
at android.test.ClassPathPackageInfo.getSubpackages(ClassPathPackageInfo.java:48)
at android.test.ClassPathPackageInfo.addTopLevelClassesTo(ClassPathPackageInfo.java:61)
at android.test.ClassPathPackageInfo.getTopLevelClassesRecursive(ClassPathPackageInfo.java:55)
at android.test.suitebuilder.TestGrouping.testCaseClassesInPackage(TestGrouping.java:156)
at android.test.suitebuilder.TestGrouping.addPackagesRecursive(TestGrouping.java:117)
at android.test.suitebuilder.TestSuiteBuilder.includePackages(TestSuiteBuilder.java:102)
at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:366)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4435)
at android.app.ActivityThread.access$1300(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
03-18 12:52:28.477 2998-3011/? I/TestRunner﹕ started: testOpenAndCloseDrawer(info.korzeniowski.myapp.test.BasicTest)
03-18 12:52:28.497 274-439/system_process I/ActivityManager﹕ START u0 {act=android.intent.action.MAIN flg=0x10000000 cmp=info.korzeniowski.myapp/.activity.MainActivity_} from pid 2998
03-18 12:52:28.617 2998-2998/? I/greenDAO﹕ Creating tables for schema version 1
03-18 12:52:28.687 2998-2998/? W/dalvikvm﹕ Class resolved by unexpected DEX: Linfo/korzeniowski/myapp/MyApp;(0x416fc6a8):0x73054000 ref [Ldagger/ObjectGraph;] Ldagger/ObjectGraph;(0x416fc6a8):0x72ec8000
03-18 12:52:28.687 2998-2998/? W/dalvikvm﹕ (Linfo/korzeniowski/myapp/MyApp; had used a different Ldagger/ObjectGraph; during pre-verification)
03-18 12:52:28.697 2998-2998/? W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41465700)
03-18 12:52:28.738 2998-2998/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
at info.korzeniowski.myapp.MyApp.onCreate(MyApp.java:32)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4444)
at android.app.ActivityThread.access$1300(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
03-18 12:52:28.738 274-286/system_process W/ActivityManager﹕ Error in app info.korzeniowski.myapp running instrumentation ComponentInfo{info.korzeniowski.myapp.test/android.test.InstrumentationTestRunner}:
03-18 12:52:28.738 274-286/system_process W/ActivityManager﹕ java.lang.IllegalAccessError
03-18 12:52:28.738 274-286/system_process W/ActivityManager﹕ java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementationF
Since class is not found in org.hamcrest.integration package, try excluding it. Then your your dependencies would look like
// Espresso
androidTestCompile ('com.jakewharton.espresso:espresso:1.1-r2') {
exclude group: 'com.squareup.dagger', module: 'dagger'
exclude group: 'org.hamcrest', module: 'hamcrest-integration'
}
androidTestCompile ('com.jakewharton.espresso:espresso-support-v4:1.1-r2') {
exclude group: 'com.android.support', module: 'support-v4'
// Not sure whether line below is needed
exclude group: 'org.hamcrest', module: 'hamcrest-integration'
}
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)
I have a problem.
When I updated Android SDK tool to version 17 and the ADT to 17 I can't use ksoap2 any more.
I start the app and get this error:
03-25 20:13:49.995: E/AndroidRuntime(555): FATAL EXCEPTION: main
03-25 20:13:49.995: E/AndroidRuntime(555): java.lang.NoClassDefFoundError: org.ksoap2.serialization.SoapObject
03-25 20:13:49.995: E/AndroidRuntime(555): at com.alcad.pernat.praksa.SplashScreen.pridobiDanasnjo(SplashScreen.java:124)
03-25 20:13:49.995: E/AndroidRuntime(555): at com.alcad.pernat.praksa.SplashScreen.onCreate(SplashScreen.java:73)
03-25 20:13:49.995: E/AndroidRuntime(555): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-25 20:13:49.995: E/AndroidRuntime(555): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-25 20:13:49.995: E/AndroidRuntime(555): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-25 20:13:49.995: E/AndroidRuntime(555): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-25 20:13:49.995: E/AndroidRuntime(555): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-25 20:13:49.995: E/AndroidRuntime(555): at android.os.Handler.dispatchMessage(Handler.java:99)
03-25 20:13:49.995: E/AndroidRuntime(555): at android.os.Looper.loop(Looper.java:123)
03-25 20:13:49.995: E/AndroidRuntime(555): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-25 20:13:49.995: E/AndroidRuntime(555): at java.lang.reflect.Method.invokeNative(Native Method)
03-25 20:13:49.995: E/AndroidRuntime(555): at java.lang.reflect.Method.invoke(Method.java:521)
03-25 20:13:49.995: E/AndroidRuntime(555): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-25 20:13:49.995: E/AndroidRuntime(555): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-25 20:13:49.995: E/AndroidRuntime(555): at dalvik.system.NativeStart.main(Native Method)
I should get String with some numbers but instead I get this error.
I was using ksoap2-2.5.4.jar and tried the new ksoap2-android-assembly-2.6.2-jar-with-dependencies.jar.
I'm using Eclipse indigo, Ubuntu 11.04.
The code looks like this:
SoapObject Request =new SoapObject(NAMESPACE,METHOD_NAME); // Here I get the error
SoapSerializationEnvelope soapEnvelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.dotNet=false;
String tmp=odstejDatum(datum);
Request.addProperty("datumod",tmp);
Request.addProperty("datumdo",datum);
Request.addProperty("tip_lme",1);
#SuppressWarnings("deprecation")
HttpTransportSE aht=new HttpTransportSE(URL,5000);
soapEnvelope.setOutputSoapObject(Request);
//
aht.call(SOAP_ACTION_DANASNJI,soapEnvelope);
Object response= soapEnvelope.getResponse();
Thanks for the help.
Android SDK tool to version 17 and the ADT to 17 they changed lib structure more details.
Here is the fix:
Remove the "ksoap2-android-assembly-2.6.2-jar-with-dependencies.jar"
from the build path.
copy the jar file into libs folder
(if not exist create it), then remove jar file from your folder(if you have custom jar folder in your project).
it will automatically take it in the build path.then, clean your project and run.
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