Android APK not installing in device - android

I have created Same project as two WorkSpace in my system .
ex: AppSampleHindi and AppSampleEnglish,
once i run the app i am getting error so how to solve this error.
and instant run option is not there in my android studio
$ adb install-multiple -r -t /Users/Name/Desktop/AppName/app/build/intermediates/resources/instant-run/debug/resources-debug.apk
Error while installing apk

Make sure that the two projects have different package names, otherwise installation will fail.
Open your AndroidManifest.xml file and look for "package" property.

Related

Failure [INSTALL_FAILED_TEST_ONLY] Error while Installing APK [duplicate]

I am having issues installing an apk to my device.
adb install <.apk>
Using the above command returns the following:
5413 KB/s (99747 bytes in 0.017s)
pkg: /data/local/tmp/AppClient.TestOnly.App3.apk
Failure [INSTALL_FAILED_TEST_ONLY]
Any idea on what might cause this issue?
It definitely recognizes the device. Could it be an issue with the apk?
Looks like you need to modify your AndroidManifest.xml
Change android:testOnly="true" to android:testOnly="false" or remove this attribute.
If you want to keep the attribute android:testOnly as true you can use pm install command with -t option, but you may need to push the apk to device first.
$ adb push bin/hello.apk /tmp/
5210 KB/s (825660 bytes in 0.154s)
$ adb shell pm install /tmp/hello.apk
pkg: /tmp/hello.apk
Failure [INSTALL_FAILED_TEST_ONLY]
$ adb shell pm install -t /tmp/hello.apk
pkg: /tmp/hello.apk
Success
I was able to reproduce the same issue and the above solved it.
If your APK is outside the device (on your desktop), then below command would do it:
$ adb install -t hello.apk
I had a similar problem with Android Studio 3.0.0 Beta 7 and could not publish anymore to the play store.
As stated here: https://developer.android.com/studio/run/index.html
Note: The Run button builds an APK with testOnly="true", which means
the APK can only be installed via adb (which Android Studio uses). If
you want a debuggable APK that people can install without adb, select
your debug variant and click Build > Build APK(s).
Same goes for release build, with Android Studio 3 you need to go to Build > Build APK(s) to have a non testable release apk that you can submit to the store.
Add -t install flag, as on the screenshot below:
In my case this mistake was in unstable gradle version. Just use a stable version of gradle (not alpha, not even beta). And it was fixed for me
After searching and browsing all day, the only one works is adding
android.injected.testOnly=false
to the gradle.properties file
I agree with Elisey. I got this same error after opening my project in the 2.4 preview and then opening the same project in android studio 2.3
Fixed the issue by changing this line in build.gradle from
classpath 'com.android.tools.build:gradle:2.4.0-alpha5'
to
classpath 'com.android.tools.build:gradle:2.3.1'
None of the previous post solve my issue. Here is what's happening with me:
I normally load the app from android studio by clicking on the "Run" button. When you do this, android would create an app that's good for debug but not for install. If you try to install using:
adb install -r yourapk
you will get a message that says:
Failure [INSTALL_FAILED_TEST_ONLY]
When this happens, you will need to rebuilt the apk by first clean the build, then select Build->Build APK. See the image bellow:
This APK is ready to be installed either through adb install command or any other methods
Hope this helps
David
Android studio 3.0 generates test only APK.
I have solved the issue by adding the "android:testOnly" property to android manifest's tag.
<application
.....
android:testOnly="false"
android:theme="#style/AppTheme">
And then generated the APK by Android studio3.0 menu:Build-->Build APK(s).
More Info:
https://commonsware.com/blog/2017/10/31/android-studio-3p0-flag-test-only.html
add this line to your ‘gradle.properties’
android.injected.testOnly=false
If you want to test the apk, just add the -t command line option.
Example command:
adb install -t .\app-debug.apk
In my case was by uploading an APK, that although it was signed with production certificate and was a release variant, was generated by the run play button from Android studio.
Problem solved after generating APK from Gradle or from Build APK menu option.
In my case, using Android Studio 4.0, the below solved the issue;
Add to 'gradle.properties' file;
android.injected.testOnly=false
Android 3.6.2 or later
Build >> Build/Bundle apk >> Build apk
Its working fine.
I see the accepted answer but you dont have to actually push the apk and then run the command on adb shell direct adb install with -t flag actually works
adb install -t "path to apk in ur computer"
attaching a screenshot for reference
This works for me:
adb install -t myapk.apk
The easiest to solve this, without reverting to an older gradle version is to add the '-t' option in the run configurations (for pm install).
testOnly='false' had no effect whatsoever. The error is caused by the alpha version of gradle plugin that makes debug APK 'for test only purposes'. The -t option allows such APK to be installed. Setting it in run configuration makes it automatically install you APK as usual.
My finding is as below. If I compile using the Android Studio UI, and the APK generated, I can't just
adb install <xxx.apk>
It will generate Failure [INSTALL_FAILED_TEST_ONLY]
I need to compile it using the gradle i.e. ./gradlew app:assembleRelease. Then only the generated apk, then it can only be installed.
This is because the Android Studio UI Compile, only generate test apk for a particular device, while ./gradlew app:assembleRelease command is the actual apk generation to be installed on all device (and upload to playstore)
I don't know if it's gonna be useful for anyone or not, but I got this error message, when I accidentally tried to build and install my project with test gradle plugin ('gradle:2.4.0-alpha5') version in stable Android Studio version (2.3, not in 2.4 preview 5 version I'd downloaded and installed before).
When I realized my mistake, I launched preview Android Studio version and it built and installed my project without any problem.
As mentioned in documentation:
Android Studio automatically adds this attribute when you click Run
So, to be able to install your apk with adb install <path to apk file> you need to assemble build from terminal: ./gradlew assembleDebug and install with adb. Or just run ./gradlew installDebug to build and install on the device simultaneously.
Build your distribution .apk from Android Studio as follow
Build --> Build Apk(s) (for unsigned build)
Build --> Generate Signed APK ( for signed build)
These option builds the APK with android:testOnly="false" option which allows you to install the APK expicitly into device by the commond.
adb install yourBuilT.apk
What worked for me is performing Refresh all Gradle projects from the Gradle toolbar from the right menu.
PFB the screenshot from Android Studio.
Select Gradle toolbar from the right menu.
Select the Refresh icon
This resolved the issue for me.
Although I am sure Saurabh's answer will work for most other people, I did want to identify the extra steps I had to take in order to get my apk installed.
I tried pushing to the device with the following result:
? adb push AppClient.TestOnly.App3.apk \tmp\
failed to copy 'AppClient.TestOnly.App3.apk' to '\tmp\': Read-only file system
After looking around to change the filesystem RW permissions I ended up executing the following commands:
? adb shell
255|shell#android:/ $ su
shell#android:/ # mount -o remount,rw /
mount -o remount,rw /
I got this when I tried to push again:
? adb push AppClient.TestOnly.App3.apk /tmp
failed to copy 'AppClient.TestOnly.App3.apk' to '/tmp': Permission denied
I was able to push to the sdcard:
? adb push AppClient.TestOnly.App3.apk /sdcard/
3178 KB/s (99747 bytes in 0.030s)
At which point I was able to execute Saurabh's command:
shell#android:/ # pm install -t /sdcard/AppClient.TestOnly.App3.apk
pm install -t /sdcard/AppClient.TestOnly.App3.apk
pkg: /sdcard/AppClient.TestOnly.App3.apk
Success
For me it has worked execute the gradle task 'clean' (under :app, at Gradle pane, usually located at the right) and run again the project.
I tried external project, with multiple apk.
The command from Studio, looked like
adb install-multiple -r ....
Solution -
select console
aste command with -t
If you are looking for a less permanent solution then adding android.injected.testOnly=false to your gradle.properties file and you don't mind using the command line then the following two commands before installation will do:
rm -v **/build/**/AndroidManifest.xml
gradle build
For Windows users: delete all AndroidManifest.xml from all build directories. But not from the src directories so DEL /S is not the best idea.
I got the same issue and no answer helps.
At last, I find there's still an install in my Safe Folder(Or Secure folder depending phone brands), which had not been removed when Android uninstalled the ordinary install. Remove it and this issue fixed.
Hope this can help some guys else!
first remove the unstable version:
adb uninstall problematic-package-name
; and then reinstall the apk.

Install any apk from Eclipse

I want to install apk from within Eclipse IDE by right-clicking on apk file (that may be in any project, no need for ADT).
The system command to execute is adb install app-name.apk
How to archive that in Eclipse IDE ?
To run some tool Eclipse External tool may be used (that I don't know well),
but that will not appear in context menu for right-button mouse click.
Eclipse lets you right-click any file, and use Open With -> Other , where you can choose any external program or script. On Windows, I created a simple batch script with below line (you should be able to do something similar on other platforms)
adb install -r %1
and in eclipse, i right-click an apk file, and choose Open With -> Other -> above batch script , Eclipse then successfully installed the APK.
Another option: you can create Eclipse plugin, using its Commands interface. This lets you add a context-menu/right-click action. You can execute your adb command from there. Creating this plugin can be easy, please take a look at this code snippet for a sample.
Ideally you would want to use the -r option so it re-installs if apk already present on device : adb install -r app-name.apk.

How to import android apk

I have been sent an android app to test. I saved the apk to my desktop, but now I don't know what else to do. How do I import it into androis studio? I know this is a very basic question but please be detailed, thank you.
Connect your android device (or start an emulator), go to the command prompt, change directory to where the apk is, and enter adb install apkname
Please follow the below steps to install apk file.
1.First run the emulator.
2. open the sdk specified path and find the platform tools folder.then copy the apk file and store it inside the platform-tools folder.(G:android-sdks\platform-tools).
3.open the command prompt and change the directory to android-sdks/platform tools.
4.enter the command : adb install apkfile name.
5.if you are getting success in command prompt the apk was sucessfully installed in your emulator..

android Failed to start emulator:Cannot run program

I have installed android SDK and android eclipse plugin successfully on Ubuntu.
Every thing was working fine until I removed Ubuntu and installed Linux Mint.
I installed the SDK again and used the same eclipse copy I was using on Ubuntu but now all the android applications contain errors and I can not start the emulator.
When starting the emulator this message appears
Starting emulator for AVD 'test' Failed to start emulator: Cannot run program "/home/anas/android//tools/emulator": error=2, No such file or directory
While the android SDK is installed in the specified path and the file (emulator) is exists in the same path.
Also all my applications contains the same error R can not be resolved to a variable
What is the problem here?
Installed on Ubuntu successfully.
but not running avd
If you're running a 64-bit system, you need to install ia32-libs
sudo apt-get install ia32-libs
R can not be resolved to a variable
This can be due to following Reason
class is not the part of that package add proper package
not properly defined in manifest file class path define it properly
clear and run the avd it will work
If cmd from fist comment doesn't work like in my case (64bit Crunchbang) then you may also try with :
sudo aptitude install ia32-libs lib32ncurses5 lib32stdc++6
I solved it doing a backup of the "emulator" and creating a symbolic link to the correct emulator:
mv emulator emulator_bup
ln -s emulator64-arm emulator
I used the command-line tool android (android avd), and used Tools->Manage SDK to install 64 bit emulators. I then mv'ed emulator to emulator.old, and emulator64-arm to emulator. Now the AVD starts up.
You do not need install packages any more!
In directory tools, there are many types of emulator, while my computer works with emulator64-arm! My system is Linux Mint 16 amd64! Good luck!
./emulator64-arm #yxphone -sdcard yxsd -scale 0.8
Like you have written the specified path and the files are exists in the same path, but i suggest to check that one more time.
and like you are getting R cannot be resolved to a variable, do not worry:
Reasons:
Check Package name in Manifest File
If you are already getting something like this: import com.version.bajrang.january.R;
so first of all try to change package name here, or secondly just delete this line and
clean your program
If you are not getting something like: import com.version.bajrang.january.R;
then add import packagename.R;
I believe that you will get your answer.....
It looks like your SDK path in eclipse has a mistake:
Cannot run program "/home/anas/android//tools/emulator"
That double "//" may be the problem. Check in Eclipse: Window -> Preferences -> Android. There should be a field there pointing the SDK Location. Edit it.
Check your path : /home/anas/android/ to see if it really is where you put your SDK . If not repeat these steps to have it
The missing R resource message is a compile error right? Then in this case your emulator should not be the problem. However, if your SDK path is incorrect like I suspect, then .. you can expect this compile error along with any other android libraries import
This is sorted by running this on Ubuntu.
sudo cp ~/Android/Sdk/platform-tools/adb /usr/bin/adb
Refer this: Can't connect to emulator through ADB genymotion

Can I run an APK file in the Android emulator?

Can I run an APK file in the Android emulator? I have to look at the UI design of an application, but only the apk is provided.
Assuming you have an emulator created and started (which you can do with the AVD manager,) you can install an apk by running:
adb install WhateverApp.apk
from the terminal. The adb command comes with the SDK and is under platform-tools/. Then just run it in the emulator.
Yes you can run apk in the emulator . for that you need to install apk in emulator ..
Steps To Install APK in Emulator
Open Command Prompt
Now Go to tools or platform-tools . Ex(E:\android-sdk\tools)
Then type this command adb install [apk file name whenever it stored]

Categories

Resources