Why I Run Apk sent out the boss, but not installed!

Why I Run Apk sent out the boss, but not installed!

A. Order

When we In Android Studio, a project directly Run, AS will automatically play a Debug of Apk, and by ADB command to install the App on our connected devices.

Run out of this Apk, can be found at the project's build / directory. If you also want to share this Apk out, first to experience functional, sorry, under normal circumstances, this Apk is not installed.

Then take a look, what led to Run out of the APK can not be installed.

Two. Run the Apk

2.1 textOnly property

We know, AS Run up Apk, will use the Debug signature is signed, but not installed, the signature is not a problem.

But because, Run out of the APK, will AndroidManifest.xml file, add android: textOnly property, precisely because of this property, prevents us from using the normal way to install APK.

android: testOnly corresponds ApplicationInfo in FLAG_TEST_ONLY, that have existed in the earliest Flag Api Level 4, using it will not have any lower version compatibility issues.

When you use adb install install android: When testOnly = "true" package, error messages output, clearly marked TEST_ONLY can not install a package.

Failed to install app-debug.apk: Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]

For many years experience of Android developers, who has been out of the Run Debug.apk share with others, the early years is the normal installation, it textOnly property is at what point is added to the Debug.apk it?

Although FLAG_TEST_ONLY property can be traced back APK Level 4, but it is in fact the default Android Studio 3.0 was only added to the APK. IDE only on the AS 3.0+, Run out of the APK, the default will bring textOnly property, which would prevent you from using the normal way to install.

Briefly summarized:

TextOnly = "true" the Apk: 1. We can not through the normal installation, install a android with.
2. This attribute is added in AS 3.0 in.

That's why you can not install Run out Debug.apk.

2.2 Why such a design?

The problem for most developers, is basically not a problem.

Because we put as long as the normal measure, the publishing process, it is very difficult to share a Run Apk out to others.

textOnly just a mark, the mark is a test version of it, in fact, does not have any substantive things. If because of mistakes in the process, share it out, it is also very easy to find, because the normal flow of the package can not be installed.

2.3 is not really can not be installed?

If we have to install the Apk with a textOnly, it is actually a way, whether the person is how the AS Run up the package, install it on the device?

The solution is very simple, just on adb install, you can increase -t.

adb install -t debug.apk

If you want to stop when the AS Run, built APK increase android: textOnly mark, but also a way.

Can gradle.properties file, you can increase android.injected.textOnly = false.

# gradle.properties
android.injected.testOnly=false

Then the android: textOnly property will disappear.

III. Summary moment

AS Run out of Apk, the reason can not be installed because it carries FLAG_TEXT_ONLY the Flag, it will prevent us from using normal installed. You want to install, can be solved by adb install -t.

Although this initial Flag to API Level 4, but in the AS 3.0, was added to the default. Want to get rid of it can be achieved by increasing android.injected.textOnly = false.

When this problem a little knowledge can find out, we normally do not encounter this problem, after all, who would put a Run out of the bag out of it.

references

At last

Well, the article written here is over, if you think the article is well written give a praise chant? If you think there need to be improved, please give me a message. Will be serious inquiry, insufficiently corrected. Thank you.

I hope you can read this and look forward to share my future will update the technology of dry cargo, thank you for your support!

Android architects of the road is long, encourage each other with it!

Guess you like

Origin blog.51cto.com/14332859/2447160