I've finally completed building my own first flutter app, a lot thanks to SO. But I've still got an issue about testing my flutter apk in others' devices. So, finally i got 'app-release.apk', 'app.apk' and few more apk-related files. So excited, I sent those files to my friends, but friends told me that the app is well downloaded but not able to open it. So here's the question! Is there any additional essential commands to successfully open the apk file on real android device? If so, is there really no way to install and successfully open and use .apk or .aab flutter app in my friends' android device? I want to test my app in friends' device BEFORE google's review is done! Thank you in advance [:
Hey congratulations that you have completed the first app.
you have to run this command
flutter build apk --split-per-abi
this command gives your three apk file so you have to ask your friend that which processor he has. Depends on it you will give it.
<app dir>/build/app/outputs/apk/release/app-armeabi-v7a-release.apk
<app dir>/build/app/outputs/apk/release/app-arm64-v8a-release.apk
<app dir>/build/app/outputs/apk/release/app-x86_64-release.apk
Make sure your app is running perfectly in release mode as well
you can verify it via flutter run --release -v.
-v means verbose you can see the complete logs of your flutter app
I use VSCode so can't comment on AS. Basically though, to give your friends apks that they can side load on Android devices. In the terminal, first do a Flutter clean and when it completes execute 'flutter build apk --target-platform android-arm64'. The resultant app.apk in your outputs folder should be able to run on their devices.
Related
I want to build APK from the flutter project and share it to someone to review. I followed the docs, but the problem is when he tries to open the APK he gets
"there was a problem parsing the package"
I tried it on another device and gets
"App not installed"
I think the problem is in the APK file, So how I can build a correct APK that works on real devices?
I keep the name of the file "app.apk" does that matter?
from the Flutter docs, to build an APK from the command line:
Run flutter build apk
(The flutter build command defaults to --release.)
This command results in an APK file:
[project]/build/app/outputs/flutter-apk/app-release.apk
take note of the path and ask name(app-release.apk)
if you would like to debug why the apk not running on physical device, install this app https://fbflipper.com/ on your system, and connect your mobile device though a usb cable, now when you run the apk, on the flipper app you will receive crash report that will help you understand why your app is crashing!
I recently started working with flutter. I have been making several test applications. They all work well on emulators.
But now I want to be able to use them on my cell phone.
I took the APK that is generated when I run the application in the emulator, indicated in this route:
But it always fails to install
So far, my applications are simple, Hello world, Add numbers, etc.
Any ideas?
How should I do it correctly?
First: Open your Terminal/Shell/Command Line and open the directory of the Flutter App in there (cd PATH_TO_YOUR_FILE)
You probably want to create a profile-mode apk for testing. This build still helps debugging while having the speed of the --release version:
This creates a single APK which works on all devices (x64, arm64 and arm), it's probably pretty big:
flutter build apk --profile
If the people who install your App know which devices they have, you can use the split-per-abi command which creates three different APKs for all architectures (x64, arm64 and arm)
flutter build apk --profile --split-per-abi
If you want to have a release build, you can use what #Niteesh commented:
flutter build apk --release --split-per-abi
Release-builds can be uploaded to Google-Play (also the internal testing)
Read more: https://flutter.dev/docs/testing/build-modes
the apk that is generated when you run the app is the debug-apk, it contains lots of overheads which helps in flutter hot reload and hot restart. The size of debug apk version is also a lot.
use this command to generate release version of apk
flutter build apk --split-per-abi
After execution of the command, you get the path of the apk, something like this
√ Built build\app\outputs\flutter-apk\app-armeabi-v7a-release.apk (7.0MB).
Then you can install that apk on your phone
So, I'm stuck with an error after generating APK with React-Native. I tried on multiple computers, 32-bit and 64-bit operating system and had no success.
How I got here
First, I created my app with
create-react-native-app suporteecontrole
Then I started developing my app, installing dependencies, and etc. After making sure that the APP was running without any errors, I ejected with the command line:
npm run eject
I've put my expo credentials and it worked without any errors too. I figured that it was going to work.
Generating APK's
To generate APK, i followed the instructions on this link:
React Native Build Signed APK
1 - I installed the JAVA 8 SDK, and all dependences too.
2 - I generated the Key by following the step one on the link.
3 - I changed all gradle files according to the link
4 - Then I runned this lines on cmd:
cd android
And
gradle assembleRelease
No errors popped up. I made it to the build successfully.
So, It generated some files: app-dev19-release.apk, app-dev-release.apk, app-devRemoteKernel-release.apk, app-prod-release.apk.
I installed app-prod-release.apk on my mobile, and returns an Expo error:
Could not load app
photo_2018-07-24_12-57-51
I searched Google for this, and found nothing.
Can anybody help me with this?
It is frustrating how the create-react-native does expo by default instead of normal react app. But you've already ejected from the expo app, and your code now wont be working on it.
Instead you'll see a new app on your phone with the name and icon you chose. Try to find the App and run it. And to assemble a release, you actually need to sign it too, so I hope you've done the signing right. Take a look at this https://facebook.github.io/react-native/docs/signed-apk-android.html for signing if you face that error.
I tried to reinstall an apk
$adb install -r new.apk
And it shows the error:
Failure [INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES]
One solution is to uninstall and install the new.apk, that works fine.
But I'm wondering whether I could re-build an apk and re-install without the uninstallation. Eg. change some config in the AndroidManifest.xml, or not sign the APK, etc.
It would be great appreciated if you could tell me the whole meaning of the "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES".
It means the new copy of your application (on your development machine) was signed with a different signing key than the old copy of your application (installed on the device/emulator). For example, if this is a device, you might have put the old copy on from a different development machine (e.g., some other developer's machine). Or, the old one is signed with your production key and the new one is signed with your debug key.
I ran into this while testing on a new Xoom. I had previously installed my app from the Marketplace. Later while trying to test a new version of the app I ran into this error.
I fixed it by removing the app that was installed via Marketplace (just hold and drag to the trash). Thereafter I was able to deploy my development version without any issue.
This happened to me when another developer on the team built our app on the hardware device I was trying to deploy to. Uninstalling the app from hardware fixed my problem.
This is the command to uninstall the app from device using adb:
adb uninstall <package name>
I got this error even after uninstalling the original APK, which was mystifying. Finally I realized that I had set up multiple users on my Nexus 7 for testing and that the app was still installed for one of the other users. Once I uninstalled it for all users the error went away.
I changed the package name while coding an update so that I could debug it on my device via Eclipse, without deleting the old version that was installed. Without reverting the package name I was using when trying to reinstall, I got this same error. Using the same package name the reinstall was successful.
Just delete the old build from the device and reinstall the same. Because device.keystore is already exist in the device so just uninstall the build and reinstall the APK thats all..
Thanks
I faced an another use case where I got the similar error.
When At first I got the error, I panicked, and removed /data/data/{package.name}
After that I tried, and my problem was still present.
Then I tried uninstall, it failed.
I then removed the apk file present in /system/app (required root access), and tried uninstall and it was successfull.
After that I tried re-installing the apk, it worked.
If you encounter a failed deployment to an Andorid device or emulator with the error "Failure [INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES]" in the Output Window, simply delete the existing app on the device or emulator and redeploy. Debug builds will use a debug certificate while Release builds will use your configured certificate. This error is simply letting you know that the certificate of the app installed on the device is different than the one you are attempting to install. In non-development (app store) scenarios, this can be indicator of a corrupted or otherwise modified app not safe to install on the device.
I had the same problem until I realised I had the simulator running and adb was trying to install on that
For what it is worth, I ran into this problem after adding a new plugin to my Cordova project. I had been having cordova do builds and install directly on the device via USB.
I fixed it by uninstalling the app from the device and on the next deploy there were no problems.
Nothing from above worked for me. The problem for me was that I had wrong source in my Java Build Path for android-support-v7-appcompat. When you go to Project> Build Path> Configure Build Path>. Under the Source tab make sure you have android-support-v7-appcompat/gen , android-support-v7-appcompat/libs and android-support-v7-appcompat/src and nothing else. Click OK and it should work.
I've had the same error today, but the problem wasn’t exactly the same. I’m using ADB with Android installed in VirtualBox. I tried to install different versions of my app (signed / not signed, debug / release mode) and got two errors alternatively : INSTALL_FAILED_UID_CHANGED and INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES.
Now, when looking at /data/data/{package.name}, I found a bunch of files that were still there after uninstalling the app. I tried to rm -rf them without success : I got I/O errors.
The solution to this was :
Shut down the VM
Mount the VDI image with vdfuse (read/write)
Repair the Partition1 image file with e2fsck
Umount and restart the VM
Since the verification is based on package's name, you can change the package name inside your config.xml or manifest file for another name you want.
When publishing your app don't forget to change back the name!
I had this problem trying to execute gradle task connectedDebugAndoidTest (or connectedAndroidTest) on Genymotion. Running it on normal emulator solved the problem.
I think , your app installed by other account.( multiple account mode feature ) You can uninstall app in Setting>Apps>"app name"> Uninstall
When trying to deploy my app to the Android device I am getting the following error:
Deployment failed because of an internal error: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE]
I am aware of this question but the app is not installed. It has been removed/partially removed by Visual Studio during the attempt to deploy.
In the past I solved this by downloading the app from the google play store and then removing it from settings->Application manager. However, now i am getting the error "incompatible update" when it is trying to install it.
I tried to remove it using Titanium Backup and few other things but no luck.
EDIT 1
I realised (from #Motz) that I haven't mentioned that the obvious solution doesn't work. Namely, the app doesn't appear in Settings->Apps
I've seen this several times. Usually, it's due to having a signed release version on my phone, then trying to deploy the debug version on top. It gets stuck in an invalid state where it's not fully uninstalled.
The solution that works for me is to open a command prompt and type:
adb uninstall my.package.id
That usually completes the uninstall in order for me to continue development.
No need to do an adb uninstall, just go to your settings->apps and then do uninstall from there. You will see your application grayed out.
The issues usually has to do with a release vs debug version such as #Kiliman noted here.
Uninstalling the application would be enough to avoid this problem.
INSTALL_FAILED_UPDATE_INCOMPATIBLE
but sometimes even uninstalling the message is raised again, it occurs in Android OS 5.0 +, so this is the solution:
Go to Settings > Apps and you will find your app with the message:
"Not installed for this user"
, we have to uninstall manually for all users with the option:
"Uninstall for all users"
You have to make sure the application is uninstalled.
In your phone, try going to settings/applications and show the list of all your installed applications, then make sure the application is uninstalled for all users (in my case I had uninstalled the application but still for others).
I usually face this issue on Android 5.0+ version devices. Since it has multi-user profiles accounts on the same devices. Every app will install as a separate instance for all users. Make sure to uninstall for all the users as below screenshot.
I accidentally had two devices connected.
After removing one device, INSTALL_FAILED_UPDATE_INCOMPATIBLE error has gone.
Uninstall the apk(app that you are working) from your android device and then run again.
You can just add a parameter to run, see:
Run --> Parameters
In field parameters add -cleaninstall
Now just run, they always will do a deep clean before install.
If you are using Samsung Device and by any chance marked your app for Samsung Knox, then you need to uninstall it from My Knox app.
Uninstalling just from General apps won't uninstall it from Knox App. It has to be done explicitly!
Ok uninstall the app, but we admit that the data not must be lost?
This can be resolve, upgrading versionCode and versionName and try the application in "Release" mode.
For example, this is important when we want to try the migration of our Database.
We can compare the our application on play store with actual application not release yet.
In my case. I installed the release-version app. And after uninstall the app from my device. Thing works fine.
Signature Mismatch your Previous Present APP and new APK
So Please uninstall the previous app and gradlew clean and again install apk
react-native run-android
react-native run-ios
Uninstall your app from connected device(emulator or mobile)
got terminal into project folder cd android
3 next run ./gradlew clean it clean your build
4 cd.. and run below
5 react-native run-android
the first, you must uninstall your app in emulator or device, after that you can cd ./android -> ./gradlew clean then build project again (run android or ios) -> solve
uninstall the app from emulate or smart phone and try to run again
In my case i was getting this when switched the Minimum target version of the android and when i changed back to original one (when i created project at first).
So for that uninstalling worked. But when i changed my android version to latest i was getting it again. To fix that, i went to properties of android project and in Android manifest section, i added a package name e.g com.dotnetdreamer.net. If you have already a package name then you can simply rename it to something else.
One simple way is rename your package name and run again
Delete all app files from Phone
To automate the deletion of an app on your phone you can use the steps below. It can be very useful to delete your app and app data on a quick and clean way.
Make a textfile with this code and save it as Uninstall.sh. Go to the folder (where you've put it) of this script in the terminal and do: sh Uninstall.sh YOURNAMESPACE
Now your namespacefolder (including saved appfiles and database) will be deleted.
echo "Going to platform tools $HOME/Library/Android/sdk/platform-tools"
cd $HOME/Library/Android/sdk/platform-tools
echo "uninstalling app with packagae name $1"
./adb uninstall $1
Delete all app files from pc
Make a textfile with this code and save it as DeleteBinObj.sh.
find . -iname "bin" -o -iname "obj" | xargs rm -rf
Go to the folder of your project where you place this script and do in the terminal: sh DeleteBinObj.sh
In case this helps someone,
I deployed my app to google play, when I uninstalled it and tried to run a debug on my device (new version) I was getting this failed update message.
I couldn't see the app in my device (it was already uninstalled) so I:
Installed the first version again from google play
Opened Settings/App/App name
Cleared the Data
Cleared the Cache
Uninstalled the app
Now you can deploy the debug version again to the device :)
Using Ionic with Cordova via command line...
ionic cordova run android --prod
I ran into this and found that I had deleted the release version from a previous test install, but had an old debug version that was hanging out in apps drawer that I missed. I unplugged my device from the computer, opened the app drawer and used "Search apps.." to find all instances of the app to uninstall them. Then I re-plugged in the device to the computer and viola, it worked!
Thanks for the help everyone!
I Hope this will help somebody in the future but simply go to you config.xml, inside the widget tag, change the default id(io.ionic.starter) to your own id. Have a look at this for android package naming.
Uninstalling the application from all users may be the correct solution, but also be sure to check the Secure Folder or something like that for other devices.
I spent 2 hours of my life trying to figure out the reason for the problem (I only have one user on my personal tablet)
The reason I was unable to install the application is because I mistakenly installed the application via direct link from the "Internal Testing" to both current user and my secure folders.
When you have the Secure Folder active, the tablet name appears twice: one or these is the Secure Folder. (accidentally installed on both)
Example here