Programming

INSTALL_FAILED_TEST_ONLY로 ADB 설치가 실패 함

procodes 2020. 6. 1. 20:42
반응형

INSTALL_FAILED_TEST_ONLY로 ADB 설치가 실패 함


장치에 APK를 설치하는 데 문제가 있습니다.

adb install <.apk>

위 명령을 사용하면 다음이 반환됩니다.

5413 KB/s (99747 bytes in 0.017s)
        pkg: /data/local/tmp/AppClient.TestOnly.App3.apk
Failure [INSTALL_FAILED_TEST_ONLY]

이 문제의 원인에 대한 아이디어가 있습니까?

확실히 장치를 인식합니다. APK에 문제가 될 수 있습니까?


AndroidManifest.xml
변경 사항 android:testOnly="true"수정하거나이 android:testOnly="false"속성을 제거해야합니다.

이 속성을 유지하려면 android:testOnly로서 true당신은 사용할 수 pm install와 명령을 -t옵션, 하지만 당신은해야 할 수도 있습니다 push첫 번째 장치에 APK.

$ 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

나는 같은 문제를 재현 할 수 있었고 위의 문제가 해결되었습니다.

APK가 기기 외부에있는 경우 (데스크톱에서) 아래 명령으로 수행 할 수 있습니다.

$ adb install -t hello.apk

나는 비슷한 문제가 Android Studio 3.0.0 Beta 7있었고 더 이상 Play 스토어에 게시 할 수 없었습니다.

여기에 언급 된대로 : https://developer.android.com/studio/run/index.html

참고 : 실행 버튼은 testOnly = "true"로 APK를 빌드합니다. 즉, APK는 adb (Android Studio에서 사용)를 통해서만 설치할 수 있습니다. 사람들이 adb없이 설치할 수있는 디버깅 가능한 APK를 원하는 경우 디버그 변형을 선택하고 빌드> APK 빌드를 클릭하십시오.

상점에 제출 할 수있는 테스트 할 수없는 릴리스 apk가 Android Studio 3필요 하므로 릴리스 빌드도 마찬가지입니다 Build > Build APK(s).


-t아래 스크린 샷과 같이 설치 플래그를 추가하십시오 .

답은 빨간색 상자에 있습니다


제 경우에는이 실수가 불안정한 gradle 버전이었습니다. 알파 버전이 아니라 베타 버전이 아닌 안정적인 버전의 gradle을 사용하십시오. 그리고 그것은 나를 위해 고정되었습니다


하루 종일 검색하고 탐색 한 후에는 유일한 작품이 추가됩니다.

android.injected.testOnly=false

받는 사람 gradle.properties의 파일


나는 Elisey에 동의합니다. 2.4 미리보기에서 프로젝트를 연 다음 android studio 2.3에서 동일한 프로젝트를 연 후에도 동일한 오류가 발생했습니다.

build.gradle에서이 줄을 변경하여 문제를 해결했습니다.

classpath 'com.android.tools.build:gradle:2.4.0-alpha5'

classpath 'com.android.tools.build:gradle:2.3.1'

Android Studio 3.0은 테스트 전용 APK를 생성합니다.

"android : testOnly"속성을 Android 매니페스트 태그에 추가하여 문제를 해결했습니다.

 <application
    .....
    android:testOnly="false"
    android:theme="@style/AppTheme">

그런 다음 APK by Android studio3.0 메뉴 : Build-> Build APK (s)를 생성했습니다 .

추가 정보 : https://commonsware.com/blog/2017/10/31/android-studio-3p0-flag-test-only.html


이 줄을 'gradle.properties'에 추가하십시오.

android.injected.testOnly=false

필자의 경우 APK를 업로드하여 프로덕션 인증서로 서명했지만 릴리스 변형 이었지만 Android 스튜디오의 실행 재생 버튼으로 생성되었습니다. Gradle 또는 Build APK 메뉴 옵션에서 APK를 생성 한 후 문제가 해결되었습니다.


APK를 테스트하려면 -t명령 행 옵션을 추가하십시오 .

명령 예 :

adb install -t .\app-debug.apk

허용 된 답변을 볼 수 있지만 실제로 apk를 푸시 한 다음 adb shell direct adb install--t 플래그로 명령을 실제로 실행할 필요는 없습니다.

adb install -t "UR 컴퓨터의 APK 경로"

참조를 위해 스크린 샷 첨부 여기에 이미지 설명을 입력하십시오


이전 gradle 버전으로 되 돌리지 않고이 문제를 해결하는 가장 쉬운 방법은 실행 구성 (pm 설치)에 '-t'옵션을 추가하는 것입니다.

testOnly = 'false'는 전혀 효과가 없었습니다. 오류는 디버그 버전을 '테스트 전용'으로 만드는 gradle 플러그인의 알파 버전으로 인해 발생합니다. -t 옵션을 사용하면 이러한 APK를 설치할 수 있습니다. 실행 구성에서 설정하면 평소와 같이 APK가 자동으로 설치됩니다.


이것은 나를 위해 작동 adb install -t myapk.apk


그것이 누군가에게 유용할지 아닌지는 모르겠지만 실수로 테스트 gradle 플러그인 ( 'gradle:2.4.0-alpha5') 버전으로 안정적인 Android Studio 버전 ( 2.3, 2.4 preview 5버전 I이 아닌 )으로 프로젝트를 빌드하고 설치하려고 할 때이 오류 메시지가 나타납니다. 이전에 다운로드하여 설치했습니다).

실수를 깨달았을 때 Android Studio 버전 미리보기를 시작했으며 아무런 문제없이 프로젝트를 빌드하고 설치했습니다.


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:

안드로이드 APK 빌드

This APK is ready to be installed either through adb install command or any other methods

Hope this helps

David


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

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)


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.


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.

  1. Select Gradle toolbar from the right menu.
  2. Select the Refresh icon

This resolved the issue for me.

Android Studio 스크린 샷


I tried external project, with multiple apk.

The command from Studio, looked like

adb install-multiple -r ....

Solution -

  • select console
  • aste command with -t

As mentioned in documentation:

실행을 클릭하면 Android Studio가이 속성을 자동으로 추가합니다

따라서 apk를 설치하려면 adb install <path to apk file>터미널에서 빌드를 조립 ./gradlew assembleDebug하고 adb로 설치해야합니다. 또는 ./gradlew installDebug장치에서 동시에 빌드하고 설치하기 위해 실행 하십시오.


먼저 불안정한 버전을 제거하십시오.

adb uninstall 문제가있는 패키지 이름

; APK를 다시 설치하십시오.

참고 URL : https://stackoverflow.com/questions/25274296/adb-install-fails-with-install-failed-test-only

반응형