Crosswalk crashes with AssertionFailedError - android

Crashlytics reports the following problem, that is affecting a good percentage of the users of my application:
Fatal Exception: junit.framework.AssertionFailedError: Cannot call
this method before xwalk is ready
at junit.framework.Assert.fail(Assert.java:50)
at org.xwalk.core.XWalkView.setZOrderOnTop(XWalkView.java:1271)
at org.crosswalk.engine.XWalkWebViewEngine.initWebViewSettings(XWalkWebViewEngine.java:193)
at org.crosswalk.engine.XWalkWebViewEngine.access$000(XWalkWebViewEngine.java:55)
at org.crosswalk.engine.XWalkWebViewEngine$2.run(XWalkWebViewEngine.java:90)
at org.xwalk.core.XWalkActivityDelegate.onActivateCompleted(XWalkActivityDelegate.java:179)
at org.xwalk.core.XWalkLibraryLoader$ActivateTask.onPostExecute(XWalkLibraryLoader.java:314)
at org.xwalk.core.XWalkLibraryLoader$ActivateTask.onPostExecute(XWalkLibraryLoader.java:277)
at android.os.AsyncTask.finish(AsyncTask.java:632)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5034)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(NativeStart.java)
I just added crosswalk as a plugin and I don't think I call any method explicitly (Cannot call this method before xwalk is ready). Any ideas? Thanks in advance!

I think you're doing something to the XWalkView while it's still in the not-ready state.
In the latest version of Crosswalk, there are some changes to the lib that the Crosswalk runtime isn't loaded yet when onCreate() is called. Therefore, if you want to initialize XWalkView or do something, wait until XWalkActivity.onXWalkReady() is called.
The solution is :
Extend the activity containing XWalkView from XWalkActivity
Override XWalkActivity's onXWalkReady() methods, and do necessary initialization stuff to the XWalkView there
As already stated here: https://crosswalk-project.org/apis/embeddingapidocs_v5/org/xwalk/core/XWalkActivity.html

Related

Android application with camera2 library crash on start for SDK19

I use androidx.camera.camera2 library in my application. This library for SDK 21 and greater. But i want allow users start application for SDK 19 without camera2 support. I check SDK version in my code, but application crash on start. Can i exclude camera2 from dependencies for old SDK?
05-30 12:13:42.318 2000-2000/com.myapp.android E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myapp.android, PID: 2000
java.lang.NoClassDefFoundError: android.util.Size
at androidx.camera.camera2.impl.Camera2DeviceSurfaceManager.<clinit>(Camera2DeviceSurfaceManager.java:53)
at androidx.camera.camera2.Camera2AppConfig.create(Camera2AppConfig.java:58)
at androidx.camera.camera2.impl.Camera2Initializer.onCreate(Camera2Initializer.java:44)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1591)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1562)
at android.app.ActivityThread.installProvider(ActivityThread.java:4790)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4385)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4325)
at android.app.ActivityThread.access$1500(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
I recently stumbled into the same issue.
Diving deep into the CameraX code I found that CameraX is initialized in app startup through a content provider. Here is the content provider code where CameraX is being initialized.
public final class Camera2Initializer extends ContentProvider {
private static final String TAG = "Camera2Initializer";
#Override
public boolean onCreate() {
Log.d(TAG, "CameraX initializing with Camera2 ...");
CameraX.init(getContext(), Camera2AppConfig.create(getContext()));
return false;
}
}
Im not very familiar with content providers but my first taught was, this is add at the manifest level? And indeed I was right.
Looking at there manifest I found this
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="androidx.camera.camera2">
<application>
<provider
android:name=".Camera2Initializer"
android:authorities="${applicationId}.camerax-init"
android:exported="false"
android:initOrder="100"
android:multiprocess="true" />
</application>
</manifest>
There manifest gets merged into ours which will include this content provider which in the other hand initializes CameraX, we want to avoid this. So one possible way of doing so is creating our own empty content provider and adding it to our manifest with the same name. This will override there content provider.
You can look into
https://developer.android.com/studio/build/manifest-merge
for more detail about manifest merging.
So now with there content provider overriden hopefully you can call
CameraX.init(getContext(), Camera2AppConfig.create(getContext()));
only when the feature gets called and not on app startup.
Im hoping this gets fixed in later versions and allows us to initialize cameraX when we want to.

Unmarshalling unknown type code 6881391 at offset 4752 After Upgrading to Support Libraries 23.2.0

My app has been working well at Support Libraries 23.1.1. However, after upgrading to Support Libraries 23.2.0, it starts to crash. The crash happens when I navigate from an activity back to the main activity (for example, I open the about activity from main activity's actionbar menu, then press back button to go back to main activity, then it crashes).
The crash log is here:
FATAL EXCEPTION: main Process: com.myapp.blah.blah, PID: 22124
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.myapp.blah.blah/com.myapp.blah.blah.ui.MainActivity}:
java.lang.RuntimeException: Parcel android.os.Parcel#41d10870:
Unmarshalling unknown type code 6881391 at offset 4752 at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2429)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2493)
at android.app.ActivityThread.access$800(ActivityThread.java:166) at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1283)
at android.os.Handler.dispatchMessage(Handler.java:102) at
android.os.Looper.loop(Looper.java:136) at
android.app.ActivityThread.main(ActivityThread.java:5584) at
java.lang.reflect.Method.invokeNative(Native Method) at
java.lang.reflect.Method.invoke(Method.java:515) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084) at
dalvik.system.NativeStart.main(Native Method) Caused by:
java.lang.RuntimeException: Parcel android.os.Parcel#41d10870:
Unmarshalling unknown type code 6881391 at offset 4752 at
android.os.Parcel.readValue(Parcel.java:2087) at
android.os.Parcel.readArrayMapInternal(Parcel.java:2321) at
android.os.Bundle.unparcel(Bundle.java:249) at
android.os.Bundle.getSparseParcelableArray(Bundle.java:1273) at
com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:1884)
at android.app.Activity.onRestoreInstanceState(Activity.java:989) at
android.app.Activity.performRestoreInstanceState(Activity.java:961) at
android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1145)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2407)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2493)?
at android.app.ActivityThread.access$800(ActivityThread.java:166)? at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1283)?
at android.os.Handler.dispatchMessage(Handler.java:102)? at
android.os.Looper.loop(Looper.java:136)? at
android.app.ActivityThread.main(ActivityThread.java:5584)? at
java.lang.reflect.Method.invokeNative(Native Method)? at
java.lang.reflect.Method.invoke(Method.java:515)? at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)?
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)? at
dalvik.system.NativeStart.main(Native Method)?
The crash only happens if I set the developer debug option "do not keep activities" on. The crash does not happen if this option is off.
The crashes happens in debug mode where no Proguard is used.
I do not pass any parcels/bundles between the activities, and do not use startActivityForResult().
Crash happens on both pre and post Lollipop devices.
I found two similar posts here and here which might (or might not) be related.
Unmarshalling exception when using SearchView with an id resource in
appcompat 23.2
Hi, it can fix by implement onSavedInstance and onRestore but don't use super. This strange behavior
#Override
protected void onSaveInstanceState(Bundle outState) {
}
#Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
}

TextView animation

I find a good external lib to implement many beautiful Textview animations. The link is this: https://github.com/daimajia/AndroidViewAnimations
I have a problem to implement it. I have imported correctly all 3 libs and I use correctly the function like in the dev's example:
YoYo.with(Techniques.Tada).duration(700).playOn(findViewById(R.id.TextView1));
Eclipse doesn't segnalate me any problem. But when I launch the application, it crashes
p.s. sorry for my bad english, I'm italian :(
EDIT 1:
logcat:
FATAL EXCEPTION: main
java.lang.IllegalStateException: Could not execute method of the activity
at android.app.ActivityThread.main(ActivityThread.java:4960)
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:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at android.view.View$1.onClick(View.java:3675)
... 12 more
Caused by: java.lang.NoClassDefFoundError:com.daimajia.androidanimations.library.Techniques
enter code here
I had the same problem. My problem was missing dependency AndroidEasingFunctions-1.0.0. Please make sure all dependencies are included into the project correctly. See https://github.com/daimajia/AndroidViewAnimations.

Clockwork package installer stopped

Recently, I've been coding an APP which could work for an Android Device and an Android Wearable.
Today, I finished developments, and I've created a production APK following http://developer.android.com/training/wearables/apps/packaging.html tutorial.
However, when I install APK on a device, it works, but it doesn't get pushed to device.
Device crashes with message:
This is the stacktrace returned by Wearable:
08-04 21:53:47.957 914-914/com.google.android.clockwork.packageinstaller E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.google.android.clockwork.packageinstaller, PID: 914
java.lang.NullPointerException
at java.util.jar.Manifest.read(Manifest.java:187)
at java.util.jar.Manifest.<init>(Manifest.java:106)
at java.util.jar.StrictJarFile.<init>(StrictJarFile.java:65)
at android.content.pm.PackageParser.collectManifestDigest(PackageParser.java:594)
at com.google.android.clockwork.packageinstaller.PackageUtil.getPackageInfo(PackageUtil.java:76)
at com.google.android.clockwork.packageinstaller.PackageInstallerService.installPackage(PackageInstallerService.java:144)
at com.google.android.clockwork.packageinstaller.PackageInstallerService.access$000(PackageInstallerService.java:29)
at com.google.android.clockwork.packageinstaller.PackageInstallerService$1.handleMessage(PackageInstallerService.java:55)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5026)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(Native Method)
I don't really know how to debug this.
APP works perfectly when pushed via ADB.
Tell me if you do need any further info.
Thanks.
Well... Today it worked.
What did I do:
Clean
Removed old APK generated (.....\mobile\build\outputs\apk)
Compile via gradle via script "assembleRelease"
Now it works.

Null pointer exception on doing webview.loadUrl()

I've been getting this error in my developer portal. I'm not sure why. Stack trace tracks back into some internal function call inside WebView object.
java.lang.NullPointerException
at android.webkit.WebView.loadUrlImpl(WebView.java:3008)
at android.webkit.WebView.loadUrlImpl(WebView.java:3047)
at android.webkit.WebView.loadUrl(WebView.java:3040)
at com.myapp.android.PreviewActivity.notifyJS(PreviewActivity.java:175)
at com.myapp.android.PreviewActivity.access$14(PreviewActivity.java:174)
at com.myapp.android.PreviewActivity$ActionBarItemClickListener.onClick(PreviewActivity.java:901)
at android.view.View.performClick(View.java:3644)
at android.view.View$PerformClick.run(View.java:14313)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4517)
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:993)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
at dalvik.system.NativeStart.main(Native Method)
In my code at com.myapp.android.PreviewActivity.notifyJS(PreviewActivity.java:175), there is this line
webView.loadUrl("javascript:MyApp.onClick('" + action + "');");
I'm actually invoking a javascript call from my java code. Has anyone faced this issue before?
I found the answer myself. If webView.destroy() has already been called then calling webView.loadUrl() will cause this exception.
It seems that your webview is null. Did you call findView before?

Categories

Resources