tchvu3 / capacitor-voice-recorder

Capacitor plugin for voice recording
MIT License
75 stars 61 forks source link

Unable to build on Capacitor 4 #27

Closed justjoshin83 closed 1 year ago

justjoshin83 commented 1 year ago

I have an ionic 6 project using Capacitor 4. When compiling the project, I get the error seen below:

C:\project\MainActivity.java:10: error: package com.tchvu3.capvoicerecorder does not exist
import com.tchvu3.capvoicerecorder.VoiceRecorder;

My package.json has this:

"capacitor-voice-recorder": "^4.0.1",

This was working when I was using an older version of Capacitor. I tried uninstalling and re-installing, but get the same error. Any help or suggestions would be much appreciated.

tchvu3 commented 1 year ago

After installing the plugin have you synced you android version? Try running: "npx cap sync android" and see if it fix your problem. Please let me know if it worked or not so I can close this issue in case of success

justjoshin83 commented 1 year ago

Thanks so much for the quick response! So I actually tried running that command a few times and unfortunately I'm still having the same issue. Please let me know if I can try anything else, or provide you with more information. Thanks!

tchvu3 commented 1 year ago

Our of curiosity, where are you importing the library in your Android code? Since capacitor 3 you don't need to manually add the plugin in your main activity

justjoshin83 commented 1 year ago

So I'm not manually importing the library anywhere... It's being imported as part of whatever the plugin does during the build from Ionic to Android code. That said, after looking at the Android code, it appears to be getting imported in the MainActivity. So I removed the line with the capvoicerecorder import and the build finished successfully. Perhaps when I upgraded from an old version of Capacitor it didn't remove that import automatically?

My apologies for the trouble, and thank you for following up with the perfect solution; you saved me a ton of time :)