How work around java.lang.verifyerror in Android - java

I have an app which works perfect in all 4.x devices, but now I have a report of the app not working on a samsung_gt (advance) android 2.3.6. Here is the trace:
FATAL EXCEPTION: main
java.lang.VerifyError: com.bamobile.fdtks.activities.MainActivity
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1409)
at android.app.Instrumentation.newActivity(Instrumentation.java:1024)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1573)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
at android.app.ActivityThread.access$1500(ActivityThread.java:121)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3770)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
at dalvik.system.NativeStart.main(Native Method)
I have the latest support jar (v4) and have already patched the gson library in case the phone is already using it. The problem seems to be the the support lib. Any ideas? Thank you very much!

The most common cause of java.lang.VerifyError is having a class that uses methods that are not available on the version of Android where the app is running.
Based on your stacktrace, it seems that com.bamobile.fdtks.activities.MainActivity is using a method that is not available on Android 2.3.6, hence the "verification error" that you're seeing.
To fix it, change the minSdkVersion and of your app to 9 or 10 (Android 2.3.6) and look for errors/warnings about unsupported methods for that version of Android. You can also change (temporarily) both minSdkVersion and targetSdkVersion to 9 to force the compiler to fail when you use methods that are not found in Gingerbread devices.

Related

Android app doesn't login by error: org/postgresql/jdbc/TimestampUtils

when I try to do login in my android app occurs the following error:
java.lang.VerifyError: org/postgresql/jdbc/TimestampUtils
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:279)
at org.postgresql.Driver.makeConnection(Driver.java:450)
at org.postgresql.Driver.connect(Driver.java:252)
at java.sql.DriverManager.getConnection(DriverManager.java:175)
at com.j256.ormlite.jdbc.JdbcConnectionSource.makeConnection(JdbcConnectionSource.java:266)
at com.j256.ormlite.jdbc.JdbcConnectionSource.getReadWriteConnection(JdbcConnectionSource.java:187)
at com.j256.ormlite.jdbc.JdbcConnectionSource.getReadOnlyConnection(JdbcConnectionSource.java:172)
at com.j256.ormlite.stmt.StatementExecutor.buildIterator(StatementExecutor.java:243)
at com.j256.ormlite.stmt.StatementExecutor.query(StatementExecutor.java:197)
at com.j256.ormlite.dao.BaseDaoImpl.query(BaseDaoImpl.java:277)
at com.j256.ormlite.stmt.QueryBuilder.query(QueryBuilder.java:366)
at com.j256.ormlite.stmt.Where.query(Where.java:480)
at com.j256.ormlite.dao.BaseDaoImpl.queryForEq(BaseDaoImpl.java:253)
at com.discurs.app.login.LoginFragment$1.onClick(LoginFragment.java:61)
at android.view.View.performClick(View.java:4209)
at android.view.View$PerformClick.run(View.java:17431)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:5297)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
Some code:
ConnectionSource connectionSource = new PostgreSqlDBHelper().createConnectionSource();
Dao<UserVO, String> userDAO = DaoManager.createDao(connectionSource, UserVO.class);
List<UserVO> listUserVO = userDAO.queryForEq("username", userName.getText().toString().toLowerCase());
I use Ormlite to manage all database connections. All methods are from ormlite framework.
I cannot find any information about this error: java.lang.VerifyError: org/postgresql/jdbc/TimestampUtils
The minimum API version of the app is 16 (Jelly Bean)
I have done test (with physical and virtual devices) with all API's available since the minimum of my app.
The conclusion is that crash with:
Android Jelly Bean (API version: 16/17/18)
Android KitKat (API version: 19/20)
The next versions of android works correctly.
Please help me to find some solution or any idea of why it's occurs.
Thank you

Crash on Android 2.3.3 after upgrading to support library 25.0.0 (java.lang.NoSuchMethodError: android.view.View.isAttachedToWindow)

After upgrading to the latest version of the support library, I'm no longer able to run the app on Android 2.3.3. The app crashes during startup with the
11-01 13:53:16.580 2115-2115/no.bouvet.routeplanner.atb E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NoSuchMethodError: android.view.View.isAttachedToWindow
at android.support.v7.widget.ForwardingListener$2.(ForwardingListener.java:102)
at android.support.v7.widget.ForwardingListener.addDetachListenerBase(ForwardingListener.java:101)
at android.support.v7.widget.ForwardingListener.(ForwardingListener.java:78)
at android.support.v7.widget.ActionMenuPresenter$OverflowMenuButton$1.(ActionMenuPresenter.java:650)
at android.support.v7.widget.ActionMenuPresenter$OverflowMenuButton.(ActionMenuPresenter.java:650)
at android.support.v7.widget.ActionMenuPresenter.initForMenu(ActionMenuPresenter.java:114)
at android.support.v7.view.menu.MenuBuilder.addMenuPresenter(MenuBuilder.java:262)
at android.support.v7.widget.ActionMenuView.getMenu(ActionMenuView.java:656)
at android.support.v7.widget.Toolbar.ensureMenu(Toolbar.java:1037)
at android.support.v7.widget.Toolbar.getMenu(Toolbar.java:1008)
at android.support.v7.widget.ToolbarWidgetWrapper.getMenu(ToolbarWidgetWrapper.java:676)
at android.support.v7.app.ToolbarActionBar.getMenu(ToolbarActionBar.java:595)
at android.support.v7.app.ToolbarActionBar.populateOptionsMenu(ToolbarActionBar.java:447)
at android.support.v7.app.ToolbarActionBar$1.run(ToolbarActionBar.java:61)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
The dependencies used are:
compile 'com.android.support:support-v4:25.0.0'
compile 'com.android.support:support-compat:25.0.0'
compile 'com.android.support:support-core-ui:25.0.0'
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:preference-v7:24.2.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services-maps:9.6.1'
compile 'com.android.support:design:24.2.1'
compile 'com.google.maps.android:android-maps-utils:0.4'
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support:recyclerview-v7:24.2.1'
The error disappears of I downgrade to 24.2.2, but this causes other problems (when using the default android searchview, the text that the user enters is not visible, even though the autocomplete works fine)
I assume this is a bug in the support library. Have anyone seen the same problem and know of a fix?
It's an issue with Support Library 25.0.0:https://code.google.com/p/android/issues/detail?id=225647.
You can reproduce the issue by creating a new project and using the standard Basic Activity template in Android Studio. The app will crash on setSupportActionBar(toolbar); on devices API 11 and below.
I didn't find another solution except to downgrade support library version.
The problem is solved with new realease:
Android Support Library, revision 25.0.1 (November 2016)
https://developer.android.com/topic/libraries/support-library/revisions.html

NoClassDefFoundError: com.parse.ParseObject$1

I'm Running into a NoClassDefFoundError on Android 4.4, 4.3, and 4.2. I've tried all day to fix it to no avail. I've tried changing the targetSdkVersion, Parse version, importing the Parse library with a jar instead of Gradle, and cleaning and rebuilding the project. Everything works on Android 5.0 and up.
I'm using Parse version 1.12.0
CompileSdkVersion 23
buildToolsVersion 23.0.2
minSdkVersion 17
targetSdkVersion 23
Here is my stack trace. It crashes on the first attempt to register a subclass of ParseObject.
01-13 12:18:26.500 1347-1347/? E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.parse.ParseObject$1
at com.parse.ParseObject.<clinit>(ParseObject.java:316)
at com.company.myapp.utils.Application.onCreate(PensterApplication.java:36)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4444)
at android.app.ActivityThread.access$1300(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
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:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Here is the Application class where it crashes.
I've altered the class names to post online here
public class myApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
FacebookSdk.sdkInitialize(this);
// Enable Local Datastore.
Parse.enableLocalDatastore(this);
// Parse classes that need registering
ParseObject.registerSubclass(aaa.class); //error happens here
ParseObject.registerSubclass(bbb.class);
ParseObject.registerSubclass(ccc.class);
ParseObject.registerSubclass(ddd.class);
ParseObject.registerSubclass(eee.class);
ParseObject.registerSubclass(fff.class);
ParseObject.registerSubclass(ggg.class);
ParseObject.registerSubclass(hhh.class);
ParseObject.registerSubclass(iii.class);
ParseObject.registerSubclass(jjj.class);
Parse.initialize(this, PARSE_APPLICATION_ID, PARSE_CLIENT_KEY);
//set a default acl so that default is not public read.write
if (ParseUser.getCurrentUser() != null) {
ParseACL defaultACL = new ParseACL(ParseUser.getCurrentUser());
defaultACL.setPublicReadAccess(false);
defaultACL.setPublicWriteAccess(false);
ParseACL.setDefaultACL(defaultACL, true);
}
// Save this installation
ParseInstallation.getCurrentInstallation().saveInBackground();
ParseFacebookUtils.initialize(this);
ParseTwitterUtils.initialize(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET);
}
}
Any idea what's going wrong would be much appreciated.
I got some help from the friendly parse people on their github repo.
My issue:
https://github.com/ParsePlatform/Parse-SDK-Android/issues/342
The issue referenced from my issue:
https://github.com/ParsePlatform/Parse-SDK-Android/issues/213
The Stack Overflow Question referenced from the referenced issue. (this is what helped me solve my problem.)
Crash: java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$layout
Turns out it was a problem with multidex. I needed to extend MultiDexApplication instead of Application. I also added a couple things to my proguard rules.
This might be caused by:
aaa (presumably a subclass of ParseObject) having been built with a version of ParseObject that is different than the deployed library version, OR
myApplication being built with a version of ParseObject that is different than the deployed library version.
More likely the latter.

App works in debug but is crashing on google play version (classpath issue?)

I just posted a very major update to a program I have on google play. Everything works fine locally. But I have received field reports of about 20 or 30 of the following Crash report:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.twoplay.twoplayer/com.twoplay.twoplayer.TwoPlayer2Activity}: java.lang.ClassNotFoundException: com.twoplay.twoplayer.TwoPlayer2Activity in loader dalvik.system.PathClassLoader[/data/app/com.twoplay.twoplayer-1.apk]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1680)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
at android.app.ActivityThread.access$1500(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3835)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.twoplay.twoplayer.TwoPlayer2Activity in loader dalvik.system.PathClassLoader[/data/app/com.twoplay.twoplayer-1.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1672)
... 11 more
com.twoplay.twoplayer/com.twoplay.twoplayer.TwoPlayer2Activity is the correct name of the initial startup activity.
I also have a similar crash-dump where one of the app's services successfully starts, but crashes shortly after starting due to a missing class (not the service class itself).
I am using android.support.v4, along with a variety of other private libraries.
The project files have (for all practical purposes) been rebuilt from scratch since 2.0 upgrade. Although the package file name should be correct.
Curious things that I don't entirely understand in the log file:
/data/app/com.twoplay.twoplayer-1.apk
Why does "-1" get appended? The actual name of the APK seems to vary from crash dump to crash dump from the field. Sometimes the "-1" is there; sometimes not. e.g. (from other logs):
/data/app/com.twoplay.twoplayer-2.apk
I am assuming and hoping that Google Play developer console would not let me update my app if I had signed with an incorrect key. I didn't have any problems uploading.
Obviously, I'm not able to debug this locally, since I can't download my own app from Google Play. (I do hate that).
Any theories, or suggestions on how to approach gratefully appreciated.

MapActivity ClassDefNotFoundException at runtime

My Activity extends from MapActivity, I have descried it correctly in the manifest, I have put the <uses-library> tag inside the <application> tag I am building with goole apis library and the maps.jar is there only one time(no duplicates) and the app runs and works perfect on most devices.
However I got a crash report with ClassDefNotFoundException which occurred on ZTE Blade device with Android 2.1. I am building with google apis 2.1
Does anyone have suggestions for that?
I am providing the stack trace too:
java.lang.IllegalStateException: Could not execute method of the activity
at android.view.View$1.onClick(View.java:2165)
at android.view.View.performClick(View.java:2506)
at android.view.View$PerformClick.run(View.java:9112)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3835)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at android.view.View$1.onClick(View.java:2160)
... 11 more
Caused by: java.lang.NoClassDefFoundError: com.testing.asd.android.ui.InfoActivity
at com.testing.asd.android.ui.HomeScreen.onClick(HomeScreen.java:60)
... 14 more
com.testing.asd.android.ui.InfoActivity extends MapActivity. The problem is only on one device so far. I tested it on Android 2.3 and 4.2 and it is ok there.
I'm not sure if this is the case with the ZTE Blade, but there are some devices (such as the Kindle Fire) that don't have the Google APIs. I think these phones will show a NoClassDefFoundError if your app uses MapView.

Categories

Resources