android.support.v4 causing force close on some devices - android

I have one application listed in playstore, for which some user have reported force close issue. I went to developer console to see the details and that showed the following message. I have used android support library in the application. The class extends FragmentActivity and the other imports i have used are
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.AsyncTaskLoader;
import android.support.v4.content.Loader;
Stacktrace
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.support.v4.a.h.done(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
at java.lang.Thread.run(Thread.java:1019)
Caused by: java.lang.NullPointerException
at my.package.name.k.n(Unknown Source)
at my.package.name.k.d(Unknown Source)
at android.support.v4.a.a.e(Unknown Source)
at android.support.v4.a.b.a(Unknown Source)
at android.support.v4.a.b.a(Unknown Source)
at android.support.v4.a.g.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
... 4 more
For applications that include obfuscated code, stack traces contain obfuscated symbol
names. If the application was obfuscated using ProGuard, you can unobfuscate the stack
trace using the "retrace" tool, included in the Android SDK Tools r8 and later. For
more information, see the ProGuard document.

Related

Olingo OData 2.0 for Android - Dependency to javax.xml.stream.XMLInputFactory

I tried to implement an OData V2 Client using Apache Olingo OData 2.0 in Android.
Executing the client class as java class works fine, but I cannot run the Android App using the same code in an AsyncTask:
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.my.app.appname, PID: 2521
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.conurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
java.util.conurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/xml/stream/XMLInputFactory;
at org.apache.olingo.odata2.core.commons.XmlHelper.createStreamReader(XmlHelper.java:41)
org.apache.olingo.odata2.core.edm.provider.EdmxProvider.parse(EdmxProvider.java:50)
org.apache.olingo.odata2.core.ep.ProviderFacadeImpl.readMetadata(ProviderFacadeImpl.java:224)
org.apache.olingo.odata2.api.ep.EntityProvider.readMetadata(EntityProvider.java:844)
at connectivity.MyClass.doInBackground(MyClass.java:153)
at connectivity.MyClass.doInBackground(MyClass.java:38)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237) <4 more...>
Caused by: java.lang.ClassNotFoundException: Didn't find class "javax.xml.stream.XMLInputFactory" on path: DexPathList[[zip file "/data/app/com.my.app.appname-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469) <12 more...>
Suppressed: java.lang.ClassNotFoundException: javax.xml.stream.XmlInputFactory
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.findClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 13 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
My questions are:
(How) Can I fix this issue?
(I read somewhere that the missing class might not be supported by Android?)
Would it help to switch to Apache Olingo OData 4.0?
(I need to consume an OData V2 service and if Olingo V4 would suport this on Android, I might try to migrate my client...)
Thanks in advance!
You have to repackage the javax.xml.stream classes yourself since Android does not support XML. Olingo V4 has a special android packaged client for that on the V4 dowload page: http://olingo.apache.org/doc/odata4/download.html
Olingo V2 does not have this feature because when the V2 library was created the main focus was on server side implementations. This is why a lot of convenience on client side is missing.

Android ChimpChat throws exception

I am trying to get chimpchat to work for Android. This is my class
import java.util.Map;
import java.util.TreeMap;
import com.android.chimpchat.ChimpChat;
import com.android.chimpchat.adb.AdbBackend;
import com.android.chimpchat.core.IChimpDevice;
import com.android.chimpchat.core.TouchPressType;
public class TapTest {
public static void main(String[] args)
{
Map<String, String> options = new TreeMap<String, String>();
options.put("backend", "adb");
options.put("adbLocation", "D:\\Android\\platform-tools\\adb.exe");
ChimpChat chimpchat = ChimpChat.getInstance(options);
IChimpDevice device = chimpchat.waitForConnection(5000, ".*");
device.touch(100, 100, TouchPressType.DOWN_AND_UP);
chimpchat.shutdown();
}
}
and running this gives me this exception
Exception in thread "main" java.lang.NoClassDefFoundError: com/android/ddmlib/TimeoutException
at com.android.chimpchat.adb.AdbBackend.waitForConnection(AdbBackend.java:122)
at com.android.chimpchat.ChimpChat.waitForConnection(ChimpChat.java:91)
at TapTest.main(TapTest.java:21)
Caused by: java.lang.ClassNotFoundException: com.android.ddmlib.TimeoutException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 3 more
I have added Chimpchat.jar,guava.jar, monkeyrunner.jar, sdklib.jar, jython-standalone.jar.
Why don't you use uiautomator instead?
I see the uiautomator as the better tool for inspecting UI elements. It has more powerful methods to identify UI objects and interact with them. You no longer need to place sleep commands in your script. Just wait for a specific element. You can wait for an element to appear or disappear.
You can have watchers which run in case an UI object is not found. This can be helpful when handling pop-ups and error messages.
Here's a link to a tutorial. http://developer.android.com/tools/testing/testing_ui.html
As the error say. You need to add ddmlib.jar too.

How to use spring in Android Application?

I am trying to use spring in my android app as client of my spring mvc REST application. I think I have a problem to put correct jars in classpath of my android app. I put the image of jars in libs folder of my android app. I found many related question on SO. But none of them helped me. That is why i am asking here again.
Here is how I am calling my webservice referenced from here :
#Override
protected SowResult doInBackground(Void... params) {
System.out.println("URLLLL : "+URL);
RestTemplate rest = new RestTemplate();
rest.getMessageConverters().add(new MappingJacksonHttpMessageConverter());
SowResult result = rest.getForObject(URL, SowResult.class);
return result;
}
And the exception I am getting:
FATAL EXCEPTION: AsyncTask #1
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:200)
at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
at java.lang.Thread.run(Thread.java:1096)
Caused by: java.lang.NoSuchMethodError: org.codehaus.jackson.map.ObjectMapper.getTypeFactory
at org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.getJavaType(MappingJacksonHttpMessageConverter.java:166)
at org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.canRead(MappingJacksonHttpMessageConverter.java:101)
at org.springframework.web.client.RestTemplate$AcceptHeaderRequestCallback.doWithRequest(RestTemplate.java:542)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:474)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:439)
at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:237)
at com.inovarge.shoponway.resttasks.UserRestTask.doInBackground(UserRestTask.java:30)
at com.inovarge.shoponway.resttasks.UserRestTask.doInBackground(UserRestTask.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:185)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
... 4 more
The exception indicates that you are missing a required Jackson dependency. First, I recommend using MappingJackson2HttpMessageConverter instead of the MappingJacksonHttpMessageConverter which you've configured:
rest.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
Next, MappingJackson2HttpMessageConverter depends on the Jackson 2 library for its functionality, which requires the following files be on your classpath:
jackson-databind-2.3.2.jar
jackson-annotations-2.3.2.jar
jackson-core-2.3.2.jar
You already have jackson-databind-2.3.2.jar in your libs folder, so you need to download the other two jars.
Lastly, I highly recommend using a dependency management system like the Gradle plugin in Android's New Build System. It will handle downloading all the transitive dependencies for you instead of having to manually do that.

Untracable AsyncTask error

I have a live app that uses AsyncTask in several activities, and I'm getting an untraceable error (below). The key line of bto.org.monitoring.birdtrack.ce.doInBackground(Unknown Source) that is being sent to Google Play by my users (with no messages of course) isn't letting me debug this problem, so I can't find the right bit of code never mind post it here. Any ideas?
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:200)
at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
at java.lang.Thread.run(Thread.java:1019)
Caused by: java.lang.NullPointerException
at bto.org.monitoring.birdtrack.ce.doInBackground(Unknown Source)
at android.os.AsyncTask$2.call(AsyncTask.java:185)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
... 4 more
OK, sussed this now. I am using Proguard, and can detect the location of the doInBackground() method by grabbing the error and running it past the using:
retrace.sh -verbose myApp/proguard/mapping.txt myErrorFile.txt
This translates the error to display the classes that are causing it. Hooray!

why java.lang.IllegalStateException: no transaction pending and how to solve

I developed one android application.Its working fine for our device and and most of the devices.But some of the users sent error report.
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:200)
at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
at java.lang.Thread.run(Thread.java:1019)
Caused by: java.lang.IllegalStateException: no transaction pending
at android.database.sqlite.SQLiteDatabase.endTransaction(SQLiteDatabase.java:610)
at com.footy.fixture.FixtureActivity$ProgressTask.doInBackground(FixtureActivity.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:185)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
Why this happends for some devices.Which type of error is this?...How can I solve this
You have called SQLiteDatabase.endTransaction() without first calling SQLiteDatabase.beginTransaction(). So you're trying to close a transaction which doesn't exist. Inspect your code, or post the relevant snippets here if you can't see what's wrong.

Categories

Resources