所遇问题
使用Android Studio Electric Eel | 2022.1.1版本新建了一个Demo,USB真机调试报:INSTALL_FAILED_TEST_ONLY
根据以往经验立马在根目录的gradle.properties中添加:
android.injected.testOnly=false
添加完一运行还是不行,结果想了想老版本的Android Studio就可以为啥新版本不行,那肯定是配置问题,结果就想到了是不是gradle版本问题?就试了试改了一下gradle版本,然后再运行就可以了。
我的根目录下build.gradle默认配置如下:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.4.0' apply false
id 'com.android.library' version '7.4.0' apply false
}
默认gradle>wrapper>gradle-wrapper.properties配置如下:
#Thu Feb 09 16:39:18 CST 2023distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
解决方案
修改根目录下build.gradle版本配置为7.3.0:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.3.0' apply false
id 'com.android.library' version '7.3.0' apply false
}
只要小于7.4.0版本就行,版本过低的话要把wrapper.properties配置一起修改
插件版本和所需最低Gradle版本对照表
