Skip to content

working on api 8 devices; emulator #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dragom opened this issue Oct 12, 2012 · 11 comments
Closed

working on api 8 devices; emulator #2

dragom opened this issue Oct 12, 2012 · 11 comments

Comments

@dragom
Copy link

dragom commented Oct 12, 2012

Is this code working on API 8 devices?
I tested on emulator and have problems with this issue:

http://code.google.com/p/android/issues/detail?id=9431

java.lang.System.setProperty("java.net.preferIPv4Stack", "true");
java.lang.System.setProperty("java.net.preferIPv6Addresses", "false");

Even if I set this property something else is crashing...

@koush
Copy link
Owner

koush commented Oct 13, 2012

Run the sample and send me the log crash please.

@koush
Copy link
Owner

koush commented Oct 13, 2012

I've only realy tested on Gingerbread+. That's API 9

@dragom
Copy link
Author

dragom commented Oct 13, 2012

After fixing SSLcontext creation in...

public class SSLDataExchange implements DataTransformer, DataExchange
...
static SSLContext ctx;
static {
try {
ctx = SSLContext.getInstance("TLS");
ctx.init(null, null, new SecureRandom());
}
catch (Exception ex) {
}
}
...

I'm struggling to find out why is not working. There is no crash, but also no response.

@dragom dragom closed this as completed Oct 13, 2012
@dragom dragom reopened this Oct 13, 2012
@koush
Copy link
Owner

koush commented Oct 13, 2012

Fixed with:

bc96ad9

@koush koush closed this as completed Oct 13, 2012
@dragom
Copy link
Author

dragom commented Oct 14, 2012

Verified. Works okey. Thnx!
Still missing other stuff but I will try to implement myself in a forked repo.

  • there is only http GET method (probably you just wonder when this issue will popup :) )
  • SSL context should be as input parameter (client certificates, different TrustManagers)

@koush
Copy link
Owner

koush commented Oct 14, 2012

TBH, you probably shouldn't use this library for http yet. It's very rough still. Only the socket library portion is flushed out and battle tested. I'd read the project description :)

Asynchronous socket and http library for android. Based on nio, not threads. Seriously though, you probably don't need this. I wrote it for a Tethering app, where hundreds of threads waiting for data input would crush your phone. Your app won't have those demands.

@dragom
Copy link
Author

dragom commented Oct 14, 2012

Well, I read it and also checked Thethering code with jd-gui to see that only sockets nio is used.
So all http, ssl code is not so tested. But is working for me on some SSL problems client certificates.

Do you have any plans to work on it more?

@soulseekah
Copy link
Contributor

There's an Array.copyOf call in ArrayDeque that has a dependency on API level 9. API 8 doesn't compile. Perhaps the project.properties should target the android-8 platform to catch any back-incompatibilities?
Would you like me to patch that call for something else? System.arraycopy? Or will AndroidAsync not support API 8? If that's the case the AndroidManifest.xml should reflect that by bumping the minSdkVersion.
Let me know what you'd like me to do @koush.

--- a/android/lib/src/com/koushikdutta/async/ArrayDeque.java
+++ b/android/lib/src/com/koushikdutta/async/ArrayDeque.java
@@ -798,7 +798,7 @@ public class ArrayDeque<E> extends AbstractCollection<E>
         try {
             @SuppressWarnings("unchecked")
             ArrayDeque<E> result = (ArrayDeque<E>) super.clone();
-             result.elements = Arrays.copyOf(elements, elements.length);
+             System.arraycopy(elements, 0, result.elements, 0, elements.length);
             return result;

         } catch (CloneNotSupportedException e) {

Moreover, API 9 got the same ArrayDeque http://developer.android.com/reference/java/util/ArrayDeque.html so it's either not needed at all, or needs a fix.

Also, that method is never called anywhere in the project so even deleting it works, which is why targeting android-9 with a minSdkVersion value of 9 will still work on 8. This is still probably incorrect and needs a proper fix.

@koush
Copy link
Owner

koush commented Jul 16, 2013

@soulseekah Will take a look

@koush koush reopened this Jul 16, 2013
@koush
Copy link
Owner

koush commented Jul 16, 2013

Hm, I don't really support API 8 anymore
http://developer.android.com/about/dashboards/index.html

Only 3.1% footprint. I think I originally added the class for API 8 support, but didn't realize that Arrays.copyOf doesn't work. I'll apply your patch though.

@soulseekah
Copy link
Contributor

Agreed on API 8 support, 3.1% is not that much.
You will continue (start) supporting it if you'll accept a patch for the ArrayDeque.
Or bump all minimum versions to API 9 (AndroidManifest.xml) and remove ArrayDeque completely since it's part of the API since verion 9, http://developer.android.com/reference/java/util/ArrayDeque.html
Let me know what you want to do.

@koush koush closed this as completed Jul 16, 2013
koush added a commit that referenced this issue Sep 14, 2013
sacaratoqv added a commit to sacaratoqv/AndroidAsync that referenced this issue Aug 5, 2024
`Arrays.copyOf` was introduced in API 9, so the `minSdkVersion`
of 8 is not enough. Substituting for `System.arraycopy` makes a
bit more sense at this point in time.

See koush/AndroidAsync#2 (comment) for discussion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants