Closed casper5822 closed 4 years ago
@casper5822 did you run:
npx cap sync android
which links plugin code to android project after npm install?
Yes i tried ionic cap sync android buth nothing. this is the output of sync command:
capacitor sync android ✔ Copying web assets from www to android/app/src/main/assets/public in 485.74ms ✔ Copying native bridge in 461.07μp ✔ Copying capacitor.config.json in 472.53μp ✔ copy in 574.21ms ✔ Updating Android plugins in 6.78ms Found 1 Capacitor plugin for android: capacitor-secure-storage-plugin (0.4.0) ✔ update android in 43.77ms
Android studio says not found the package but the app build and install correctly.
The other strange thing is when call: secureStorage.set(key,value) i get the exception, i m sure the data in the set are not null i try a little test when app starts:
SecureStoragePlugin.set("test","value").then(()=>{ alert("saved")})
In this case the alert never show up.
so could be related to the import problem?.
@casper5822 your call
SecureStoragePlugin.set("test","value")
correct call
SecureStoragePlugin.set({ key, value })
There are missing curly braces. paramater to the set method is single object with key and value properties.
Ok thanks fixed the problem with set and get. But i don't know why android studio doesn't find the package.
I made the sync, i have no idea.
Maybe just some cache problem. I am closing this issue.
I add the plugin in my ionic 4 capacitor app and add the plugin in the main activity but the import fails because the package is not found:
import com.whitestein.securestorage.SecureStoragePlugin;
The app builds and install correctly but i had this error in the logcat:
Capacitor/Plugin: Attempt to invoke virtual method 'byte[] java.lang.String.getBytes(java.nio.charset.Charset)' on a null object reference java.lang.NullPointerException: Attempt to invoke virtual method 'byte[] java.lang.String.getBytes(java.nio.charset.Charset)' on a null object reference at com.whitestein.securestorage.SecureStoragePlugin._set(SecureStoragePlugin.java:73) at com.whitestein.securestorage.SecureStoragePlugin.set(SecureStoragePlugin.java:32) at java.lang.reflect.Method.invoke(Native Method) at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:99) at com.getcapacitor.Bridge$1.run(Bridge.java:520) at android.os.Handler.handleCallback(Handler.java:789) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:164) at android.os.HandlerThread.run(HandlerThread.java:65)