十一:Could not resolve com.android.support:support-v4:19.1.+.
修改project的gradle,添加
maven {
url “https://maven.google.com”
}
十二:导入的类报红

1. File -> Invalidate Caches/Restart -> Invalidate and Restart
2.若1不行,则需要配置jre,具体参考:
Android Studio(AS)内置jre进行环境配置、com.android.support:design:26.1.0
十三:app:transformClassesAndResourcesWithR8ForRelease
在项目中的gradle.properties文件中添加如下代码
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true
org.gradle.configureondemand=true
十四:Android Studio中app出现红叉:
1. 若报错:No IDEA annotations attached to the JDK 1.8
完美解决 No IDEA annotations attached to the JDK 1.8
2. 若无上述错误,点击红叉,选择Edit configurations,最下方有提示
或者参考:
Android Studio APP红叉如何解决
Android Studio “Sync project with Gradle Files”按钮消失问题
十五:Attempt to invoke virtual method 'void android.widget.TextView.setVisibility(int)' on a null object reference
首先要确认控件的位置,看控件是否在Activity的子界面中,若在,则要在加载子界面布局的位置初始化该控件。
十六:java.lang.OutOfMemoryError: Failed to allocate a 20971532 byte allocation with 4194304 free bytes and 7MB until OOM
需要在清单文件的application中加上下面两行代码:
android:largeHeap="true"
android:hardwareAccelerated="false"
<application
android:name=".im.ImApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:largeHeap="true"
android:hardwareAccelerated="false"
android:theme="@style/AppTheme"
android:largeHeap="true"
android:hardwareAccelerated="false">
十七:Error:Project with path 'XXXX' could not be found
配置文件setting.gradle里少了依赖工程的配置信息,添加以后rebuild peoject ,然后就OK了!
十八:AS代码、文件错乱
1.清除缓存重启AS: File -> Invalidate Cahes/ Restart
2.删除项目路径下的 .gradle .idea 文件, 以及 app目录下的build文件,然后重新编译
3.清除build缓存 Clean 后 Rebuild一下
4.找到C盘/用户目录/.AndroidStudio版本号(如.AndroidStudio3.4)/system/cache文件夹,关闭studio后将其删除
十九:OPPO手机 "安装失败:安装包异常"
gradle.properties中添加android.injected.testOnly = false
若Demo无限闪退,解决方案: setting->instant run 中 关掉instant run
OPPO R11S 手机 Androidstudio直接运行安装apk时提示安装包异常
二十:release包安装后无法正常打开
debug包正常,release包无法打开,此时要考虑Gradle版本和Gradle插件的版本是否对应。
参考:Android应用闪退异常java.lang.RuntimeException: Unable to instantiate application
这篇博客汇总了Android Studio常见的错误及解决方法,包括支持库无法解析、类报红、R8编译错误、控件初始化问题、内存溢出、依赖工程找不到、代码文件错乱、安装失败及release包无法打开等问题,并提供了详细的解决步骤。
&spm=1001.2101.3001.5002&articleId=98343339&d=1&t=3&u=75e96939b317443885f3731bd866f6f3)
1564

被折叠的 条评论
为什么被折叠?



