App not installed error

I am not able to install APK file on real device. when I click install i got error App not installed. I made sure to configure the device to accept installations from unknown sources. The generated the APK using the the following commands:
ionic capacitor build android --prod
ionic capacitor build android --prod --release
ionic capacitor build android --release

I tried to install a signed and unsigned APK but both didn’t work. the same error App not installed no more details.

what makes it weird is that the APKs are working fine on android emulator devices. and on the browser and ionic lab virtual devices.

I am new to ionic i have no idea where to start working to fix this issue.

Can you describe the process you are using to install the APK? Are you doing this from inside Android Studio? Some other IDE? Have you tried using adb install from a command line?

Thanks for your reply.
when I run the command line ionic capacitor build android --prod Android studio automatically opened with android project inside. so I click the Run button and I can see the new changes I made on the emulator. then I get the APK file from android\app\build\outputs\apk\debug
and then I send it to my phone to install it but I got App not installed error

I tried to install a signed APK as I found other have mentioned that it might solve the issue. So i signed it using the following commands:

Generated keystore:

generate keystore : keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000

Sign the APK:
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore app-debug.apk alias_name

Optimize the APK:

zipalign -v 4 app-debug.apk HelloWorld.apk

I would suggest ignoring the signing issue for now, because I’ve definitely run Ionic/Capacitor apps straight from development on a device, without signing.

If adb can see your device, Android Studio should be able to as well. Personally, I use TCP mode, so that I don’t have to have my device physically connected via USB, but either way, you should ensure that your device shows up at a command line listed when you run adb devices.

Once it does, you should see the physical device in the popup menu of run targets that is immediately to the left of the green “run” arrow in the Android Studio toolbar.

Thank you I can run the app on the device when I have the device plugged in to the pc. Android studio can recognize my device so when I click run it runs on the device. but since I am working with a client and I need to send him a demo, I need to be able to send him the apk and install it directly on his phone. do you think if i uploaded the app to the play store will solve the issue? so the client can install it from the store and on my end i push the update to the store. if this works I can go with this solution…

The store is one option, but another would be to send them the APK and have them sideload it using adb or Android Studio.

Thank you again. do you have any idea why I am not able to install the apk file if it has been normally sent to a device?

Once the app loads in the Android Studio, you need to sign it from there. Go to the Build → Generate Signed Bundle / APK menu. From there, choose the APK radio button. If you do not already have a keystore, you should hit the Create New Button and select where you want to save the key. Give it a password and an alias. (Make something up for the alias). You will then fill out some additional information and select the type of build you want to do; debug or release. Choose release. Android Studio will then build the APK file and show you the location of the file in the event log at the bottom. Click on the link that says locate and it will take you to the folder where the APK was created. Good luck trying to email it. I was not able to. Instead, I created an APK mime type on my server and provided a link to the file. All the end user has to do is click on the link and the file will automatically download.

The APK mime type you need to add to your server is:

application/vnd.android.package-archive

I know this mime type is what works for IIS.

Good luck…

My project did not still work

I’m sorry to hear that, but if you don’t provide any further information, neither can I.