When i debug my app it is working fine but when i try to export my apk and install it i am getting this issue:
java.lang.NoClassDefFoundError: org.apache.http.params.SyncBasicHttpParams
at aig.a(Unknown Source)
at ahy.q(Unknown Source)
at ahy.d(Unknown Source)
at ahy.r(Unknown Source)
at ahy.c(Unknown Source)
at ahy.a(Unknown Source)
at ahy.a(Unknown Source)
at ahy.execute(Unknown Source)
at com.application.Login.a(Unknown Source)
at com.application.Login.onCreate(Unknown Source)
at android.app.Activity.performCreate(Activity.java:5115)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2248)
at android.app.ActivityThread.access$600(ActivityThread.java:145)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1246)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5095)
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:898)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
at dalvik.system.NativeStart.main(Native Method)
I am using proguard,
I have added reference libs also like this:
-libraryjars /libs/org.apache.httpcomponents.httpclient_4.2.1.jar
-libraryjars /libs/signpost-commonshttp4-1.2.1.1.jar
-libraryjars /libs/signpost-core-1.2.1.1.jar
-libraryjars /libs/signpost-jetty6-1.2.1.1.jar
-libraryjars /libs/twitter4j-core-2.1.6.jar
any idea..#thanks
There is no HttpCore in your libs.
Please import HttpCore
This link is HttpCore 4.1, You can search HttpCore 4.2 or 4.3 if you want.
In the future, when you import a library please ensure that you import the relevant library
Add the following lines to you proguard-project.txt file:
-keep class org.apache.http.** {
*;
}
I would also suggest you to use repackaged version of HttpClient for Android instead of original HttpClient jar to avoid class loading collisions with the version bundled with Android. But as far as I can see you'll also need to rebuild Signpost HttpClient module to use ch.boye.httpclientandroidlib package instead of org.apache.http (and don't forget to update package name in proguard-project.txt as well).
Import the package on your bundle
Import-Package: org.apache.http.params
In the standard Android builds (Ant, Eclipse, Gradle), don't specify -libraryjars or -injars, since the build scripts will already specify those for you. Just make sure you add all necessary library jars to the libs directory, as usual, so the build scripts will include them.
In Eclipse, libraries may need to be marked as Exported.
Related
Similar questions have need asked already. But this one seems to be more complicated than previous ones because of changes in compatibility of Android Platforms.
Here is my error log from Pixel and Pixel2 which are signed up for Android Beta Program
08-16 13:20:53.146 9630-9630/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: me.project.android.dev, PID: 9630
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/commons/logging/LogFactory;
at com.amazonaws.util.VersionInfoUtils.<clinit>(VersionInfoUtils.java:41)
at com.amazonaws.util.VersionInfoUtils.c(VersionInfoUtils.java:77)
at com.amazonaws.ClientConfiguration.<clinit>(ClientConfiguration.java:43)
//project specific class reference removed
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.commons.logging.LogFactory" on path: DexPathList[[zip file "/data/app/me.project.android.dev-0SPRJnc8-4voauRU7Y20zQ==/base.apk"],nativeLibraryDirectories=[/data/app/me.project.android.dev-0SPRJnc8-4voauRU7Y20zQ==/lib/arm64, /data/app/me.project.android.dev-0SPRJnc8-4voauRU7Y20zQ==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.amazonaws.util.VersionInfoUtils.<clinit>(VersionInfoUtils.java:41)
at com.amazonaws.util.VersionInfoUtils.c(VersionInfoUtils.java:77)
at com.amazonaws.ClientConfiguration.<clinit>(ClientConfiguration.java:43)
//project specific class reference removed
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Same code when ran on Devices running Android 7.0 and below, it works perfectly fine.
I tried adding dependency to my project too
implementation "commons-logging:commons-logging:1.2"
Adding this dependency makes the app work in Pixel and Pixel but then it crashes in all other devices with Exception saying
org.apache.commons.logging.impl.LogFactoryImpl does not extend or implement org.apache.commons.logging.LogFactory
I tried doing all the changes in ProGuard already. Here is my proguard configuration
-keep class org.apache.commons.logging.impl.LogFactoryImpl
-keep class org.apache.commons.logging.LogFactory
-keepnames class org.apache.commons.logging.impl.* {*;}
-keepnames class org.apache.commons.logging.*
-keepclassmembers class org.apache.commons.logging.impl.* {*;}
-keepclassmembers class org.apache.commons.logging.*
-keepnames interface org.apache.commons.logging.impl.* {*;}
-keepnames interface org.apache.commons.logging.*
Still causing the crash.
This issue is related to Amazon AWS SDK - https://github.com/aws/aws-sdk-android/issues/476
Is there any workaround till AWS updates their SDK to fix this issue?
Add this below line in manifest file.
<uses-library android:name ="org.apache.http.legacy" android:required ="false"/>
This is an AWS SDK bug that appears to be solved in version 2.6.30 of the SDK:
Fixed a bug where getting a logger using Apache Commons Logging would
crash starting Android 9.0 (Pie / API Level 28). See pull #521. Now,
Apache Commons Logging would be used if it's being added as a
dependency, otherwise android.util.Log will be used.
to fix this issue I had the dependency
implementation "commons-logging:commons-logging-api:1.1"
in gradle file.
An alternative workaround is to add the commons-logging library as a .jar file to your libs/ folder instead of using implementation. Make sure that implementation fileTree(include: ['*.jar'], dir: 'libs') is in your dependencies.
Sources of commons-logging-1.2.jar:
Maven Repository
Apache Commons Logging
Credit: Dale Lim -
https://github.com/aws/aws-sdk-android/issues/265#issuecomment-411978696
/*Apache Commons Logging would crash starting Android 9.0 (Pie / API Level 28).*/
//try this
testImplementation 'commons-logging:commons-logging:1.2'
// in manifest <application> s
<uses-library android:name="org.apache.http.legacy" android:required="false" />
/* if this files 'commons-logging:commons-logging:1.2' fails to download then
download this file manual from http://commons.apache.org/proper/commons-
logging/download_logging.cgi and paste it lib folder*/
Since I updated Android Studio to version 1.2.1.1 I have the following problem:
Whenever I build a release version / build variant of my app, I get a NoClassDefFoundError on the Adjust library I have included in the project as a library module.
The stracktrace:
java.lang.NoClassDefFoundError: com.adjust.sdk.AdjustConfig
at de.myapp.GlobalApp.prepareAdjust(GlobalApp.java:111)
at de.myapp.GlobalApp.onCreate(GlobalApp.java:71)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:999)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4151)
at android.app.ActivityThread.access$1300(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
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:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Corresponding part of my code:
AdjustConfig config = new AdjustConfig(this, someString, otherString);
When I turn off Proguard with minifyEnabled false; in my build.gradle, the error is gone.
My proguard-rules.pro looks like this:
-keepattributes **
-keep class !android.support.v7.internal.view.menu.**,** {*;}
-dontpreverify
-dontoptimize
-dontshrink
-dontwarn **
These Proguard rules might look a bit strange because they do but one thing: obfuscate classes in the android.support.v7.internal.view.menu package.
This procedure is a workaround for a a known issue of the Android Support library on Samsung devices.
Even more confusingly, the NoClassDefFoundError only occurs only devices running Android < 5.0.
Any ideas on what the reason could be or how to fix this?
The documentation says:
If you are using Proguard, add these lines to your Proguard file:
-keep class com.adjust.sdk.** { *; }
-keep class com.google.android.gms.common.** { *; }
-keep class com.google.android.gms.ads.identifier.** { *; }
I am getting this exception. Please find below the complete stack trace.
com.facebook.FacebookGraphObjectException: Factory can't proxy method: public abstract java.lang.String com.junobe.android.junowallet.SNS.u.a()
at com.facebook.model.GraphObject$Factory.verifyCanProxyClass(SourceFile:290)
at com.facebook.model.GraphObject$Factory.createGraphObjectProxy(SourceFile:216)
at com.facebook.model.GraphObject$Factory.access$0(SourceFile:215)
at com.facebook.model.GraphObject$Factory$GraphObjectProxy.proxyGraphObjectMethods(SourceFile:583)
at com.facebook.model.GraphObject$Factory$GraphObjectProxy.invoke(SourceFile:521)
at $Proxy0.cast()
at com.facebook.Response.getGraphObjectAs(SourceFile:124)
at com.junobe.android.junowallet.SNS.FacebookOpenGraphController.handleResponse(SourceFile:568)
at com.junobe.android.junowallet.SNS.FacebookOpenGraphController.access$6(SourceFile:555)
at com.junobe.android.junowallet.SNS.FacebookOpenGraphController$3.onPostExecute(SourceFile:522)
at com.junobe.android.junowallet.SNS.FacebookOpenGraphController$3.onPostExecute(SourceFile:1)
at android.os.AsyncTask.finish(AsyncTask.java:417)
at android.os.AsyncTask.access$300(AsyncTask.java:127)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3685)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(NativeStart.java)
I am not getting this issue on all devices or all times. Identified this from crashlytics.
I have a hunch that it may be some proguard - obfuscation issue on Android.
I have added the following lines to in the proguard file (As per facebook Documentation):
-keep class com.facebook.** { *; }
-keepattributes Signature
Is there something I am missing .. Any assistance or solution would be welcome.
The only thing that I found that worked for me was to not obfuscate classes that extended facebook classes. I had a bunch of files in one package so for all those files I just excluded them by adding this to my proguard-project.txt.
-keep class com.classes.extending.facebook.** { *; }
I wanna add just google-play-services.jar to my project and make map v2 work without adding google-play-services_lib as a library to my project, is that possible ?
i try to do that lot of times and ways, but every one make an exception, expel :
FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:279)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:558)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
...
no because it needs additional resources such as images and styles as you can see by the error that are not in just the jar file
My application worked well, without any errors, so far. But lately I've began using ProGuard to obfuscate the code now I see the following error report in the Google Play developer console:
java.lang.RuntimeException: Unable to instantiate application MYPACKAGE.MyApp: java.lang.ClassNotFoundException: MYPACKAGE.MyApp
at android.app.LoadedApk.makeApplication(LoadedApk.java:482)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3950)
at android.app.ActivityThread.access$1300(ActivityThread.java:127)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1197)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4507)
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:980)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: MYPACKAGE.MyApp
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newApplication(Instrumentation.java:945)
at android.app.LoadedApk.makeApplication(LoadedApk.java:477)
MyApp is the custom application class, obviously. There's only one error report on that issue so far, although there are 10,000+ active installations. Does that mean I shouldn't bother with that problem or could it be a serious issue? How can I resolve this?
try add this lines:
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
to proguard.cfg file
ProGuard simply replaces class names by obfuscated class names. If the processed code works on one device (or 10,000+ devices), it should work on all devices.
Moreover, if you disassemble the processed application, you'll see that mypackage.MyApp is still there, with its original name. The default integration of ProGuard in the Android build takes care of keeping activities, services, etc, without any need for additional -keep options.
In short, this is some sort of fluke, most probably unrelated to obfuscation. Simply reinstalling the application may help.
Seems like your class names are missing in proguard's obfuscation configuration. Add the following to your proguard.cfg with the missing class names.
-keep public class your_missing_class_full_name