Why can disabling obfuscation in ProGuard break the optimization step? - android

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.

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

RecyclerView with view pager

I have a working piece of code which works when built on other machines but if i build using my machine, the adapter does not show up. No elements of the adapter are populated.
I have RecyclerView inside a ViewPager.
I have updated SDK and Android Studio as well.
LOGS
05-30 16:13:15.637 17918-17918/ E/ViewRootImpl: sendUserActionEvent() mView == null
05-30 16:13:15.877 17918-17922/ D/dalvikvm: GC_CONCURRENT freed 630K, 17% free 9656K/11592K, paused 12ms+4ms, total 39ms
05-30 16:13:15.887 17918-17918/ I/dalvikvm: Could not find method android.widget.LinearLayout$LayoutParams.<init>, referenced from method android.support.design.widget.AppBarLayout$LayoutParams.<init>
05-30 16:13:15.887 17918-17918/ W/dalvikvm: VFY: unable to resolve direct method 19614: Landroid/widget/LinearLayout$LayoutParams;.<init> (Landroid/widget/LinearLayout$LayoutParams;)V
05-30 16:13:15.887 17918-17918/ D/dalvikvm: VFY: replacing opcode 0x70 at 0x0000
05-30 16:13:15.897 17918-17918/ I/dalvikvm: Could not find method android.widget.LinearLayout$LayoutParams.<init>, referenced from method android.support.design.widget.AppBarLayout$LayoutParams.<init>
05-30 16:13:15.897 17918-17918/ W/dalvikvm: VFY: unable to resolve direct method 19614: Landroid/widget/LinearLayout$LayoutParams;.<init> (Landroid/widget/LinearLayout$LayoutParams;)V
05-30 16:13:15.897 17918-17918/ D/dalvikvm: VFY: replacing opcode 0x70 at 0x0000
Please help
I think your build.gradle is missing design dependency,
try compiling this dependency
com.android.support:design:23.4.0
in your build.gradle

NoClassDefFoundError for .jar library at runtime in Android Studio

Hi Friends at Stack Overflow
I recently run into a problem when implementing Fiksu SDK in my Android app. A brief intro, Fiksu SDK is a marketing tool to register installation and events. All the methods related to Fiksu is in a .jar file called "ASOTracking.jar"
The problem:
The library is setup correctly, there is no error reported by Gradle when project compiles and I can even make debug apk. However, it throws "java.lang.NoClassDefFoundError" at runtime when it tries to initialize the SDK.
The log:
01-27 14:06:54.801 31166-31166/com.example.myapp I/dalvikvm﹕ Could not find method com.fiksu.asotracking.FiksuDeviceSettingsManager.getInstance, referenced from method com.fiksu.asotracking.FiksuTrackingManager.getClientId
01-27 14:06:54.801 31166-31166/com.example.myapp W/dalvikvm﹕ VFY: unable to resolve static method 13738: Lcom/fiksu/asotracking/FiksuDeviceSettingsManager;.getInstance ()Lcom/fiksu/asotracking/FiksuDeviceSettingsManager;
01-27 14:06:54.801 31166-31166/com.example.myapp D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x0000
01-27 14:06:54.806 31166-31166/com.example.myapp I/dalvikvm﹕ Could not find method com.fiksu.asotracking.FiksuConfigurationManager.getInstance, referenced from method com.fiksu.asotracking.FiksuTrackingManager.initialize
01-27 14:06:54.806 31166-31166/com.example.myapp W/dalvikvm﹕ VFY: unable to resolve static method 13733: Lcom/fiksu/asotracking/FiksuConfigurationManager;.getInstance ()Lcom/fiksu/asotracking/FiksuConfigurationManager;
01-27 14:06:54.806 31166-31166/com.example.myapp D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x000f
01-27 14:06:54.806 31166-31166/com.example.myapp I/dalvikvm﹕ Could not find method com.fiksu.asotracking.FiksuDeviceSettingsManager.getInstance, referenced from method com.fiksu.asotracking.FiksuTrackingManager.isAppTrackingEnabled
01-27 14:06:54.806 31166-31166/com.example.myapp W/dalvikvm﹕ VFY: unable to resolve static method 13738: Lcom/fiksu/asotracking/FiksuDeviceSettingsManager;.getInstance ()Lcom/fiksu/asotracking/FiksuDeviceSettingsManager;
01-27 14:06:54.806 31166-31166/com.example.myapp D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x0000
01-27 14:06:54.806 31166-31166/com.example.myapp I/dalvikvm﹕ Could not find method com.fiksu.asotracking.FiksuDeviceSettingsManager.getInstance, referenced from method com.fiksu.asotracking.FiksuTrackingManager.setAppTrackingEnabled
01-27 14:06:54.806 31166-31166/com.example.myapp W/dalvikvm﹕ VFY: unable to resolve static method 13738: Lcom/fiksu/asotracking/FiksuDeviceSettingsManager;.getInstance ()Lcom/fiksu/asotracking/FiksuDeviceSettingsManager;
01-27 14:06:54.806 31166-31166/com.example.myapp D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x0010
01-27 14:06:54.806 31166-31166/com.example.myapp I/dalvikvm﹕ Could not find method com.fiksu.asotracking.FiksuDeviceSettingsManager.getInstance, referenced from method com.fiksu.asotracking.FiksuTrackingManager.setClientId
01-27 14:06:54.806 31166-31166/com.example.myapp W/dalvikvm﹕ VFY: unable to resolve static method 13738: Lcom/fiksu/asotracking/FiksuDeviceSettingsManager;.getInstance ()Lcom/fiksu/asotracking/FiksuDeviceSettingsManager;
01-27 14:06:54.806 31166-31166/com.example.myapp D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x0010
01-27 14:06:54.806 31166-31166/com.example.myapp I/dalvikvm﹕ Could not find method com.fiksu.asotracking.FiksuConfigurationManager.getInstance, referenced from method com.fiksu.asotracking.FiksuTrackingManager.setDebugModeEnabled
01-27 14:06:54.806 31166-31166/com.example.myapp W/dalvikvm﹕ VFY: unable to resolve static method 13733: Lcom/fiksu/asotracking/FiksuConfigurationManager;.getInstance ()Lcom/fiksu/asotracking/FiksuConfigurationManager;
01-27 14:06:54.806 31166-31166/com.example.myapp D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x0001
01-27 14:06:54.806 31166-31166/com.example.myapp E/dalvikvm﹕ Could not find class 'com.fiksu.asotracking.CustomEventTracker', referenced from method com.fiksu.asotracking.FiksuTrackingManager.uploadCustomEvent
01-27 14:06:54.806 31166-31166/com.example.myapp W/dalvikvm﹕ VFY: unable to resolve new-instance 2112 (Lcom/fiksu/asotracking/CustomEventTracker;) in Lcom/fiksu/asotracking/FiksuTrackingManager;
01-27 14:06:54.806 31166-31166/com.example.myapp D/dalvikvm﹕ VFY: replacing opcode 0x22 at 0x000f
01-27 14:06:54.806 31166-31166/com.example.myapp E/dalvikvm﹕ Could not find class 'com.fiksu.asotracking.PurchaseEventTracker', referenced from method com.fiksu.asotracking.FiksuTrackingManager.uploadPurchase
01-27 14:06:54.806 31166-31166/com.example.myapp W/dalvikvm﹕ VFY: unable to resolve new-instance 2125 (Lcom/fiksu/asotracking/PurchaseEventTracker;) in Lcom/fiksu/asotracking/FiksuTrackingManager;
01-27 14:06:54.806 31166-31166/com.example.myapp D/dalvikvm﹕ VFY: replacing opcode 0x22 at 0x0022
01-27 14:06:54.806 31166-31166/com.example.myapp E/dalvikvm﹕ Could not find class 'com.fiksu.asotracking.PurchaseEventTracker', referenced from method com.fiksu.asotracking.FiksuTrackingManager.uploadPurchaseEvent
01-27 14:06:54.806 31166-31166/com.example.myapp W/dalvikvm﹕ VFY: unable to resolve new-instance 2125 (Lcom/fiksu/asotracking/PurchaseEventTracker;) in Lcom/fiksu/asotracking/FiksuTrackingManager;
01-27 14:06:54.806 31166-31166/com.example.myapp D/dalvikvm﹕ VFY: replacing opcode 0x22 at 0x0014
01-27 14:06:54.806 31166-31166/com.example.myapp E/dalvikvm﹕ Could not find class 'com.fiksu.asotracking.RegistrationEventTracker', referenced from method com.fiksu.asotracking.FiksuTrackingManager.uploadRegistration
01-27 14:06:54.806 31166-31166/com.example.myapp W/dalvikvm﹕ VFY: unable to resolve new-instance 2126 (Lcom/fiksu/asotracking/RegistrationEventTracker;) in Lcom/fiksu/asotracking/FiksuTrackingManager;
01-27 14:06:54.806 31166-31166/com.example.myapp D/dalvikvm﹕ VFY: replacing opcode 0x22 at 0x001e
01-27 14:06:54.806 31166-31166/com.example.myapp E/dalvikvm﹕ Could not find class 'com.fiksu.asotracking.RegistrationEventTracker', referenced from method com.fiksu.asotracking.FiksuTrackingManager.uploadRegistrationEvent
01-27 14:06:54.806 31166-31166/com.example.myapp W/dalvikvm﹕ VFY: unable to resolve new-instance 2126 (Lcom/fiksu/asotracking/RegistrationEventTracker;) in Lcom/fiksu/asotracking/FiksuTrackingManager;
01-27 14:06:54.806 31166-31166/com.example.myapp D/dalvikvm﹕ VFY: replacing opcode 0x22 at 0x0010
01-27 14:06:54.806 31166-31166/com.example.myapp D/dalvikvm﹕ DexOpt: unable to opt direct call 0x35ce at 0x2b in Lcom/fiksu/asotracking/FiksuTrackingManager;.initialize
01-27 14:06:54.806 31166-31166/com.example.myapp D/dalvikvm﹕ DexOpt: unable to opt direct call 0x35c5 at 0x2e in Lcom/fiksu/asotracking/FiksuTrackingManager;.initialize
01-27 14:06:54.811 31166-31166/com.example.myapp D/dalvikvm﹕ DexOpt: unable to opt direct call 0x359b at 0x15 in Lcom/fiksu/asotracking/FiksuTrackingManager;.uploadCustomEvent
01-27 14:06:54.811 31166-31166/com.example.myapp D/dalvikvm﹕ DexOpt: unable to opt direct call 0x35cf at 0x30 in Lcom/fiksu/asotracking/FiksuTrackingManager;.uploadPurchase
01-27 14:06:54.811 31166-31166/com.example.myapp D/dalvikvm﹕ DexOpt: unable to opt direct call 0x35cf at 0x23 in Lcom/fiksu/asotracking/FiksuTrackingManager;.uploadPurchaseEvent
01-27 14:06:54.811 31166-31166/com.example.myapp D/dalvikvm﹕ DexOpt: unable to opt direct call 0x35d1 at 0x26 in Lcom/fiksu/asotracking/FiksuTrackingManager;.uploadRegistration
01-27 14:06:54.811 31166-31166/com.example.myapp I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x1507 at 0x16 in Lcom/fiksu/asotracking/FiksuTrackingManager;.uploadRegistrationEvent
01-27 14:06:54.811 31166-31166/com.example.myapp D/dalvikvm﹕ DexOpt: unable to opt direct call 0x35d1 at 0x19 in Lcom/fiksu/asotracking/FiksuTrackingManager;.uploadRegistrationEvent
01-27 14:06:54.811 31166-31166/com.example.myapp D/AndroidRuntime﹕ Shutting down VM
01-27 14:06:54.811 31166-31166/com.example.myapp W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41ecb700)
01-27 14:06:54.821 31166-31166/com.example.myapp E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.fiksu.asotracking.FiksuConfigurationManager
at com.fiksu.asotracking.FiksuTrackingManager.initialize(FiksuTrackingManager.java:83)
at com.example.userinterface.MyApplication.onCreate(MyApplication.java:56)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4684)
at android.app.ActivityThread.access$1400(ActivityThread.java:159)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1376)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5419)
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:1187)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
at dalvik.system.NativeStart.main(Native Method)
My local environment:
Project is developed on Android Studio
I'm using Mac OS X 10.8.5 Mountain Lion
compileSdkVersion 21, buildToolsVersion "21.1.2",
gradleVersion = '2.2.1', com.android.tools.build:gradle:1.0.0
This is a multi-module project. Application module calls "userInterface" library module and this SDK lies in this library module.
What I've tried:
I do make sure the SDK (jar) file is properly setup and there is no compile error reported by Gradle
I make sure there is no syntax error at the places where SDK methods is called
I checked the dependency of the module that calls this SDK to make sure there is no dependency problem. I go so far that I even trim the whole dependency tree (I know it's unnecessary).
I tried deleting the "build" directory of all modules and rebuild the whole project
I performed the "Invalidate Cache/Restart" operation in Android Studio
I performed "./gradlew clean" command via Terminal at both root directory and application module directory.
I consulted the following links in STO with no success:
Android Studio - Importing external Library/Jar
Android Studio: Add jar as library?
Android studio Gradle Could not find method compile()
Getting "Caused by: java.lang.VerifyError:"
Unable to find classes in Android library file
NoClassDefFoundError with libraries in Android Studio
Final thoughts:
I need some serious help because I've tried everything I know. This SDK worked fine before I migrated this project from Eclipse. Now it throws weird exception when running in Android Studio.
There is one last thing that's kinda suspicious --- the classpath file in Android Studio (the ***.imi file), I re-arrange the classpath entries in it and it still doesn't work.
Thank you guys advance for your help!
New Findings
My GS4 (Android 4.3) cannot run this app, but HTC One M8 (Android 5.0.1) can run it
Root Cause
65K methods limit
Refer to this document: https://developer.android.com/tools/building/multidex.html
Basically there is a methods reference limit and the only solution is to use multidex configuration. However there are implementation for platforms prior 5.0 and after 5.0
Solution
The solution is described in both:
https://developer.android.com/tools/building/multidex.html
https://developer.android.com/reference/android/support/multidex/MultiDexApplication.html
For my project, since it supports older version of Android, I go with the "multidex support library" solution.
Set the build tool version of all library modules and app module to the latest 21.1.2
For module that has Application class, add compile 'com.android.support:multidex:1.0.0' as dependency
Refer to this link to modify your application class. https://developer.android.com/reference/android/support/multidex/MultiDexApplication.html
At the same gradle script, under android -> defaultConfig block, add "multiDexEnabled true"
If your system gives "Java Heap Size" error, in the app module's gradle script, add the following
dexOptions {
incremental true
javaMaxHeapSize "4g"
}

Could not find class 'com.google.android.maps.GeoPoint', referenced from method

I have one user running my app getting the following error, which I can't reproduce on my phone or I haven't see on any other phone.
Can any one suggest why this isn't working just for this user, they say that the Googlemaps app works fine.
Note I have Google API and maps in my manifest too.
E/dalvikvm( 1978): Could not find class 'com.google.android.maps.GeoPoint', referenced from method id.wilsononline.gcadroid.gcadroid$loadNearby.<init>
W/dalvikvm( 1978): VFY: unable to resolve new-instance 522 (Lcom/google/android/maps/GeoPoint;) in Lid/wilsononline/gcadroid/gcadroid$loadNearby;
D/dalvikvm( 1978): VFY: replacing opcode 0x22 at 0x006b
D/dalvikvm( 1978): DexOpt: unable to opt direct call 0x0de1 at 0x7d in Lid/wilsononline/gcadroid/gcadroid$loadNearby;.<init>
W/dalvikvm( 1978): VFY: unable to find class referenced in signature (Lcom/google/android/maps/GeoPoint;)
W/dalvikvm( 1978): VFY: unable to find class referenced in signature (Lcom/google/android/maps/GeoPoint;)
W/dalvikvm( 1978): VFY: unable to find class referenced in signature (Lcom/google/android/maps/GeoPoint;)
I/dalvikvm( 1978): Could not find method com.google.android.maps.GeoPoint.getLatitudeE6, referenced from method id.wilsononline.gcadroid.gaLoadNearbyCaches.startLoadCaches
W/dalvikvm( 1978): VFY: unable to resolve virtual method 3554: Lcom/google/android/maps/GeoPoint;.getLatitudeE6 ()I
D/dalvikvm( 1978): VFY: replacing opcode 0x6e at 0x0004

Issues with Google Play Game Services occupying Android Res folder & Web API alternative?

So we're in the middle of development of our Unity based game for Android. We had Facebook authentication already implemented and this makes use of the Android/Res folder. It stores some values and images there.
While trying to implement Google Play SDK for Authentication, Leaderboards, Achievements.... we came to realize it too makes use of the Android/Res folder which apparently causes a crash and not currently possible.
We're curious about 2 options
1) is there any possible way to allow 2 different services to make use of the Android resource system? Please note we're using Unity, and the plugin is made by Prime31.
If the source for the library is released then it could be possible to modify so the resource folder isn't used.
2) If we're stuck not being able to have Facebook and Google Play Services co-exist then is the entire process possible via REST JSON access? How is the Google+ sign in performed with our app launching a browser or Google+ app to securely take in credentials?
See our error log below
W/PopupManager(11358): You have not specified a View to use as content view for popups. Falling back to the Activity content view which may not work properly in future versions of the API. Use setViewForPopups() to set your content view.W/dalvikvm(11358): VFY: unable to resolve static field 1994 (common_google_play_services_install_title) in Lcom/google/android/gms/R$string;
D/dalvikvm(11358): VFY: replacing opcode 0x60 at 0x0041
W/dalvikvm(11358): VFY: unable to resolve static field 1990 (common_google_play_services_enable_title) in Lcom/google/android/gms/R$string;
D/dalvikvm(11358): VFY: replacing opcode 0x60 at 0x004c
W/dalvikvm(11358): VFY: unable to resolve static field 2000 (common_google_play_services_update_title) in Lcom/google/android/gms/R$string;
D/dalvikvm(11358): VFY: replacing opcode 0x60 at 0x0057
W/dalvikvm(11358): VFY: unable to resolve static field 1997 (common_google_play_services_unsupported_title) in Lcom/google/android/gms/R$string;
D/dalvikvm(11358): VFY: replacing opcode 0x60 at 0x0069
W/dalvikvm(11358): VFY: unable to resolve static field 1991 (common_google_play_services_install_button) in Lcom/google/android/gms/R$string;
D/dalvikvm(11358): VFY: replacing opcode 0x60 at 0x0009
W/dalvikvm(11358): VFY: unable to resolve static field 1988 (common_google_play_services_enable_button) in Lcom/google/android/gms/R$string;
D/dalvikvm(11358): VFY: replacing opcode 0x60 at 0x0010
W/dalvikvm(11358): VFY: unable to resolve static field 1998 (common_google_play_services_update_button) in Lcom/google/android/gms/R$string;
D/dalvikvm(11358): VFY: replacing opcode 0x60 at 0x0017
W/dalvikvm(11358): VFY: unable to resolve static field 1995 (common_google_play_services_unknown_issue) in Lcom/google/android/gms/R$string;
D/dalvikvm(11358): VFY: replacing opcode 0x60 at 0x0004
I/dalvikvm(11358): DexOpt: unable to optimize static field ref 0x07c9 at 0x18 in Lcom/google/android/gms/common/GooglePlayServicesUtil;.b
I/dalvikvm(11358): DexOpt: unable to optimize static field ref 0x07c8 at 0x38 in Lcom/google/android/gms/common/GooglePlayServicesUtil;.b
I/dalvikvm(11358): DexOpt: unable to optimize static field ref 0x07c5 at 0x3f in Lcom/google/android/gms/common/GooglePlayServicesUtil;.b
I/dalvikvm(11358): DexOpt: unable to optimize static field ref 0x07cf at 0x46 in Lcom/google/android/gms/common/GooglePlayServicesUtil;.b
I/dalvikvm(11358): DexOpt: unable to optimize static field ref 0x07cc at 0x66 in Lcom/google/android/gms/common/GooglePlayServicesUtil;.b
D/Prime31 (11358): onConnectionFailed: result 4
D/Prime31 (11358): onConnectionFailed: since user didn't initiate sign-in, failing now.
D/dalvikvm(11358): GC_CONCURRENT freed 430K, 5% free 9477K/9936K, paused 2ms+2ms, total 27ms
I/Unity (11358): authenticationFailedEvent: Unknown error
I/Unity (11358):
I/Unity (11358): (Filename: ./Runtime/ExportGenerated/AndroidManaged/UnityEngineDebug.cpp Line: 54)
I/Unity (11358):
E/Prime31 (11358): Exception running command on UI thread: Not connected. Call connect() and wait for onConnected() to be called.
D/dalvikvm(11358): GC_CONCURRENT freed 385K, 5% free 9477K/9936K, paused 2ms+2ms, total 27ms
D/dalvikvm( 6765): GC_CONCURRENT freed 417K, 7% free 9483K/10172K, paused 7ms+2ms, total 32ms
E/Prime31 (11358): Exception running command on UI thread: Not connected. Call connect() and wait for onConnected() to be called.
D/dalvikvm(11358): GC_CONCURRENT freed 385K, 5% free 9478K/9936K, paused 2ms+2ms, total 29ms
D/dalvikvm(11358): GC_CONCURRENT freed 387K, 5% free 9478K/9936K, paused 6ms+1ms, total 62ms
D/Prime31 (11358): isGooglePlayServicesAvailable returned 0
D/Prime31 (11358): beginUserInitiatedSignIn: continuing pending sign-in flow.
D/Prime31 (11358): resolveConnectionResult: trying to resolve result: ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{423c8fe8: android.os.BinderProxy#423c8f88}}
D/Prime31 (11358): --------------------- result has resolution. Starting it. --------------------
I/ActivityManager( 506): START u0 {cmp=com.phyken.wizardopstactics/com.prime31.PlayServicesProxyActivity} from pid 11358
D/dalvikvm(11358): GC_CONCURRENT freed 384K, 5% free 9481K/9936K, paused 5ms+4ms, total 80ms
1) There isn't any problem in two services using the resources folder. All the resources will be on the final APK, just pay attention on the resources names so they don't conflict. The best practice is to use a suffix (example: fb_logo.png and google_logo.png, instead of two logo.png images)
2) Not needed!
If you posted the error log it would have been easier to help and point the exact issue!

Categories

Resources