WebDav library Sardine on Android with httpclientandroidlib - android

Referencing to this thread Using webdav on Android
It is possible to use the Sardine lib ( http://code.google.com/p/sardine/) in combination with the httpclientandroidlib ( http://code.google.com/p/httpclientandroidlib/).
But I keep getting a java.lang.VerifyError Exception.
I tried to reference the Sardine lib as a jar file and as Eclipse-project but its always the same.
If i read the Messages from dalvikVM, before the exeption is thrown, there are problems with javax.xml.bind.JAXBContext.newInstance(). But i cant add the JAXB library or source to to the project because I get several Dx Errors:
[2011-10-28 16:48:40 - FireTablet] Dx 1 error; aborting
[2011-10-28 16:48:40 - FireTablet] Conversion to Dalvik format failed with error 1
[2011-10-28 16:49:00 - FireTablet] Dx
trouble processing "javax/xml/bind/PrintConversionEvent.class":
So this cant be the solution. Does anyone know how to run the sardine library on android?
I am very grateful for help!
Exceptions:
10-28 16:21:33.602: I/Process(22992): Sending signal. PID: 22992 SIG: 9
10-28 16:30:59.005: I/dalvikvm(23056): Could not find method javax.xml.bind.JAXBContext.newInstance, referenced from method com.googlecode.sardine.util.SardineUtil.<clinit>
10-28 16:30:59.005: W/dalvikvm(23056): VFY: unable to resolve static method 20578: Ljavax/xml/bind/JAXBContext;.newInstance ([Ljava/lang/Class;)Ljavax/xml/bind/JAXBContext;
10-28 16:30:59.005: D/dalvikvm(23056): VFY: replacing opcode 0x71 at 0x000a
10-28 16:30:59.005: W/dalvikvm(23056): VFY: unable to resolve exception class 2678 (Ljavax/xml/bind/JAXBException;)
10-28 16:30:59.005: W/dalvikvm(23056): VFY: unable to find exception handler at addr 0x50
10-28 16:30:59.005: W/dalvikvm(23056): VFY: rejected Lcom/googlecode/sardine/util/SardineUtil;.<clinit> ()V
10-28 16:30:59.005: W/dalvikvm(23056): VFY: rejecting opcode 0x0d at 0x0050
10-28 16:30:59.005: W/dalvikvm(23056): VFY: rejected Lcom/googlecode/sardine/util/SardineUtil;.<clinit> ()V
10-28 16:30:59.005: W/dalvikvm(23056): Verifier rejected class Lcom/googlecode/sardine/util/SardineUtil;
10-28 16:30:59.005: D/AndroidRuntime(23056): Shutting down VM
10-28 16:30:59.005: W/dalvikvm(23056): threadid=1: thread exiting with uncaught exception (group=0x40015578)
10-28 16:30:59.009: E/AndroidRuntime(23056): FATAL EXCEPTION: main
10-28 16:30:59.009: E/AndroidRuntime(23056): java.lang.VerifyError: com.googlecode.sardine.util.SardineUtil
10-28 16:30:59.009: E/AndroidRuntime(23056): at com.googlecode.sardine.impl.SardineImpl.list(SardineImpl.java:339)
10-28 16:30:59.009: E/AndroidRuntime(23056): at hsr.ifs.firetablet.network.WebDavConnector.getFacilityNames(WebDavConnector.java:36)
I use Android API-Level 10 & Java 1.6.

Not sure what's going on, but did you try https://github.com/yeonsh/Sardine-Android ?

I also had the same issue and modified the Sardine project to use SimpleXml instead of JAXB. Here is my version of the library: https://github.com/thegrizzlylabs/sardine-android

Related

DB didn't get created in Cordova

I have problem with my first application in Android Studio-Cordova.
I used for my application html,css, jquery and sql.
The application is correct, because I'm attending an on-line course with related code.
It starts, but the message of creating db isn't appeared.
the log of Android Studio is this:
Client not ready yet..Waiting for process to come online
Connected to process 2679 on device Nexus_5_API_19_armeabi_v7a [emulator-5554]
I/InstantRun: Instant Run Runtime started. Android package is com.videocorsi.test, real application class is null.
W/InstantRun: No instant run dex files added to classpath
I/CordovaLog: Changing log level to DEBUG(3)
I/CordovaActivity: Apache Cordova native platform version 6.0.0 is starting
D/CordovaActivity: CordovaActivity.onCreate()
I/dalvikvm: Could not find method android.app.Activity.checkSelfPermission, referenced from method org.apache.cordova.CordovaInterfaceImpl.hasPermission
W/dalvikvm: VFY: unable to resolve virtual method 2: Landroid/app/Activity;.checkSelfPermission (Ljava/lang/String;)I
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0023
I/dalvikvm: Could not find method android.app.Activity.requestPermissions, referenced from method org.apache.cordova.CordovaInterfaceImpl.requestPermissions
W/dalvikvm: VFY: unable to resolve virtual method 136: Landroid/app/Activity;.requestPermissions ([Ljava/lang/String;I)V
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0029
V/WebViewChromium: Binding Chromium to the background looper Looper (main, tid 1) {9dd95220}
I/chromium: [INFO:library_loader_hooks.cc(112)] Chromium logging enabled: level = 0, default verbosity = 0
I/BrowserProcessMain: Initializing chromium process, renderers=0
W/chromium: [WARNING:proxy_service.cc(888)] PAC support disabled because there is no system implementation
D/dalvikvm: GC_FOR_ALLOC freed 142K, 12% free 3463K/3892K, paused 86ms, total 88ms
I/dalvikvm-heap: Grow heap (frag case) to 6.078MB for 2536936-byte allocation
D/dalvikvm: GC_FOR_ALLOC freed 0K, 7% free 5941K/6372K, paused 58ms, total 58ms
I/dalvikvm: Could not find method android.webkit.CookieManager.setAcceptThirdPartyCookies, referenced from method org.apache.cordova.engine.SystemCookieManager.<init>
W/dalvikvm: VFY: unable to resolve virtual method 953: Landroid/webkit/CookieManager;.setAcceptThirdPartyCookies (Landroid/webkit/WebView;Z)V
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0046
I/dalvikvm: Could not find method android.webkit.CookieManager.flush, referenced from method org.apache.cordova.engine.SystemCookieManager.flush
W/dalvikvm: VFY: unable to resolve virtual method 947: Landroid/webkit/CookieManager;.flush ()V
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0019
W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/webkit/ClientCertRequest;)
W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/webkit/ClientCertRequest;)
I/dalvikvm: Could not find method android.webkit.WebViewClient.onReceivedClientCertRequest, referenced from method org.apache.cordova.engine.SystemWebViewClient.onReceivedClientCertRequest
W/dalvikvm: VFY: unable to resolve virtual method 1147: Landroid/webkit/WebViewClient;.onReceivedClientCertRequest (Landroid/webkit/WebView;Landroid/webkit/ClientCertRequest;)V
D/dalvikvm: VFY: replacing opcode 0x6f at 0x0031
W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/webkit/PermissionRequest;)
I/dalvikvm: Could not find method android.webkit.PermissionRequest.getResources, referenced from method org.apache.cordova.engine.SystemWebChromeClient.onPermissionRequest
W/dalvikvm: VFY: unable to resolve virtual method 964: Landroid/webkit/PermissionRequest;.getResources ()[Ljava/lang/String;
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0023
I/dalvikvm: Could not find method android.webkit.WebChromeClient$FileChooserParams.createIntent, referenced from method org.apache.cordova.engine.SystemWebChromeClient.onShowFileChooser
W/dalvikvm: VFY: unable to resolve virtual method 969: Landroid/webkit/WebChromeClient$FileChooserParams;.createIntent ()Landroid/content/Intent;
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0021
D/SystemWebViewEngine: CordovaWebView is running on device made by: unknown
D/PluginManager: init()
D/CordovaWebViewImpl: >>> loadUrl(file:///android_asset/www/index.html)
D/CordovaActivity: Started the activity.
D/CordovaActivity: Resumed the activity.
D/OpenGLRenderer: Enabling debug mode 0
I/Choreographer: Skipped 81 frames! The application may be doing too much work on its main thread.
W/AwContents: nativeOnDraw failed; clearing to background color.
W/AwContents: nativeOnDraw failed; clearing to background color.
W/AwContents: nativeOnDraw failed; clearing to background color.
W/AwContents: nativeOnDraw failed; clearing to background color.
D/CordovaWebViewImpl: onPageDidNavigate(file:///android_asset/www/index.html)
D/JsMessageQueue: Set native->JS mode to EvalBridgeMode
I/chromium: [INFO:async_pixel_transfer_manager_android.cc(56)] Async pixel transfers not supported
I/chromium: [INFO:async_pixel_transfer_manager_android.cc(56)] Async pixel transfers not supported
I/Choreographer: Skipped 74 frames! The application may be doing too much work on its main thread.
D/SystemWebChromeClient: file:///android_asset/www/cordova_plugins.js: Line 7 : Uncaught SyntaxError: Unexpected string
I/chromium: [INFO:CONSOLE(7)] "Uncaught SyntaxError: Unexpected string", source: file:///android_asset/www/cordova_plugins.js (7)
D/CordovaWebViewImpl: onPageFinished(file:///android_asset/www/index.html)
D/SystemWebChromeClient: file:///android_asset/www/js/index.js: Line 39 : Uncaught ReferenceError: listeningElement is not defined
I/chromium: [INFO:CONSOLE(39)] "Uncaught ReferenceError: listeningElement is not defined", source: file:///android_asset/www/js/index.js (39)
D/SystemWebChromeClient: file:///android_asset/www/index.html: Line 237 : Uncaught TypeError: Cannot call method 'transaction' of undefined
I/chromium: [INFO:CONSOLE(237)] "Uncaught TypeError: Cannot call method 'transaction' of undefined", source: file:///android_asset/www/index.html (237)
What Can I do?
the problem was in this file index.js . I had commented this:
receivedEvent: function(id) { var parentElement =document.getElementById(id);
// var listeningElement = parentElement.querySelector('.listening');
//var receivedElement = parentElement.querySelector('.received');
// listeningElement.setAttribute('style', 'display:none;'); //receivedElement.setAttribute('style', 'display:block;');
console.log('Received Event: ' + id); }
Then, I had move the tag script with my js/jquery code at the end of the tag

Error on startup android application (Titanium framework)

I've a problem with my Titanium Android application. The app works correctly in iOS, but not in Android.
I get the following error:
V8Object: (KrollRuntimeThread) [88,88] Runtime disposed, cannot set property 'userAgent'
[INFO] : dalvikvm: Could not find method android.app.Activity.checkSelfPermission, referenced from method ti.modules.titanium.media.MediaModule.hasCameraPermission
[INFO] : dalvikvm: Could not find method android.app.Activity.checkSelfPermission, referenced from method ti.modules.titanium.media.MediaModule.hasStoragePermission
[WARN] : dalvikvm: VFY: unable to resolve virtual method 27: Landroid/app/Activity;.checkSelfPermission (Ljava/lang/String;)I
[WARN] : dalvikvm: VFY: unable to resolve virtual method 27: Landroid/app/Activity;.checkSelfPermission (Ljava/lang/String;)I
[INFO] : dalvikvm: Could not find method android.app.Activity.checkSelfPermission, referenced from method ti.modules.titanium.media.MediaModule.hasCameraPermissions
[WARN] : dalvikvm: VFY: unable to resolve virtual method 27: Landroid/app/Activity;.checkSelfPermission (Ljava/lang/String;)I
[INFO] : dalvikvm: Could not find method android.app.Activity.requestPermissions, referenced from method ti.modules.titanium.media.MediaModule.requestCameraPermissions
[WARN] : dalvikvm: VFY: unable to resolve virtual method 80: Landroid/app/Activity;.requestPermissions ([Ljava/lang/String;I)V
[WARN] : dalvikvm: threadid=10: thread exiting with uncaught exception (group=0x41fe92a0)
Can anybody help me help me?
Sory for the previos unformatted message.I send a screenshot of log file.
android crashed log
This issue relates V8Object: (KrollRuntimeThread) Runtime disposed, cannot set property 'userAge. Check the link

NativeActivity and GooglePlayServices

I am trying to get a NativeActivity app to implement GooglePlayServices. I'm currently trying to do this by creating my own class that extends NativeActivity.
My Google Play services Revision is 18 shown in my Android SDK Manager. I am running on a device that is running Android API 10.
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="10"/>
Here is a snippet from my activity
public class KablamActivity extends NativeActivity {
#Override
protected void onResume(){
super.onResume();
GooglePlayServicesUtil.isGooglePlayServicesAvailable(this.getApplicationContext());
}
}
The following output is saying my Google Play services is out of date as well, but there is supposed to be a dialog popping up telling me something. What do I need to do to resolve the android.app.AlertDialog and android.app.Activity.getFragmentManager issues?
dalvikvm Could not find method android.app.AlertDialog$Builder.<init>, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.a
dalvikvm VFY: unable to resolve direct method 79: Landroid/app/AlertDialog$Builder;.<init> (Landroid/content/Context;I)V
dalvikvm VFY: replacing opcode 0x70 at 0x002c
dalvikvm Could not find method android.app.Activity.getFragmentManager, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.b
dalvikvm VFY: unable to resolve virtual method 28: Landroid/app/Activity;.getFragmentManager ()Landroid/app/FragmentManager;
dalvikvm VFY: replacing opcode 0x6e at 0x0023
dalvikvm VFY: dead code 0x0026-0030 in Lcom/google/android/gms/common/GooglePlayServicesUtil;.b (ILandroid/app/Activity;Landroid/support/v4/app/Fragment;ILandroid/content/DialogInterface$OnCancelListener;)Z
dalvikvm DexOpt: couldn't find field Landroid/content/res/Configuration;.smallestScreenWidthDp
dalvikvm VFY: unable to resolve instance field 53
dalvikvm VFY: replacing opcode 0x52 at 0x0012
dalvikvm VFY: dead code 0x0014-0018 in Lcom/google/android/gms/common/GooglePlayServicesUtil;.b (Landroid/content/res/Resources;)Z
GooglePlayServicesUtil Google Play services out of date. Requires 5077000 but found 4452034

try to access android.os.Build.SERIAL if available

Below is some code that I use to access Build.SERIAL static field, but it crashes when runs on Android 1.6!
// introduced in Android 2.3(API Level 9)
if (Integer.parseInt(android.os.Build.VERSION.SDK) >= android.os.Build.VERSION_CODES.GINGERBREAD) {
deviceID = android.os.Build.SERIAL; //cannot execute here if runs on Android 1.6!!!
}
That's the crash logs:
DexOpt: couldn't find static field
W/dalvikvm( 1098): VFY: unable to resolve static field 37 (SERIAL) in Landroid/os/Build;
W/dalvikvm( 1098): VFY: rejecting opcode 0x62 at 0x0001
W/dalvikvm( 1098): VFY: rejected Lcom/opera/mini/android/DisplayNotificationService;.getDeviceSerialID ()Ljava/lang/String;
W/dalvikvm( 1098): Verifier rejected class Lcom/opera/mini/android/DisplayNotificationService;
W/dalvikvm( 1098): Class init failed in newInstance call (Lcom/opera/mini/android/DisplayNotificationService;)
D/AndroidRuntime( 1098): Shutting down VM
W/dalvikvm( 1098): threadid=3: thread exiting with uncaught exception (group=0x4001da10)
E/AndroidRuntime( 1098): Uncaught handler: thread main exiting due to uncaught exception`
So how to resolve this problem?
If you check the Android documentation , android.os.Build.VERSION_CODES.GINGERBREAD is supported since API level 9 (Gingerbread). Remove it from the If condition and do the check another way. For e.g. check that if SDK is greater than DONUT, then do something else get the serial.
Update:
I mean try like this for e.g.:
if (Integer.parseInt(android.os.Build.VERSION.SDK) >= 9) {
deviceID = android.os.Build.SERIAL;
}
Use SDK_INT not SDK, as it's an integer not a string and removes the comparison issues you are suffering from.
This works for me:
if(Build.VERSION.SDK_INT >= 9){
deviceID = android.os.Build.SERIAL;
}
Use Build.VERSION.SDK_INT instead of Integer.parseInt(android.os.Build.VERSION.SDK) then check it by numbers like Build.VERSION.SDK_INT>9

Why can disabling obfuscation in ProGuard break the optimization step?

We've recently decided to disable code obfuscation in our Android build, since while it makes the final APK slightly larger, it makes debugging so much more difficult.
Ever since we've done that, I keep running into crashes in our app that were not present before, i.e. while obfuscation was still active. Usually these crashes are caused by Java VerifyErrors or NoSuchMethodErrors.
Here are two of these errors I suddenly see when I disable obfuscation:
Could not find method org.apache.http.HttpConnectionMetrics.getResponseCount, referenced from method com.google.android.apps.analytics.PipelinedRequester.sendRequests
W/dalvikvm( 6652): VFY: unable to resolve virtual method 16112: Lorg/apache/http/HttpConnectionMetrics;.getResponseCount ()J
W/dalvikvm( 6652): VFY: rejecting opcode 0x6e at 0x000c
W/dalvikvm( 6652): VFY: rejected Lcom/google/android/apps/analytics/PipelinedRequester;.sendRequests ()V
W/dalvikvm( 6652): Verifier rejected class Lcom/google/android/apps/analytics/PipelinedRequester;
D/dalvikvm( 6652): GC_CONCURRENT freed 253K, 46% free 3261K/6023K, external 0K/0K, paused 2ms+2ms
I/dalvikvm( 6652): Rejecting re-init on previously-failed class Lcom/google/android/apps/analytics/PipelinedRequester; v=0x4062de30
D/AndroidRuntime( 6652): Shutting down VM
W/dalvikvm( 6652): threadid=1: thread exiting with uncaught exception (group=0x400a7560)
E/AndroidRuntime( 6652): FATAL EXCEPTION: main
E/AndroidRuntime( 6652): java.lang.VerifyError: com/google/android/apps/analytics/PipelinedRequester
...
I could resolve this error by disabling class merging via !class/merging/*
Another error I was seeing was this:
I/dalvikvm( 7292): DexOpt: access denied from Lcom/urbanairship/analytics/EventUploadManager; to field Lorg/apache/http/entity/AbstractHttpEntity;.contentEncoding
W/dalvikvm( 7292): VFY: unable to resolve instance field 5188
D/dalvikvm( 7292): VFY: replacing opcode 0x5b at 0x00ec
I/dalvikvm( 7292): Could not find method org.apache.http.conn.scheme.PlainSocketFactory.<init>, referenced from method com.google.android.apps.analytics.PipelinedRequester.<init>
W/dalvikvm( 7292): VFY: unable to resolve direct method 15044: Lorg/apache/http/conn/scheme/PlainSocketFactory;.<init> (B)V
D/dalvikvm( 7292): VFY: replacing opcode 0x70 at 0x0003
D/dalvikvm( 7292): VFY: dead code 0x0006-0009 in Lcom/google/android/apps/analytics/PipelinedRequester;.<init> (Lorg/apache/http/HttpHost;)V
I/dalvikvm( 7292): DexOpt: access denied from Lcom/google/android/apps/analytics/PipelinedRequester; to field Lorg/apache/http/impl/SocketHttpClientConnection;.open
W/dalvikvm( 7292): VFY: unable to resolve instance field 5234
D/dalvikvm( 7292): VFY: replacing opcode 0x55 at 0x0006
D/dalvikvm( 7292): VFY: dead code 0x0008-000e in Lcom/google/android/apps/analytics/PipelinedRequester;.closeConnection ()V
D/dalvikvm( 7292): VFY: dead code 0x0010-0011 in Lcom/google/android/apps/analytics/PipelinedRequester;.closeConnection ()V
I/dalvikvm( 7292): DexOpt: access denied from Lcom/google/android/apps/analytics/PipelinedRequester; to field Lorg/apache/http/impl/SocketHttpClientConnection;.open
W/dalvikvm( 7292): VFY: unable to resolve instance field 5234
D/dalvikvm( 7292): VFY: replacing opcode 0x55 at 0x0006
D/dalvikvm( 7292): VFY: dead code 0x0008-0009 in Lcom/google/android/apps/analytics/PipelinedRequester;.addRequest (Lorg/apache/http/HttpEntityEnclosingRequest;)V
D/dalvikvm( 7292): GC_CONCURRENT freed 253K, 47% free 3251K/6023K, external 0K/0K, paused 2ms+3ms
I/dalvikvm( 7292): DexOpt: access denied from Lcom/google/android/apps/analytics/PipelinedRequester; to field Lorg/apache/http/impl/AbstractHttpClientConnection;.metrics
W/dalvikvm( 7292): VFY: unable to resolve instance field 5225
D/dalvikvm( 7292): VFY: replacing opcode 0x54 at 0x0008
D/dalvikvm( 7292): VFY: dead code 0x000a-0090 in Lcom/google/android/apps/analytics/PipelinedRequester;.sendRequests ()V
D/AndroidRuntime( 7292): Shutting down VM
W/dalvikvm( 7292): threadid=1: thread exiting with uncaught exception (group=0x400a7560)
E/AndroidRuntime( 7292): FATAL EXCEPTION: main
E/AndroidRuntime( 7292): java.lang.NoSuchMethodError: org.apache.http.conn.scheme.PlainSocketFactory.<init>
This one I could resolve by setting !method/propagation/*
But why do these problems only appear with obfuscation disabled? Shouldn't one have no impact on the other?
The obfuscation was saving you because it was renaming your copies of the Apache HttpClient classes to names that wouldn't collide with the copies of those classes already present in Android.
Nasty place to be... you might want to consider not using Apache HttpClient at all, and using the in-built HttpURLConnection class as suggested by Jesse Wilson:
http://android-developers.blogspot.com/2011/09/androids-http-clients.html
You could try this Android-friendly veneer on HttpURLConnection:
https://github.com/kevinsawicki/http-request
If you really have to use Apache HttpClient, either use the old version embedded in Android, or try tweaking your ProGuard configuration to just obfuscate the HttpClient libraries.

Categories

Resources