⚠️出现如下警告信息:
解决方法:
检查当前使用的泛型,如果你的引用后面没有规定类型,加上即可。
List<String> -> String
List<String> entry;
1、
import com.google.common.base.Joiner;
String value = Joiner.on("#").join(entry);
2、
String.join("", entry);
3、使用forech循环(省略)
- android studio更新到3.6,构建NDK项目的时候NDK版本引起的同步报错
No version of NDK matched the requested version 20.0.5594570. Versions available locally: 16.1.4479499
修改方法:同步之后会修改build.gradle
,引入ndk版本
android {
...
ndkVersion "16.1.4479499"
...
}
API 'variantOutput.getProcessResources()' is obsolete and has been replaced with 'variantOutput.getProcessResourcesProvider()'.
API 'variant.getPackageApplication()' is obsolete and has been replaced with 'variant.getPackageApplicationProvider()'.
android {
...
// Butterknife requires Java 8.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'com.jakewharton:butterknife:10.2.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
}
Android Studio警告
Implicitly using the default locale is a common source of bugs: Use String.format(Locale, ...) instead
String.format("%.2f ms", "0.786")
增加Locale.CHINA解决:
String.format(Locale.CHINA, "%.2f ms", "0.786")
Android Studio 非法字符: '\ufeff'解决
文件采用的编码方式为UTF-8带BOM的格式
重新新建文件 复制即可解决 或者 把格式修改为 UTF-8
在<string.xml>资源文件中
名称 | 转义字符 |
普通的英文半角空格 |   |
no-break space 普通的英文半角空格但不换行 |  或 或  |
中文全角空格 (一个中文字符宽度) |   |
en空格 (半个中文字符宽度) |  或  |
em空格 (一个中文字符宽度) |  或  |
四分之一em空格 (四分之一中文字符宽度) |   |
- | "或" |
& | &或& |
< | <或< |
> | >或> |
一个汉字宽度的空格【   】
两个空格【  】比一个汉字宽度略窄
三个空格【& #160;& #160;& #160;】比一个汉字宽度略宽
xml中在文字的前面加入”u3000u3000”即可实现首行缩进
Java代码中使用setText(“u3000u3000”+s);
Java代码设置中文空格(一个中文字符宽度)setText("\u3000"+s);
Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
gradle版本与jdk版本不匹配导致,重新选择对应gradle版本的jdk版本即可解决。