Android Studio 踩坑记录,持续更新

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_38061916/article/details/86593751


由于使用 Android Studio 也有些时候了,一路上踩的坑也很多,为了以后遇坑有个参考,特此记录一下目前为止的坑。

一、调试应用时报错:Could not connect to remote process. Aborting debug session.

症状

Could not connect to remote process. Aborting debug session.

解决办法

1、在 app Module 的 build.gradle 文件中加入:

...
android {
    ...
    buildTypes {
        release {
            ...
        }
        debug {
        	// 加入下面三行。
            debuggable true
            jniDebuggable true
            renderscriptDebuggable true
        }
    }
    ...
}
...

2、如果这个应用调试的时候不设置启动 Activity 的话会永远报上面的错误,解决方法:
(一)点击 app ,选择 Edit Configurations。
一
(二)在 Edit Configurations 窗口左边选择 app ,然后右边选择 General ,点击 Launch 右边的选择框选择 Default Activity
二1
二2
(三)点击右下角 OK 按钮。

二、Gradle Build 构建到 :app:preDebugAndroidTestBuild 时报错 Conflict with dependency ‘com.android.support:support-annotations’ in project ‘:app’. Resolved versions for app (26.1.0) and test app (27.1.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.

症状

运行或调试应用程序构建到:app:preDebugAndroidTestBuild 这一步时报错:

Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (26.1.0) and test app (27.1.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.

解决办法

在 app Module 的 build.gradle 文件中加入:

...
android {
    ...
}
...
// 加入下面的内容。
configurations.all {
    resolutionStrategy.force 'com.android.support:support-annotations:27.1.1'
}
...
dependencies {
    ...
}
...

持续更新中

猜你喜欢

转载自blog.csdn.net/qq_38061916/article/details/86593751