I'm trying to implement the sample android app provided here.
I've installed all the dependencies as directed, but when I run the code on an actual phone, the error messages suggests (I think!) that the method setCoookieStore() doesn't exist and that's leading to problems down the road. Is this actually a problem with AsyncHttpClient or is this something which should be done in the parent class? How can I resolve it?
I've tried googling around quite a bit, but most results don't seem relevant and quite often are over my head (Android development beginner...). This seems like the closest thing I could find, but I'm not sure if it's right or how to implement it if it is: Using Cookies across Activities when using HttpClient.
Thank you for your help!
This is the overall series of error message
04-29 05:58:24.386 6867-6867/? E/Zygote: MountEmulatedStorage()
04-29 05:58:24.386 6867-6867/? E/Zygote: v2
04-29 05:58:24.386 6867-6867/? E/Zygote: accessInfo : 0
04-29 05:58:24.386 6867-6867/? E/SELinux: [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL
04-29 05:58:25.066 6867-6867/com.empatica.empalinksample E/EMPA_C: Loaded
04-29 05:58:25.086 6867-6867/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.empatica.empalinksample, PID: 6867
java.lang.NoSuchMethodError: No virtual method setCookieStore(Lorg/apache/http/client/CookieStore;)V in class Lcom/loopj/android/http/AsyncHttpClient; or its super classes (declaration of 'com.loopj.android.http.AsyncHttpClient' appears in /data/app/com.empatica.empalinksample-2/base.apk)
at com.empatica.empalink.EmpaDeviceManager.<init>(EmpaDeviceManager.java:180)
at com.empatica.empalink.EmpaDeviceManager.<init>(EmpaDeviceManager.java:166)
at com.empatica.sample.MainActivity.onCreate(MainActivity.java:64)
at android.app.Activity.performCreate(Activity.java:6550)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3108)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3263)
at android.app.ActivityThread.access$1000(ActivityThread.java:197)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1687)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6897)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Apparently I needed to add "useLibrary 'org.apache.http.legacy'" to my app's build.gradle file and make sure the compileSdkVersion and buildToolsVersion were pointing to 23 (instead of 21 which they were before).
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
useLibrary 'org.apache.http.legacy'
....
Related
I am trying to make an HTTP call to a server to get its HTML contents everything is working fine on other android versions. But in android 6 when the app is calling HTMLunit it crashes.
I know it has to do with something that works on API above 23. but not on the 23.. I tried many things but I sill can't fix it...
Why it's important to run the app on android 6:
A big number of my users is using android 6 and 5
The error:
FATAL EXCEPTION: Thread-9255
Process: bd.maruf.myapplication, PID: 7773
java.lang.NoClassDefFoundError: java.util.function.Supplier
at libcore.reflect.InternalNames.getClass(InternalNames.java:55)
at java.lang.Class.getDexCacheType(Class.java:476)
at java.lang.reflect.Method.getReturnType(Method.java:183)
at java.lang.Class.getDeclaredMethods(Class.java:678)
at com.gargoylesoftware.htmlunit.javascript.configuration.AbstractJavaScriptConfiguration.process(AbstractJavaScriptConfiguration.java:212)
at com.gargoylesoftware.htmlunit.javascript.configuration.AbstractJavaScriptConfiguration.getClassConfiguration(AbstractJavaScriptConfiguration.java:193)
at com.gargoylesoftware.htmlunit.javascript.configuration.AbstractJavaScriptConfiguration.<init>(AbstractJavaScriptConfiguration.java:67)
at com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration.<init>(JavaScriptConfiguration.java:685)
at com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration.getInstance(JavaScriptConfiguration.java:701)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.<init>(JavaScriptEngine.java:161)
at com.gargoylesoftware.htmlunit.WebClient.<init>(WebClient.java:326)
at com.gargoylesoftware.htmlunit.WebClient.<init>(WebClient.java:275)
at com.gargoylesoftware.htmlunit.WebClient.<init>(WebClient.java:265)
at com.gargoylesoftware.htmlunit.WebClient.<init>(WebClient.java:257)
at bd.maruf.myapplication.MainActivity.main(MainActivity.kt:32)
at bd.maruf.myapplication.MainActivity.onCreate$lambda$1$lambda$0(MainActivity.kt:22)
at bd.maruf.myapplication.MainActivity.$r8$lambda$VtPJx1mT1BVGpp5vWQWqcx_e4kM(MainActivity.kt)
at bd.maruf.myapplication.MainActivity$$ExternalSyntheticLambda2.run(D8$$SyntheticClass)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.ClassNotFoundException: Didn't find class "java.util.function.Supplier" on path: DexPathList[[zip file "/data/app/bd.maruf.myapplication-1/base.apk"],nativeLibraryDirectories=[/data/app/bd.maruf.myapplication-1/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at libcore.reflect.InternalNames.getClass(InternalNames.java:53)
at java.lang.Class.getDexCacheType(Class.java:476)
at java.lang.reflect.Method.getReturnType(Method.java:183)
at java.lang.Class.getDeclaredMethods(Class.java:678)
at com.gargoylesoftware.htmlunit.javascript.configuration.AbstractJavaScriptConfiguration.process(AbstractJavaScriptConfiguration.java:212)
at com.gargoylesoftware.htmlunit.javascript.configuration.AbstractJavaScriptConfiguration.getClassConfiguration(AbstractJavaScriptConfiguration.java:193)
at com.gargoylesoftware.htmlunit.javascript.configuration.AbstractJavaScriptConfiguration.<init>(AbstractJavaScriptConfiguration.java:67)
at com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration.<init>(JavaScriptConfiguration.java:685)
at com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration.getInstance(JavaScriptConfiguration.java:701)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.<init>(JavaScriptEngine.java:161)
at com.gargoylesoftware.htmlunit.WebClient.<init>(WebClient.java:326)
at com.gargoylesoftware.htmlunit.WebClient.<init>(WebClient.java:275)
at com.gargoylesoftware.htmlunit.WebClient.<init>(WebClient.java:265)
at com.gargoylesoftware.htmlunit.WebClient.<init>(WebClient.java:257)
at bd.maruf.myapplication.MainActivity.main(MainActivity.kt:32)
at bd.maruf.myapplication.MainActivity.onCreate$lambda$1$lambda$0(MainActivity.kt:22)
at bd.maruf.myapplication.MainActivity.$r8$lambda$VtPJx1mT1BVGpp5vWQWqcx_e4kM(MainActivity.kt)
at bd.maruf.myapplication.MainActivity$$ExternalSyntheticLambda2.run(D8$$SyntheticClass)
at java.lang.Thread.run(Thread.java:818)
Suppressed: java.lang.ClassNotFoundException: java.util.function.Supplier
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 20 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
2022-11-12 18:11:50.861 7773-7807 Surface bd.maruf.myapplication D Surface::disconnect(this=0xaddb7b00,api=1)
what I have tried :
cleaning and rebuilding that project
adding:
defaultConfig { multiDexEnabled true}
dependencies {implementation 'com.android.support:multidex:1.0.3'
3. deleting .gradel and .idea file
java.util.function.Supplier is documented as "Added in API level 24", hence code requiring it will not work on pre 24 SDK due to class absence.
Will try to solve this in HtmlUnit - check https://github.com/HtmlUnit/htmlunit-android/issues/9 or https://twitter.com/htmlunit for progress.
After some analysis and experiments i decide to not fix this. The js engine (Rhino) uses classes from the java.util.function package. Changing this is not a simple task and there are many other thinks to do.
So sorry, but i like to stay with android 7 as minimum requirement.
In my project i'm using the monetization service(Vungle/AppLovin).
When I'm trying to load an ad, i get this exception
E/AndroidRuntime: FATAL EXCEPTION: GoogleApiHandler
Process: kz.ikar, PID: 3673
java.lang.NoSuchMethodError: No virtual method setChannelId(Ljava/lang/String;)Landroid/support/v4/app/NotificationCompat$Builder; in class Landroid/support/v4/app/NotificationCompat$Builder; or its super classes (declaration of 'android.support.v4.app.NotificationCompat$Builder' appears in /data/app/kz.ikar-2oCl4DY4J8w7wP-jirbYvA==/split_lib_dependencies_apk.apk)
at com.google.android.gms.common.GoogleApiAvailability.zza(Unknown Source:225)
at com.google.android.gms.common.GoogleApiAvailability.zza(Unknown Source:15)
at com.google.android.gms.common.api.internal.zzbm.zzc(Unknown Source:4)
at com.google.android.gms.common.api.internal.zzbo.onConnectionFailed(Unknown Source:104)
at com.google.android.gms.common.api.internal.zzbo.connect(Unknown Source:83)
at com.google.android.gms.common.api.internal.zzbo.zza(Unknown Source:47)
at com.google.android.gms.common.api.internal.zzbm.handleMessage(Unknown Source:283)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:164)
at android.os.HandlerThread.run(HandlerThread.java:65)
In my project I have two fragments in one activity. The user gets an ad in the second one. If I load an ad from the activity, it works well. What can be the cause of this issue?
By the way both ad networks(Vungle and AppLovin) return this exception
I had the same problem and I fixed it downgrading to firebase Google Play services 11.6.0
One reason you could be getting this error is if your buildToolsVersion in your app-level Gradle is less than 26. Either that or your v4 support is less than 26.0.0 seeing as NotificationCompat.Builder was added in API 26.
I am building an Android App and everything works correctly for Android 5.+. However, for Android 4.x, I am getting the following error when I try to compile using Android Studio:
E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.google.android.gms.R$string
at com.google.android.gms.common.internal.zzam.<init>(Unknown Source)
at com.google.firebase.FirebaseOptions.fromResource(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1064)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:5181)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4733)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4666)
at android.app.ActivityThread.access$1300(ActivityThread.java:166)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1439)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5455)
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:966)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:733)
at dalvik.system.NativeStart.main(Native Method)
In my dependencies, I already tried both compile 'com.google.android.gms:play-services:+'
and also compile 'com.google.android.gms:play-services:9.8.0'.
I have been trying to find solutions online and people recommend to add Google Play Services dependencies, but I already did that. I had also tried compile 'com.android.support:multidex:1.0.0' but I do not think that would make any difference because in any case, I saw this message popping up in Android Studio:
"Instant Run does not support deploying build variants with multidex enabled, to a target with API level 20 or below.
To use Instant Run with a multidex enabled build variant, deploy to a target with API level 21 or higher."
Any hints? Thank you.
The solution was simply adding the following code in my class that extended Application:
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
The solution was at java.lang.NoClassDefFoundError: com.google.android.gms.internal.zzmp, so this question could be marked as duplicate.
For some reason my app won't call custom application classes onCreate() anymore. Yesterday everything was fine but today my app crashes when it tries to open a connection to Realm.
java.lang.IllegalStateException: Call 'Realm.init(Context)' before calling this method.
Since I do initialize Realm in my custom application classes onCreate() I tried inserting a breakpoint and logging out of the method. Nothing.
This question had a similiar problem
Custom Application class onCreate() never called
I have disabled instant run, cleaned, rebuilt and even restarted android studio but the problem persists. I even tried checking out a commit from three days ago, which was most certainly working, but the result is the same.
Custom application class
public class MyApplication extends Application
{
#Override
public void onCreate()
{
super.onCreate();
JodaTimeAndroid.init(this);
Realm.init(this);
//more Realm initialization code
}
}
Manifest's application section
<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="#drawable/logo"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:supportsRtl="true"
android:theme="#style/MyTheme">
Any ideas what might cause this and how to get it fixed?
EDIT
Everything logcat puts out before crash
03-19 21:06:10.687 21869-21869/? E/Zygote: v2
03-19 21:06:10.687 21869-21869/? I/libpersona: KNOX_SDCARD checking this for 10323
03-19 21:06:10.687 21869-21869/? I/libpersona: KNOX_SDCARD not a persona
03-19 21:06:10.688 21869-21869/? E/Zygote: accessInfo : 0
03-19 21:06:10.688 21869-21869/? W/SELinux: SELinux selinux_android_compute_policy_index : Policy Index[2], Con:u:r:zygote:s0 RAM:SEPF_SECMOBILE_7.0_0004, [-1 -1 -1 -1 0 1]
03-19 21:06:10.689 21869-21869/? I/SELinux: SELinux: seapp_context_lookup: seinfo=untrusted, level=s0:c512,c768, pkgname=hailer.com.hailer
03-19 21:06:10.692 21869-21869/? I/art: Late-enabling -Xcheck:jni
03-19 21:06:10.709 21869-21869/? D/TimaKeyStoreProvider: TimaSignature is unavailable
03-19 21:06:10.709 21869-21869/? D/ActivityThread: Added TimaKeyStore provider
03-19 21:06:10.790 21869-21869/hailer.com.hailer D/ContextRelationMgrBrdg: loadKlass() : caller=com.samsung.android.bridge.multiscreen.common.ContextRelationManagerBridge.<clinit>:28 android.app.LoadedApk.makeApplication:833
03-19 21:06:10.814 21869-21869/hailer.com.hailer W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
03-19 21:06:10.872 21869-21869/hailer.com.hailer D/AndroidRuntime: Shutting down VM
03-19 21:06:10.873 21869-21869/hailer.com.hailer E/AndroidRuntime: FATAL EXCEPTION: main
Process: hailer.com.hailer, PID: 21869
java.lang.RuntimeException: Unable to start activity ComponentInfo{hailer.com.hailer/hailer.com.hailer.activities.MainActivity}: java.lang.IllegalStateException: Call `Realm.init(Context)` before calling this method.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2947)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3008)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6688)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
Caused by: java.lang.IllegalStateException: Call `Realm.init(Context)` before calling this method.
at io.realm.Realm.getDefaultInstance(Realm.java:208)
at hailer.com.hailer.adapters.DiscussionAdapter.<init>(DiscussionAdapter.java:57)
at hailer.com.hailer.fragments.ChatListFragment.onCreateView(ChatListFragment.java:60)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2189)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1299)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:757)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2355)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2146)
at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2098)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2008)
at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:388)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:607)
at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:178)
at hailer.com.hailer.activities.MainActivity.onStart(MainActivity.java:320)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1256)
at android.app.Activity.performStart(Activity.java:6929)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2910)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3008)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6688)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
UPDATE
I trimmed down the libraries and disabled multidexing. Didn't help. I also went trough the DiscussionAdapter and ChatListFragment and both are fine. Realm is used in a correct manner and has worked for over a year without issues. I also have log.d("CUSTOMAPPCLS","onCreate called") in my custom application class which does not show in the log. Nor does a breakpoint stop in any part of the onCreate() call.
Now I got a new error. This time it's from PrefsAccessor - a wrapper for SharedPreferences which is also intialised in the custom applications onCreate call. PrefAccessor.init(this); I ran the build again but got the Realm error... The one considering PrefAccessor threw a nullpointer execption when trying to access the SharedPreferences. This further points to the fact that the application onCreate isn't called.
public static string isUseEnterToSendEnabled()
{
SharedPreferences prefs = applicationContext.getSharedPreferences(PREFS_KEY, Context.MODE_PRIVATE);// <-- nullpointer exception: Trying to call .getSharedPreferences on a null object
return prefs.getBoolean(ENTER_TO_SEND, false);
}
I found similar scenario to yours here:
https://github.com/realm/realm-java/issues/1800
The issue seems to be about having lots of libraries included to your project (such as Google Play Services) which might led to your app hitting the 65K methods limit.
Did you include any new dependencies to your project?
UPDATE:
after checking your log, I believe the problem can be here:
hailer.com.hailer.adapters.DiscussionAdapter.(DiscussionAdapter.java:57)
at
hailer.com.hailer.fragments.ChatListFragment.onCreateView(ChatListFragment.java:60)
Maybe in your ChatListFragment, you have an instance of DiscussionAdapter which in turn has some static initializer that invokes something related to Realm.
UPDATE 04/2017
The Samsung S7 started working couple of days after I posted this answer... Black magics all the way I say.
It seems that the Samsung S7 that I usually use for testing is somehow busted. I got some other phones from the office and all of them work just fine. I really have no idea what caused the phone to start crashing the app... None of the other apps are crashing and I didn't download any updates or other apps before this started. I'll post a comment to this answer if I figure this one out and accept this as the solution since I found a "solution"....
I am getting an Error while installing apk in android 5.1.
Package couldn't be installed in /data/app/com.acelrtech.apps.xxxxxxxxx-1
com.android.server.pm.PackageManagerException: scanPackageLI
at com.android.server.pm.PackageManagerService.scanPackageDirtyLI(PackageManagerService.java:6313)
at com.android.server.pm.PackageManagerService.scanPackageLI(PackageManagerService.java:5605)
at com.android.server.pm.PackageManagerService.installNewPackageLI(PackageManagerService.java:10550)
at com.android.server.pm.PackageManagerService.installPackageLI(PackageManagerService.java:11128)
at com.android.server.pm.PackageManagerService.access$2800(PackageManagerService.java:241)
at com.android.server.pm.PackageManagerService$6.run(PackageManagerService.java:8993)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:194)
at android.os.HandlerThread.run(HandlerThread.java:61)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
Here is the Gradle main part looks looks like . Hoping for a better input.
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
applicationId "com.acelrtech.apps.xxxxxxxxxxxx”
minSdkVersion 14
targetSdkVersion 21
versionCode 23
versionName "2016.6.21"
generatedDensities = []
multiDexEnabled true
}
Also i tried the this solution ..