INSTALL_FAILED_TEST_ONLY in Android studio 2.4 preview 7 - android

I'm using Android Studio 2.4 preview 7 version. But, when I build debug apk and install via adb command or put apk file in sdcard of device it always gives me same error "App not installed" in any of android phone. I have got INSTALL_FAILED_TEST_ONLY error in Android Logcat every time at the time of installation in any android device.

If you analyze your apk file you'll see the problem easily - namely that when building the project with the mentioned Android Studio version, the Gradle plugin is automatically injecting an android:testOnly=true to the final AndroidManifest.xml file of the output apk.
You can read more about this property and what it's used for HERE.
To workaround this problem - you can still install the app using this command:
adb install -t debug.apk
If you want to build a signed release version of your app (e.g. for publishing the Play Store), you can always do so via Build -> Generate Signed APK. The result is an apk without the mentioned property and can be installed on any device.
If you want a bit of context why this property is injected, perhaps check THIS and THIS issues on the AOSP bug tracker.

Related

React Native AppCenter build problem - "JAVA_HOME_11_X64"

I updated most app packages, updated gradle (distributionUrl=https://services.gradle.org/distributions/gradle-7.5-bin.zip) and gradle tools ('com.android.tools.build:gradle:7.3.0').
I can make apk file through android studio. I can work with the emulator.
I tried to build via AppCenter and got an error that I need to use JAVA 11.
In the builder configuration, I inserted the parameter - JAVA_HOME => $(JAVA_HOME_11_X64).
The build was assembled successfully.
But if I try to install apk on my phone I get an error (see screenshot)
Also, the size of the apk file has increased by 2 times, which is very strange.
I can't install the apk file created through the AppCenter.
Perhaps someone faced such a problem? I will be grateful for advice.
image

APK failed to install on AVD despite installing on actual device

I created a Kivy app and created a debug APK using Buildozer in a Linux virtual environment (my host laptop is Windows). When pushing this to my phone, the app works perfectly fine and 100% as expected. Before trying to push this to the Play Store, I wanted to test it on different devices using an emulator.
I installed Android Studio on my host laptop (as I am more comfortable there than Linux) and copied my .apk over. When I try and drag and drop my .apk into my Android virtual device, I get an error that says:
APK failed to install
Error: Could not parse error string
I even tried installing it directly into my emulator, by navigating to the platform-tools folder in the Sdk file, and copy and pasting my .apk there, and then trying to install it directly from cmd using:
adb install myapp-0.1-armeabi-v7a-debug.apk
however then I get an error message saying
adb: error: failed to get feature set: no devices/emulators found
When I check this in Android Studio by going to Tools > SDK Manager > SDK Tools tab, it clearly says that SDK manager and Emulator are both installed.
What am I doing wrong, and how can I sort this?
Thank you
The reason for this was that the Android architecture needed to be x86 in order to run on the emulator.
To correct it, I had to change:
android.arch = armeabi-v7a
to
android.arch = x86
and then create the debug APK.
It might be necessary to change the p4a branch to develop and run a buildozer android clean to clean the build.

Google Play error: cannot upload a test-only APK

When trying to upload the first apk to a recently created project in GooglePlay console, I receive this error:
You cannot upload a test-only APK
Searching Google gives me 0 results for that exact string as per today.
I also have submitted a ticket for Play Console. Will update here if have any answer.
UPDATE Nov 29th 2017
As #paul-lammertsma suggested, there's a workaround. Still would be good to know why we need to go gradle way and we cannot do it via IDE.
Building your app through Android Studio 3.0 and later will add android:testOnly="true" to your application manifest, marking the APK as FLAG_TEST_ONLY for the PackageManager. More information on CommonsBlog here.
Attempting to install such an APK outside of Android Studio will fail with:
Failed to install app-debug.apk: Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]
Attempting to upload it to Google Play will also fail, with :
You cannot upload a test-only APK
There are four solutions to this:
Build from Android Studio
Simply select "Build APK(s)" from the "Build" menu in Android Studio.
Sign from Android Studio manually
Simply select "Generate Signed APK..." from the "Build" menu in Android Studio. Provide the keystore and enter the signing details in the dialog that displays.
Build through Gradle
You can of course simply execute Gradle from the terminal for some automation, for instance if your deployment cycle runs through CI (which I highly recommend!):
./gradlew assembleRelease
(Alternatively, you may prefer running this Gradle task from the Gradle pane from within Android Studio.)
Disable this feature in Android Studio
If you don't like this behavior, you may elect to add this flag to your gradle.properties. Beware that the test flag is for your own protection, so you don't accidentally publish a test-only APK!
# Disble testOnly mode for Android Studio
android.injected.testOnly=false
Looks like I found something very related:
ADB Install Fails With INSTALL_FAILED_TEST_ONLY
I'm using 2.4.0-alpha6 of gradle plugin and that's seems to be far from ready to be used for production.
So the solution is to use the latest stable gradle plugin:
classpath 'com.android.tools.build:gradle:2.3.1'
Click on Build and then press BuildAPK(s) and then upload it will work. Instant run APK on android studio 3.0 runs only on the device attached to adb.
I found this blog that addresses the cause of the "test-only" bug
https://commonsware.com/blog/2017/10/31/android-studio-3p0-flag-test-only.html
basically, there are two things to note about it:
You cannot install an app with android:testOnly="true" by conventional means, such as from an Android file manager or from a download off of a Web site
Android Studio 3.0 sets android:testOnly="true" on APKs that are run from the IDE
android studio 3.0 now sets this "testOnly" flag when you compile a release version using the green Run button (make project CTRL+F9).
The solution I found is to not call "make project", but to call either
build > build APK
or
build > Generate Signed APK...
I am using Android Studio 3.1 Canary 5
What I had tried (but not worked):
I tried all the answers as above,but Unfortunately I didn't get solution.
I removed kotlin dependency and signed but doesn't worked.
I tried use command line like ./gradlew assembleRelease
I tried to build apk using "Build APK" and "Generate Signed APK"
After all the possibilities I got solution by following way:
- Compile SDK Version changed from Android P to Android Oreo 27
- Changed AppCompat Version to 27.0.1
and Its successfully working now.
Thank you.
It worked for me. Try to run this and build again.
./gradlew assembleRelease
Maybe You are uploading the wrong apk file which is generated previously not the signed apk. So select the apk file by locating the exact path of the generated signed apk file.

Can't install unsigned Cordova apk

I just built a basic Cordova image, but I can't install it on my Android phone.
It says the package is corrupted.
I have enabled "Trust unknown sources" and copied the file onto my Nexus 6P.
The build process doesn't throw any errors, it creates a android-release-unsigned.apk file as expected.
Had the same problem as you because I followed the guide I linked in the comments above; that guide is for building a release build, not a test build.
In order to build a test build, do:
cordova build android
Which should create a file called debug-build.apk
In addition, if you have an android device set up for development, you can run:
cordova run android --device

Visual studio cordova tools - unable to run / debug / deploy to android. adb hangs

I'm trying to build / deploy and debug by pressing F5 on my Cordova Tools javascript project with a variety of android targets but the apk does not want to deploy.
It appears that the build completes and deploys successfully and the ADB console windows appears but remains blank. No app is deployed to a device or emulator.
Have tried Nexus 5, Samsung Galaxy Tab 2 and various emulators. All devices have been used as debug targets before
The thing that has changed is that I recently formatted my laptop and moved to Windows 10 Enterprise
I'm using a fresh installation of Visual Studio 2015 Enterprise
I can debug OK on Windows Phone 8.1, Windows 10
If I try and deploy the APK created from the console with ADB:
adb install android-debug.apk
I get
3715 KB/s (1141677 bytes in 0.300s)
pkg: /data/local/tmp/android-debug-unaligned.apk
Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED]
I haven't tinkered with the APK it is as it was built from VS
I have tried clearing the cache, checking the dependencies (both in Options) and checked for updates.
Any suggestions on how to move forward?
Thanks
Solved. Turns out the config.xml settings were incorrect. Config.xml > Common > Package name needs to be in reverse domain name notation for android to deploy to the device.
I hadn't noticed this however because I had only been using the Cordova Tools project to compile for Windows 8.1 / 10 devices and in these build configurations the package naming convention is not enforced
This caused the problem:
Package name: mycompany.myappname
This fixed the problem:
Package name: com.mycompany.myappname
Try in the command line/terminal, navigate to the root of your project folder, and enter "cordova platform remove android.” Then, rebuild the solution again (which will generate platform/android from a clean state)

Categories

Resources