简体   繁体   中英

NoSuchMethodError in release apk when proguard is enabled

This error comes only in signed/released apk and proguard is enable( minifyEnabled true ).

Error logcat redirects me to this line: if (jsonArrayUserDetails.length() > 0) { }

Error:

E: FATAL EXCEPTION: main
    Process: com.my.project, PID: 4713
    java.lang.NoSuchMethodError: No virtual method a()I in class Lorg/json/JSONArray; or its super classes (declaration of 'org.json.JSONArray' appears in /system/framework/core-libart.jar)
        at com.my.project.userActivities.LoginActivity.a(LoginActivity.java:145)
        at com.my.project.userActivities.LoginActivity.a(LoginActivity.java:40)
        at com.my.project.userActivities.LoginActivity$1.a(LoginActivity.java:115)
        at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:70)
        at android.os.Handler.handleCallback(Handler.java:794)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:176)
        at android.app.ActivityThread.main(ActivityThread.java:6651)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)

build.gradle(project-level):

classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.google.gms:google-services:4.2.0'

After hours of search, I accidentally found a solution. I tried to update build.gradle(project-level) and it worked like a charm.

Old:

classpath 'com.android.tools.build:gradle:3.4.0'

New:

classpath 'com.android.tools.build:gradle:3.5.0'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM