Error type 3 Error: Activity class xxx does not exist
Run--> Edit Configurations... 查看Deploy: 如果是Nothing 请选择 Default APK
The currently selected variant "debug" uses split APKs, but none of the 1 split apks are compatible with the current device with density "560" and ABIs "x86".
defaultConfig {
defaultConfig {
ndk {
abiFilters 'armeabi-v7a', 'x86', 'x86_64'
}
vectorDrawables {
useSupportLibrary true
}
}
}
复制代码
android.view.InflateException: Binary XML file line #169: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
view小写了
复制代码
android.os.FileUriExposedException: file:///storage/emulated/0/temp.jpg exposed beyond app through ClipData.Item.getUri()
应用宝审核通过搜不到应用
您好,这边查看到您的应用是被限制了外显的,原因是安装包里的targetSdk Version版本低于26,按照《移动应用软件高API等级预置与分发自律公约》已进行限制,请修改后提交外显工单恢复。
您好,如果您已经修改了。请您走工单申请外显流程:开发者账号登陆-->管理中心-->点击应用名称-->基础能力-->工单系统-->选择应用宝商务类-->应用宝外显级别调整-->填单提交即可,处理周期为2个工作日(外显工单需要上传软著截图)
CLEARTEXT communication to to xx.xx.xx.xxx not permitted by network security policy
在 res 下新建一个 xml 目录,然后创建一个名为:network_security_config.xml 文件
复制代码
AndroidManifest.xml 中 application 节点下配置:
...
android:networkSecurityConfig="@xml/network_security_config"
...>
...
复制代码
android Caused by: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: 3 ֽڵ UTF-8 е ֽ 3 Ч at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte
android-studio\bin\studio64.exe.vmoptions增加一行-Dfile.encoding=UTF-8
onBindViewHolder方法只执行一次
item布局高度不能match_parent
android.content.res.Resources$NotFoundException: String resource ID #0x1
把一个 非 String 型的参数赋值给了 text
跳转activity空白
将对布局的初始化等操作放在oncreate(Bundle saveInstanceState)函数中进行,而不是oncreate(Bundle saveInstanceState,PersisitanbleBundle persistentState)
RecyclerView滚动时下方控件不显示
外部使用NestedScrollView,RecyclerView设置android:nestedScrollingEnabled="false"
Glide javax.net.ssl.SSLHandshakeException
build.gradle
implementation 'com.github.bumptech.glide:glide:4.12.0'
implementation 'com.github.bumptech.glide:annotations:4.12.0'
kapt 'com.github.bumptech.glide:compiler:4.12.0'
implementation("com.github.bumptech.glide:okhttp3-integration:4.12.0") {
exclude group: 'glide-parent'
}
复制代码
proguard-rules.pro中添加
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.module.AppGlideModule
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
复制代码
新建OkHttpAppGlideModule.kt
@GlideModule
class OkHttpAppGlideModule : AppGlideModule() {
override fun registerComponents(context: Context, glide: Glide, registry: Registry) {
val client = UnsafeOkHttpClient.getUnsafeOkHttpClient()
client?.let {
registry.replace(GlideUrl::class.java, InputStream::class.java, OkHttpUrlLoader.Factory(client))
}
}
override fun isManifestParsingEnabled(): Boolean {
return false
}
}
object UnsafeOkHttpClient {
fun getUnsafeOkHttpClient(): OkHttpClient? {
return try {
val trustAllCerts = arrayOf(
object : X509TrustManager {
override fun checkClientTrusted(chain: Array?, authType: String?) {
}
override fun checkServerTrusted(chain: Array?, authType: String?) {
}
override fun getAcceptedIssuers(): Array {
return arrayOf()
}
}
)
val sslContext = SSLContext.getInstance("SSL")
sslContext.init(null, trustAllCerts, SecureRandom())
val sslSocketFactory = sslContext.socketFactory
val builder = OkHttpClient.Builder()
builder.sslSocketFactory(sslSocketFactory, trustAllCerts[0] as X509TrustManager)
builder.hostnameVerifier(HostnameVerifier { _, _ -> true })
builder.connectTimeout(10, TimeUnit.SECONDS)
builder.readTimeout(20, TimeUnit.SECONDS)
builder.build()
} catch (e: Exception) {
throw RuntimeException(e)
}
}
}
复制代码
Build-Make Project
https请求错误
在application中调用忽略ssl证书
public static void ignoreSSLHandshake(){
try {
TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException{
}
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException{
}
}};
SSLContext sc = SSLContext.getInstance("TLS");
// trustAllCerts信任所有的证书
sc.init(null, trustAllCerts, new SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session){
return true;
}
});
} catch (Exception e) {
}
}
复制代码
proguard-rules.pro中添加
-keep public class android.net.http.SslError
-dontwarn android.webkit.WebView
-dontwarn android.net.http.SslError
-dontwarn Android.webkit.WebViewClient
复制代码
隐藏键盘
@Override
public boolean dispatchTouchEvent(MotionEvent ev){
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
View view = getCurrentFocus();
hideKeyboard(ev, view, BaseActivity.this);//调用方法判断是否需要隐藏键盘
break;
default:
break;
}
return super.dispatchTouchEvent(ev);
}
public static void hideKeyboard(MotionEvent event, View view,
Activity activity){
try {
if (view != null && view instanceof EditText) {
int[] location = { 0, 0 };
view.getLocationInWindow(location);
int left = location[0], top = location[1], right = left
+ view.getWidth(), bootom = top + view.getHeight();
// 判断焦点位置坐标是否在空间内,如果位置在控件外,则隐藏键盘
if (event.getRawX() < left || event.getRawX() > right
|| event.getY() < top || event.getRawY() > bootom) {
// 隐藏键盘
IBinder token = view.getWindowToken();
InputMethodManager inputMethodManager = (InputMethodManager) activity
.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(token,
InputMethodManager.HIDE_NOT_ALWAYS);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
复制代码
打包附带版本号
android {
defaultConfig {
versionCode 1
versionName '1.0.0'
}
android.applicationVariants.all {
variant ->
variant.outputs.all {
def createTime = new Date().format("YYYY-MM-dd", TimeZone.getTimeZone("GMT+08:00"))
outputFileName = "app_" + buildType.name + "_v" + defaultConfig.versionName + "_" + createTime + ".apk"
}
}
}
复制代码
动态修改图片颜色
Drawable icon = tabIcon.getDrawable();
Drawable iconImage= DrawableCompat.wrap(icon);
DrawableCompat.setTint(iconImage, ContextCompat.getColor(context,R.color.app_color_primary));
复制代码
ListView分割线
加边距
android:insetLeft="62dp">
复制代码
android:id="@+id/lv_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFFFF"
android:divider="@drawable/divider"
android:dividerHeight="0.5dp"/>
复制代码
状态栏颜色
6.0以上可以改状态栏文字颜色
@color/white
true
复制代码