Instant Run works but file . apk does not install

Asked

Viewed 1,351 times

0

Well, the problem I’m facing is that when I emulate mine app through the Instant Run the app goes perfectly on my smartphone. However, I cannot install the same app through the .apk generated.

Use the Android Studio 3.2.0.0

Obs.: the .apk is generated without errors, but when trying to install appears: app was not installed.

  • a silly question, but you uninstalled the debugging version of Instant run before installing apk manually?

  • Yes, I uninstalled and even tried to run the apk even on another device, also did not work.

2 answers

1


The Smartphone you want to install the .APK is the same as Instant Run ? "If yes" then it’s probably the PLAY PROTECT that does not allow you to install applications from unknown source. To resolve this, go to your play store account in the settings tab and turn off the protection service; "If not" then look at the Smartphone API version you want to install and the API of your app. See also what folders your layouts and images are located in (e.g.: Imagine you only have a name file main_activity.xml(v23). This file would only run on the V23 API version and if you want to install the app on an API 16 Smartphone, it will go bad). To solve this, have a file main_activity.xml in the briefcase layout and another in the folder layout-v23.

0

The safest way to generate an APK that will be installed manually (outside of Android Studio) is by using Gradle.

With a terminal open in your project folder, run the following command to generate a new APK:

On Unix: ./gradlew assembleDebug

On Windows: gradlew assembleDebug

Sometimes the APK generated by Android Studio is partial and/or contains the flag android:testOnly="true" on Androidmanifest.xml

  • After this command I got the following error on the terminal: ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your Environment to match the Location of your Java installation.

  • As the error message says, you must have Java installed and the variable JAVA_HOME configured in your PATH

  • Thank you, your comment with this link made me understand what I needed to do. After giving the command I managed to execute, and apparently was successfully created. Just still do not know which folder APK was created, since it is not in the default folder when building using Android Studio

  • I managed to do everything. But it didn’t work. ( APK doesn’t install yet

Browser other questions tagged

You are not signed in. Login or sign up in order to post.