I loose values in Preferences (CN1Preferences) in particular scenario of using my application on Android.
When I launch my app the first time, I save some values in Preferences. If I close my app (from background task) and then I sleep my tablet, when I relaunch the app, values save in Preferences are lost. This is the log I obtain after the relaunch :
CliniScore: [EDT] 0:0:0,4 - Exception: java.io.EOFException - null
05-04 16:32:40.667 10618-10978/? W/System.err: java.io.EOFException
05-04 16:32:40.667 10618-10978/? W/System.err: at java.io.DataInputStream.readBoolean(DataInputStream.java:69)
05-04 16:32:40.667 10618-10618/? D/SecWifiDisplayUtil: Metadata value : SecSettings2
05-04 16:32:40.667 10618-10978/? W/System.err: at com.codename1.io.Util.readObject(Util.java:541)
05-04 16:32:40.667 10618-10978/? W/System.err: at com.codename1.io.Util.readObject(Util.java:638)
05-04 16:32:40.667 10618-10978/? W/System.err: at com.codename1.io.Storage.readObject(Storage.java:261)
05-04 16:32:40.667 10618-10978/? W/System.err: at com.codename1.io.Preferences.get(Preferences.java:83)
05-04 16:32:40.667 10618-10978/? W/System.err: at com.codename1.io.Preferences.get(Preferences.java:298)
05-04 16:32:40.667 10618-10978/? W/System.err: at com.codename1.impl.CodenameOneImplementation.initEDT(CodenameOneImplementation.java:235)
05-04 16:32:40.667 10618-10978/? W/System.err: at com.codename1.ui.Display.mainEDTLoop(Display.java:952)
05-04 16:32:40.667 10618-10978/? W/System.err: at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
05-04 16:32:40.667 10618-10978/? W/System.err: at com.codename1.impl.CodenameOneThread$1.run(CodenameOneThread.java:60)
05-04 16:32:40.667 10618-10978/? W/System.err: at java.lang.Thread.run(Thread.java:818)
If I force close my app only (without sleep my tablet), there is no problem with my preferences values.
This problem doesn't occurs in iOS/Simulator/Emulator(Android). I've only noticed it on a Samsung Galaxy Tab A running Android 6.0.1
Thanks in advance.
It's possible that this relates to threaded access to the preferences which should be legal. I've made the two potentially disruptive methods synchronized in today's update and hopefully this would resolve that issue.
In my case, I copied a working project to start a new one. And I left the file
keystore.jks (keystore to upload to Google Play) empty, so when I compiled I got this exception.
I just removed the signingConfig line in android/buildTypes section in the application level build.gradle, and it worked.
May be you had a problem of this kind, an empty forgotten file that shouldnt be empty.
Related
I'm using Promise to received callback from native module on React Native project, When I was connect to server to get data:
* The first, I called action "LOGIN"
* After received data from login I called action "GET_LIST",
But the response of action "GET_LIST", I received wrong as below:
09-06 08:48:22.117 13540-15635/? W/System.err: JNA: Callback com.lnzekesi.SoLibraryModule$1#8f35faa threw the following exception:
09-06 08:48:22.119 13540-15635/? W/System.err: java.lang.RuntimeException: Illegal callback invocation from native module. This callback type only permits a single invocation from native code.
09-06 08:48:22.125 13540-15635/? W/System.err: at com.facebook.react.bridge.CallbackImpl.invoke(CallbackImpl.java:30)
09-06 08:48:22.125 13540-15635/? W/System.err: at com.facebook.react.bridge.PromiseImpl.resolve(PromiseImpl.java:32)
09-06 08:48:22.125 13540-15635/? W/System.err: at com.lnzekesi.SharedLibraryModule$1.function_recv_msg(SharedLibraryModule.java:213)
09-06 08:48:22.125 13540-15635/? W/System.err: at java.lang.reflect.Method.invoke(Native Method)
09-06 08:48:22.125 13540-15635/? W/System.err: at com.sun.jna.CallbackReference$DefaultCallbackProxy.invokeCallback(CallbackReference.java:520)
09-06 08:48:22.125 13540-15635/? W/System.err: at com.sun.jna.CallbackReference$DefaultCallbackProxy.callback(CallbackReference.java:551)
09-06 08:48:22.125 13540-15635/? W/System.err: at com.sun.jna.Native.invokePointer(Native Method)
09-06 08:48:22.125 13540-15635/? W/System.err: at com.sun.jna.Function.invokePointer(Function.java:490)
09-06 08:48:22.125 13540-15635/? W/System.err: at com.sun.jna.Function.invoke(Function.java:434)
09-06 08:48:22.125 13540-15635/? W/System.err: at com.sun.jna.Function.invoke(Function.java:354)
09-06 08:48:22.125 13540-15635/? W/System.err: at com.sun.jna.Library$Handler.invoke(Library.java:244)
09-06 08:48:22.125 13540-15635/? W/System.err: at java.lang.reflect.Proxy.invoke(Proxy.java:393)
09-06 08:48:22.125 13540-15635/? W/System.err: at $Proxy2.cli_wait(Unknown Source)
This is my callback called from native module:
onMsg = new SoLib.fnCallback() {
public synchronized void recvMsg(Pointer cli, final Pointer msg) {
promise.resolve(getResponse(msg, resIndex));
//always delete recv msg
SoLib.msgDelete(msg);
}
};
SoLib.cliRegOnMsg(cli, onMsg);
SoLib.cliConnect(cli);
Additional Information
React Native version: 0.47.2
Platform: IOS, Android
Development Operating System: MacOS
Dev tools: Android Studio, Xcode
A ReactNative Promise object, like a JavaScript Promise, can only be called once. If you want to send something multiple times from a native module to JS, you should be using an event pattern using something like DeviceEventEmiter android, ios.
In my Codename One app that involves (Android) Native interface implementation, I receive on the device from time to time a ConcurrentModificationException which stack trace reads :
W/System.err: java.util.ConcurrentModificationException
W/System.err: at java.util.ArrayList$ArrayListIterator.next(ArrayList.java:573)
W/System.err: at com.codename1.impl.android.AndroidAsyncView.flushGraphics(AndroidAsyncView.java:380)
W/System.err: at com.codename1.impl.android.AndroidImplementation.flushGraphics(AndroidImplementation.java:1147)
W/System.err: at com.codename1.impl.CodenameOneImplementation.paintDirty(CodenameOneImplementation.java:580)
W/System.err: at com.codename1.ui.Display.edtLoopImpl(Display.java:1075)
W/System.err: at com.codename1.ui.Display.mainEDTLoop(Display.java:997)
W/System.err: at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
W/System.err: at com.codename1.impl.CodenameOneThread$1.run(CodenameOneThread.java:60)
W/System.err: at java.lang.Thread.run(Thread.java:841)
My code (Codename One part or the native interface implementation) does not use ArrayList andthe app can continue after clicking OK when the 'Internal Error' pops up, but I would prefer to avoid this error.
Where should I look at to prevent this error from happening ?
Any help greatly appreciated,
That means code is triggering a native repaint for some reason on a separate thread. Does your native code that interacts with the peer component do so using the Android native UI thread?
If not that might trigger a race condition.
Just after calling show() on a form that has either a video or image displayed I am seeing this in the logs of my codenameOne Android app:
07-01 12:43:08.790 3369-3406/? E/art: Throwing OutOfMemoryError "Failed to allocate a 4631116 byte allocation with 4380676 free bytes and 4MB until OOM"
07-01 12:43:08.800 3369-3406/? W/System.err: java.lang.OutOfMemoryError: Failed to allocate a 4631116 byte allocation with 4380676 free bytes and 4MB until OOM
07-01 12:43:08.800 3369-3406/? W/System.err: at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
07-01 12:43:08.800 3369-3406/? W/System.err: at android.graphics.Bitmap.nativeCreate(Native Method)
07-01 12:43:08.800 3369-3406/? W/System.err: at android.graphics.Bitmap.createBitmap(Bitmap.java:939)
07-01 12:43:08.800 3369-3406/? W/System.err: at android.graphics.Bitmap.createBitmap(Bitmap.java:912)
07-01 12:43:08.800 3369-3406/? W/System.err: at android.graphics.Bitmap.createBitmap(Bitmap.java:879)
07-01 12:43:08.800 3369-3406/? W/System.err: at com.codename1.impl.android.AndroidNativeUtil.renderViewOnBitmap(AndroidNativeUtil.java:163)
07-01 12:43:08.800 3369-3406/? W/System.err: at com.codename1.impl.android.f$b.m_(AndroidImplementation.java:2652)
07-01 12:43:08.800 3369-3406/? W/System.err: at com.codename1.p.y.B(PeerComponent.java:64)
07-01 12:43:08.800 3369-3406/? W/System.err: at com.codename1.p.y.a(PeerComponent.java:211)
07-01 12:43:08.800 3369-3406/? W/System.err: at com.codename1.p.h.b(Component.java:1323)
07-01 12:43:08.800 3369-3406/? W/System.err: at com.codename1.p.h.d(Component.java:1297)
07-01 12:43:08.800 3369-3406/? W/System.err: at com.codename1.p.h.a(Component.java:1272)
07-01 12:43:08.800 3369-3406/? W/System.err: at com.codename1.p.i.a(Container.java:1323)
07-01 12:43:08.800 3369-3406/? W/System.err: at com.codename1.p.h.b(Component.java:1323)
07-01 12:43:08.800 3369-3406/? W/System.err: at com.codename1.p.h.d(Component.java:1297)
07-01 12:43:08.800 3369-3406/? W/System.err: at com.codename1.p.h.a(Component.java:1272)
07-01 12:43:08.800 3369-3406/? W/System.err: at com.codename1.p.i.a(Container.java:1323)
It only seem to happen when the image is a large file, and every time with a video.
Video is a peer component which means that in order to implement transitions properly we try to convert it to an image and back again. For some reason this fails here.
We are looking at a different approach for peer components which is partially explained in this issue. It should vastly improve things like video, html etc. but might be a bit challenging.
For now I would suggest disabling the transition to try to workaround this exception.
Yes, I have followed all the other instructions and links. My wearable app is definitely being packaged with the mobile one, but is not installing.
The debug version of the mobile.apk is 4.9MB and of wear.apk is 1.9MB. When I build signed release versions, the mobile.apk is 5.8MB so I believe the packaging is happening.
When I do an adb install of the mobile.apk on the handheld, I get the following errors in the logcat of the handheld (the app package is com.pipperpublishing.refwatch so note the strange refwatch-1 reference in the second error):
01-27 07:49:59.129 8729-8729/? W/System.err: android.content.pm.PackageManager$NameNotFoundException: com.pipperpublishing.refwatch
01-27 07:49:59.129 8729-8729/? W/System.err: at android.app.ApplicationPackageManager.getApplicationInfo(ApplicationPackageManager.java:303)
01-27 07:49:59.129 8729-8729/? W/System.err: at com.samsung.aasaservice.AASAUpdateReceiver.onReceive(AASAUpdateReceiver.java:33)
01-27 07:49:59.129 8729-8729/? W/System.err: at android.app.ActivityThread.handleReceiver(ActivityThread.java:2948)
01-27 07:49:59.129 8729-8729/? W/System.err: at android.app.ActivityThread.access$1800(ActivityThread.java:172)
01-27 07:49:59.129 8729-8729/? W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1498)
01-27 07:49:59.129 8729-8729/? W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
01-27 07:49:59.129 8729-8729/? W/System.err: at android.os.Looper.loop(Looper.java:145)
01-27 07:49:59.129 8729-8729/? W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5835)
01-27 07:49:59.129 8729-8729/? W/System.err: at java.lang.reflect.Method.invoke(Native Method)
01-27 07:49:59.129 8729-8729/? W/System.err: at java.lang.reflect.Method.invoke(Method.java:372)
01-27 07:49:59.129 8729-8729/? W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
01-27 07:49:59.129 8729-8729/? W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
01-27 07:50:54.219 771-11243/? W/System.err: java.io.FileNotFoundException: /data/app/com.pipperpublishing.refwatch-1: open failed: EISDIR (Is a directory)
01-27 07:50:54.239 771-11243/? W/System.err: at libcore.io.IoBridge.open(IoBridge.java:456)
01-27 07:50:54.239 771-11243/? W/System.err: at java.io.FileInputStream.<init>(FileInputStream.java:76)
01-27 07:50:54.239 771-11243/? W/System.err: at android.content.pm.PackageParser.getHashValueOfPackage(PackageParser.java:5141)
01-27 07:50:54.239 771-11243/? W/System.err: at com.android.server.pm.PackageManagerService.saveHash(PackageManagerService.java:18383)
01-27 07:50:54.239 771-11243/? W/System.err: at com.android.server.pm.PackageManagerService.access$5200(PackageManagerService.java:329)
01-27 07:50:54.239 771-11243/? W/System.err: at com.android.server.pm.PackageManagerService$20.run(PackageManagerService.java:18368)
01-27 07:50:54.239 771-11243/? W/System.err: Caused by: android.system.ErrnoException: open failed: EISDIR (Is a directory)
01-27 07:50:54.239 771-11243/? W/System.err: at libcore.io.IoBridge.open(IoBridge.java:446)
01-27 07:50:54.239 771-11243/? W/System.err: ... 5 more
I have tried a factory reset of the watch, resyncing, etc etc. Any ideas?
Here's my mobile build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.pipperpublishing.refwatch"
minSdkVersion 14
targetSdkVersion 23
versionCode 203
versionName "0.2.03"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
wearApp project(':wear')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:design:23.1.1'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.google.android.gms:play-services-identity:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-auth:8.4.0'
}
apply plugin: 'com.google.gms.google-services'
and my "wear" build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "com.pipperpublishing.refwatch"
minSdkVersion 21
targetSdkVersion 23
versionCode 203
versionName "0.2.03"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.support:wearable:1.3.0'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:support-v13:23.1.1'
compile 'com.google.android.gms:play-services-wearable:8.4.0'
compile 'com.google.android.gms:play-services-auth:8.4.0'
}
apply plugin: 'com.google.gms.google-services'
Only using the release .apk file will the wear application get automatically installed. It wont work using the debug key.
In case the application is signed with a release key, then check whether the application already exists in the android wear device.
So, after multiple uninstalls and reinstalls, but without changing any code, the install is now working. Sometimes I have to "Resync applications" to see changes on the phone. The whole process seems quite clunky.
I have a problem with a GAE project; I am using Eclipse and GAE plugin for Eclipse.
I downloaded the last GAE SDK and I have also tried with some of the previous ones.
When I build a project I get this error in my Eclipse console:
DataNucleus Enhancer (version 3.1.1) : Enhancement of classes
Encountered a problem: Unexpected exception
Please see the logs [C:\Users\ALESSA~1\AppData\Local\Temp\enhance7837945285064208066.log] for further information.
with the following log file
'java.lang.RuntimeException: Unexpected exception
at com.google.appengine.tools.enhancer.Enhancer.execute(Enhancer.java:76)
at com.google.appengine.tools.enhancer.Enhance.<init>(Enhance.java:71)
at com.google.appengine.tools.enhancer.Enhance.main(Enhance.java:51)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.google.appengine.tools.enhancer.Enhancer.execute(Enhancer.java:74)
... 2 more
Caused by: java.lang.IllegalArgumentException
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.datanucleus.enhancer.asm.ASMClassEnhancer.getClassNameForFileName(ASMClassEnhancer.java:272)
at org.datanucleus.enhancer.DataNucleusEnhancer.getFileMetadataForInput(DataNucleusEnhancer.java:727)
at org.datanucleus.enhancer.DataNucleusEnhancer.enhance(DataNucleusEnhancer.java:525)
at org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1258)
... 7 more'
In another question, someone suggested to change the Datanuclues JDO/JPA version used.
Originally it was the v2; then I changed to v1 and I continued to get an error. In particular:
An error occured for ClassEnhancer "ASM" when trying to call the method "org.datanucleus.enhancer.asm.ASMClassEnhancer" on class "getClassNameForFileName" : null java.lang.IllegalArgumentException
I have the original GAE SDK with the default version of datanucleus and datanuclues appengine plugin