Android Studio Error

· 在 AS 中运行 java 类报错

详细信息
1
2
3
4
5
6
Error:Gradle: failed to create directory 'E:\jhrFile\SortApplication\app\build\generated\source\r\debug\com\example\sortapplication'.
Error:Gradle: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Gradle: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Gradle: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Gradle: Execution failed for task ':app:processDebugResources'.
>Failed to execute aapt

解决办法:
在项目的 gradle.properties 中添加 android.enableAapt2=false 即可

· AndroidStudio 新版本 3.1.3 导入旧版本项目出现的问题

详细信息
遇到了这个,别Update,我应该就是第三方用得太多:
参考:
https://blog.csdn.net/qq_36009027/article/details/79009268

· AS 导入项目报错 Error:Your project path contains non-ASCII characters.

详细信息 具体报错信息如下:


解决办法;
其实就是 工程项目路径 或者 项目名称 包含了中文
对于像我这种英文不好的人,确实挺尴尬。虽说英文不是硬性标准,但提升一下还是很有必要的。
参考:
对的,我们要专业,不仅限于包名,还有像类名,方法名等等......
https://blog.csdn.net/lovejjfg/article/details/50574140

· AS 版本 3.0.1 新建项目报错 Error:Execution failed for task ':app:preDebugAndroidTestBuild'。

详细信息 具体报错信息如下:

从报错信息来看,问题出在这两个依赖上:
1
2
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

应该就是 com.android.support:support-annotations 这个依赖冲突了,在 app 和 text app 中版本不一致。
从查找的解决方案来看,思路应该就是将 text app 中的版本降到 26.0.1,与 app 中的版本保持一致。
查到的解决办法有三种;
1:Build->Rebuild Project,临时解决,重新打开项目还是会报错。
2:在app下的build.gradle文件中的dependences {}中添加如下代码:
1
2
3
androidTestCompile('com.android.support:support-annotations:26.1.0') {
force = true
}


3:在app下的build.gradle文件中添加如下代码;
1
2
3
configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:26.1.0'
}


对于哪种方法的优劣暂时还不清楚;
参考;
https://www.cnblogs.com/fqfzs/p/9117520.html
https://blog.csdn.net/wangzici/article/details/80140357

· 将 implementation 'androidx.core:core-ktx:1.2.0' 版本升级到 1.2.0后,sync 报错了。

详细信息 Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
解决办法:
1
2
3
4
5
6
7
android {
...
//新增如下代码
kotlinOptions {
jvmTarget = "1.8"
}
}

· 无法将使用JVM target 1.8构建的字节码内联到使用JVM target 1.6构建的字节码中

1
2
3
4
5
6
7
8
android {
...

// 解决:
kotlinOptions {
jvmTarget = "1.8"
}
}

1
2
3
4
Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:debugCompileClasspath'.


https://stackoverflow.com/questions/53932195/android-studio-3-2-1-artifactresolveexception-could-not-resolve-all-artifacts-f
1
2
3
4
5
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Installed Build Tools revision 32.0.0 is corrupted. Remove and install again using the SDK Manager.


https://stackoverflow.com/questions/68387270/android-studio-error-installed-build-tools-revision-31-0-0-is-corrupted/68437642#68437642
1
2
3
4
5
Execution failed for task ':app:processDebugMainManifest'.
> Manifest merger failed : Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.


https://stackoverflow.com/questions/67412084/android-studio-error-manifest-merger-failed-apps-targeting-android-12
1
2
3
Internal Error occurred while analyzing this expression

https://youtrack.jetbrains.com/issue/KT-42886/Internal-Error-occurred-while-analyzing-this-expression
1
2
3
4
com.example.littlehelper E/WindowManager: android.view.WindowLeaked: Activity com.example.littlehelper.ui.MainActivity has leaked window DecorView@adeafa1[MainActivity] that was originally added here


Activity关闭时,Dialog没有关闭,导致内存泄漏。