I am encountering the exception stated below in my android code where I am trying to parse an ODATA service using odata4j JAR library.
java.lang.IllegalArgumentException: Illegal datetime format 2015-05-07T00%3A00%3A00
I am getting the error at line below in Android code:
List list = c.getEntities("EntityName").execute().toList();
My entire stacktrace is stated below:
Caused by: java.lang.IllegalArgumentException: bad valueString [datetime'2015-05-07T00%3A00%3A00'] as part of keyString [*****='*****',*****='0',***='*****',date=datetime'2015-05-07T00%3A00%3A00',*****='*******']
at org.odata4j.core.OEntityKey.parse(OEntityKey.java:157)
at org.odata4j.format.xml.AtomFeedFormatParser.parseEntityKey(AtomFeedFormatParser.java:300)
at org.odata4j.format.xml.AtomFeedFormatParser.entityFromAtomEntry(AtomFeedFormatParser.java:431)
at org.odata4j.format.xml.AtomFeedFormatParser.parseEntry(AtomFeedFormatParser.java:349)
at org.odata4j.format.xml.AtomFeedFormatParser.parseFeed(AtomFeedFormatParser.java:169)
at org.odata4j.format.xml.AtomFeedFormatParser.parse(AtomFeedFormatParser.java:157)
at org.odata4j.format.xml.AtomFeedFormatParser.parse(AtomFeedFormatParser.java:45)
at org.odata4j.consumer.ConsumerQueryEntitiesRequest.doRequest(ConsumerQueryEntitiesRequest.java:67)
at org.odata4j.consumer.ConsumerQueryEntitiesRequest.getEntries(ConsumerQueryEntitiesRequest.java:50)
at org.odata4j.consumer.ConsumerQueryEntitiesRequest.execute(ConsumerQueryEntitiesRequest.java:40)
at *******.MyActivity$LoadSpinners.doInBackground(MyActivity.java:287)
at *******.MyActivity$LoadSpinners.doInBackground(MyActivity.java:202)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.IllegalArgumentException: Illegal datetime format 2015-05-07T00%3A00%3A00
at org.odata4j.internal.InternalUtil.parseDateTimeFromXml(InternalUtil.java:96)
at org.odata4j.expression.ExpressionParser.readExpression(ExpressionParser.java:462)
at org.odata4j.expression.ExpressionParser.parse(ExpressionParser.java:64)
at org.odata4j.core.OEntityKey.parse(OEntityKey.java:152)
There are ****** placed at certain sensitive information like not related properties and app package names.
Related
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #3
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:299)
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 android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.NoClassDefFoundError: org.apache.http.entity.mime.HttpMultipartMode
at org.apache.http.entity.mime.MultipartEntity.<init>(MultipartEntity.java:91)
at com.greencubes.greendesk.AndroidMultiPartEntity.<init>(AndroidMultiPartEntity.java:19)
at com.greencubes.greendesk.FirstFragment$UploadFileToServer.uploadFile(FirstFragment.java:244)
at com.greencubes.greendesk.FirstFragment$UploadFileToServer.doInBackground(FirstFragment.java:233)
at com.greencubes.greendesk.FirstFragment$UploadFileToServer.doInBackground(FirstFragment.java:211)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
If you are using a library, you need to put it into /libs folder.
download httpmime, httpcore and httpclient library from http://hc.apache.org/downloads.cgi
Hope this will help as i have the same jar files in the studio.
If you are using Eclipse then add all the jar files to build path.
Thanks,
Apache HTTP client was removed in Lollipop. It's recommended to use HttpUrlConnection instead.
If you have to use it you can add:
android {
useLibrary 'org.apache.http.legacy'
}
to your build.gradle file.
I use this code in my android studio project:
HttpUrl url = new HttpUrl.Builder().scheme("http").host("www.somesite.com")
.addPathSegment("kontakt")
.addQueryParameter("yit_contact[imie]", name)
.addQueryParameter("yit_contact[email]", email)
.addQueryParameter("yit_contact[telefon]", telephone)
.addQueryParameter("yit_contact[wiadomosc]", message)
.addQueryParameter("yit_bot", "")
.addQueryParameter("_wp_http_referer", "/kontakt/").build();
Request request = new Request.Builder().url(url).build();
Response response = new OkHttpClient().newCall(request).execute();
and I get this error when I try to get Response object:
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:299)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
at java.util.concurrent.FutureTask.run(FutureTask.java:239)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.VerifyError: com/squareup/okhttp/internal/http/HttpConnection$AbstractSource
at com.squareup.okhttp.internal.http.HttpConnection.newFixedLengthSource(HttpConnection.java:246)
at com.squareup.okhttp.internal.http.HttpTransport.getTransferStream(HttpTransport.java:125)
at com.squareup.okhttp.internal.http.HttpTransport.openResponseBody(HttpTransport.java:110)
at com.squareup.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:926)
at com.squareup.okhttp.internal.http.HttpEngine.access$300(HttpEngine.java:95)
at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:902)
at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:760)
at com.squareup.okhttp.Call.getResponse(Call.java:274)
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:230)
at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:201)
at com.squareup.okhttp.Call.execute(Call.java:81)
at com.example.tomek.myapplication.KontaktActivity$SendEmail.doInBackground(KontaktActivity.java:135)
at com.example.tomek.myapplication.KontaktActivity$SendEmail.doInBackground(KontaktActivity.java:87)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
I have added jar files to project:
compile files('libs/okhttp-2.4.0.jar')
compile files('libs/okio-1.0.0.jar')
Help.
Try adding Okio-1.4.0, which is required by OkHttp 2.4.0.
<dependency>
<groupId>com.squareup.okio</groupId>
<artifactId>okio</artifactId>
<version>1.4.0</version>
</dependency>
I am trying to implement the starter code for AWS Mobile Analytics got from http://docs.aws.amazon.com/mobile/sdkforandroid/developerguide/analytics.html
I have everything setup along with Internet permission in manifest but I am still getting this error after all debugging and troubleshooting.
02-27 17:40:38.403 25639-25830/com.bluecolony.watchappstore I/AmazonHttpClient﹕ Unable to execute HTTP request: Unable to resolve host "mobileanalytics.us-east-1.": No address associated with hostname
java.net.UnknownHostException: Unable to resolve host "mobileanalytics.us-east-1.": No address associated with hostname
at java.net.InetAddress.lookupHostByName(InetAddress.java:424)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
at java.net.InetAddress.getAllByName(InetAddress.java:214)
at com.amazonaws.org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)
at com.amazonaws.org.apache.http.impl.conn.DefaultClientConnectionOperator.resolveHostname(DefaultClientConnectionOperator.java:278)
at com.amazonaws.org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:162)
at com.amazonaws.org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)
at com.amazonaws.org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:645)
at com.amazonaws.org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:480)
at com.amazonaws.org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
at com.amazonaws.org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:400)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:243)
at com.amazonaws.services.mobileanalytics.AmazonMobileAnalyticsClient.invoke(AmazonMobileAnalyticsClient.java:313)
at com.amazonaws.services.mobileanalytics.AmazonMobileAnalyticsClient.putEvents(AmazonMobileAnalyticsClient.java:258)
at com.amazonaws.mobileconnectors.amazonmobileanalytics.internal.delivery.DefaultDeliveryClient.submitEvents(Unknown Source)
at com.amazonaws.mobileconnectors.amazonmobileanalytics.internal.delivery.DefaultDeliveryClient.access$600(Unknown Source)
at com.amazonaws.mobileconnectors.amazonmobileanalytics.internal.delivery.DefaultDeliveryClient$3.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:841)
Caused by: libcore.io.GaiException: getaddrinfo failed: EAI_NODATA (No address associated with hostname)
at libcore.io.Posix.getaddrinfo(Native Method)
at libcore.io.ForwardingOs.getaddrinfo(ForwardingOs.java:61)
at java.net.InetAddress.lookupHostByName(InetAddress.java:405)
com.amazonaws.org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)
at com.amazonaws.org.apache.http.impl.conn.DefaultClientConnectionOperator.resolveHostname(DefaultClientConnectionOperator.java:278)
at com.amazonaws.org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:162)
at com.amazonaws.org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)
at com.amazonaws.org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:645)
at com.amazonaws.org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:480)
at com.amazonaws.org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
at com.amazonaws.org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:400)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:243)
at com.amazonaws.services.mobileanalytics.AmazonMobileAnalyticsClient.invoke(AmazonMobileAnalyticsClient.java:313)
at com.amazonaws.services.mobileanalytics.AmazonMobileAnalyticsClient.putEvents(AmazonMobileAnalyticsClient.java:258)
at com.amazonaws.mobileconnectors.amazonmobileanalytics.internal.delivery.DefaultDeliveryClient.submitEvents(Unknown Source)
at com.amazonaws.mobileconnectors.amazonmobileanalytics.internal.delivery.DefaultDeliveryClient.access$600(Unknown Source)
at com.amazonaws.mobileconnectors.amazonmobileanalytics.internal.delivery.DefaultDeliveryClient$3.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:841)
I have tried using ConnectivityManager and InetAddress.getByName("google.com").isReachable(3) to confirm that my code is able to access internet.
My assumption so far is that somehow hostname which is called is wrong. it should be "mobileanalytics.us-east-1.amazonaws.com" instead of "mobileanalytics.us-east-1." . Otherwise it can be a firewall issue or with https , which I have to explore further. I am connected with wifi on mobile.
Any pointers to help ?
Looks like this was a known bug with the AWS Mobile SDK v2.1.9.
Reading through #Yangfan's comment looks like this has been addressed in version 2.1.10
http://aws.amazon.com/releasenotes/3841134019807789
Hi , my app when runs on HWY320-U (Huawei) throws exception.
What may be reason of this?
java.lang.IllegalArgumentException: Invalid int: "Acc"
at android.os.Parcel.readException(Parcel.java:1429)
at android.os.Parcel.readException(Parcel.java:1379)
at afa.a(SourceFile:102)
at aer.a(SourceFile:174)
at aer.a(SourceFile:151)
at afw.run(SourceFile:14)
at afy.run(SourceFile:30)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:838)
If I look at the stacktrace, I would say that you use Integer.parseInt() somewhere and the input seems to be "Acc". This input cannot be parsed to an Integer as it is a String
The original name of the content provider authority that works fine with no errors:
public static final String AUTHORITY = com.dakotastream.cardiologger.CardioLoggerProvider12;
I want rename my authority to:
public static final String AUTHORITY = com.dakotastream.cardiologger.CardioLoggerProvider;
When I change the name to the above I get this error.
Caused by: java.lang.StringIndexOutOfBoundsException: length=68; index=70
public static final String AUTHORITY = com.dakotastream.cardiologger.CardioLoggerProvider1;
When I change the name to the above I get this error.
Caused by: java.lang.StringIndexOutOfBoundsException: length=69; index=70
If I rename the package to com.dakotastream.cardiologger12, then I can use the
public static final String AUTHORITY = com.dakotastream.cardiologger12.CardioLoggerProvider;
with no errors.
The Authority seems to require a string length greater than 69 characters.
I am using SDK Tools 22.6.3, API 19, ABS Library 4.4.0
I have tried creating a new Android Application Project and dropping the code in. I get the same error.
Entire LogCat Dump:
FATAL EXCEPTION: ModernAsyncTask #1
Process: com.dakotastream.cardiologger, PID: 1344
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.support.v4.content.ModernAsyncTask$3.done(ModernAsyncTask.java:137)
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 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.StringIndexOutOfBoundsException: length=68; index=70
at java.lang.String.indexAndLength(String.java:584)
at java.lang.String.substring(String.java:1449)
at com.dakotastream.cardiologger.DbContentProvider.query(DbContentProvider.java:279)
at android.content.ContentProvider.query(ContentProvider.java:857)
at android.content.ContentProvider$Transport.query(ContentProvider.java:200)
at android.content.ContentResolver.query(ContentResolver.java:461)
at android.content.ContentResolver.query(ContentResolver.java:404)
at android.support.v4.content.CursorLoader.loadInBackground(CursorLoader.java:49)
at android.support.v4.content.CursorLoader.loadInBackground(CursorLoader.java:35)
at android.support.v4.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:242)
at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:51)
at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:40)
at android.support.v4.content.ModernAsyncTask$2.call(ModernAsyncTask.java:123)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
In Eclipse I use Android Tools>Rename Application Package to change the name.
This is the error I get when I change the name.
Update the android:authorities tag accordingly for the provider in the manifest.