今天做導(dǎo)航欄的適配泞辐,除了在模擬器運(yùn)行笔横,還要在真機(jī)測(cè)試。
模擬器咐吼、vivo手機(jī)都沒問題吹缔,可在華為上卻無法安裝。
檢索了一大圈锯茄,換了好幾次關(guān)鍵詞厢塘,才找到了原因。
沈文昌的博客:更正-INSTALL_FAILED_TEST_ONLY真正原因
文章提到了一個(gè)stackoverflow上的問題
帖子里有個(gè)回答里面提到官方網(wǎng)站在beta7版本已經(jīng)有了提示: 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).
也就是說studio3.0版本開始肌幽,run運(yùn)行生成的apk一定是testonly的晚碾,其application中會(huì)有 testOnly="true"屬性(為了驗(yàn)證,我還反編譯查看了)牍颈,而testonly的軟件只能通過adb安裝迄薄,如果apk脫離studio,不通過adb安裝煮岁,那么就通過Build>Build Bundle(s) /APK(s)>Build APK(s)來生成apk讥蔽。
問題解決!