Android开发问题汇总

1.如何进入页面不focus任何view?
设置父布局
    android:focusable="true" 
    android:focusableInTouchMode="true"
2.为何添加了测试库,但扔import不到?
testCompile
androidTestCompile
在
buildTypes {
    debuggable true
}
才生效
3.canvas.drawText垂直居中
参数y为baseline
baseline = height - FontMetrics.bottom - FontMetrics.top
4. over bounds of view
    setClipChildren
    setClipToPadding
5.lineSpacing的版本兼容
TextView lineSpacing  api<21 包含一行间距, api>=21不包含,需要通过value,value-21做兼容
6.指定abi编译

build.gradle

ndk {
        abiFilters = []
        abiFilters.addAll(ABI_FILTERS.split(';').collect{it as String})
}

gradle.properties

ABI_FILTERS=armeabi
7.VIVO adb install

gradle.properties

android.injected.testOnly = false
8.使用EventBus Subscriber Index 时 未执行并生成索引文件
@SupportedAnnotationTypes("org.greenrobot.eventbus.Subscribe")
@SupportedOptions(value = {"eventBusIndex", "verbose"})
public class EventBusAnnotationProcessor extends AbstractProcessor {
……
}

只有包含getSupportedAnnotationTypes类型的项目才会执行AnnotationProcessor,当前library并没有使用@org.greenrobot.eventbus.Subscribe注解

9.个别机型点击通知栏通知无法跳转到APP

在设置中开启权限

10.查看keystore信息
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
Android开发问题汇总_第1张图片
image.png
11.支持zip,rar,7z等格式文件使用APP打开

    
    
    
    
    
    
    

12.socket中readline与read的区别?

readline的时候,只有接收到换行符才能收到数据。

13.Gradle依赖下载目录
#Mon Apr 24 10:55:41 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip

会下载到GRADLE_USER_HOME目录

.gradle/wrapper/dists/
14.android studio 3.0打包
library中的buildTypes要和application中的一致
15.查看包名和签名
//查看apk签名信息
keytool -list -printcert -jarfile xxx.apk
//查看keystore签名信息,执行后会提示“输入密钥库口令”
keytool -list -v -keystore xxx.jks
keytool -list -v -keystore xxx.keystore
//查看apk包名
aapt dump badging xxx.apk
//aapt在/android-sdks/build-tools/28.0.3/下,28.0.3为build-tools版本
16.Only fullscreen opaque activities can request orientation

source:android-26(O)

//解决办法
//去掉AndroidManifest中的screenOrientation,在onCreate中根据系统版本设置
@Override
protected void onCreate(Bundle savedInstanceState) {
    if (Build.VERSION.SDK_INT != Build.VERSION_CODES.O) {
       setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }
}
//条件:
//targetSdkVersion > O
//设置了screenOrientation
//isTranslucentOrFloating == true
//解决办法:
//设置isFixedOrientation = false
//设置isTranslucentOrFloating=false
//
protected void onCreate(@Nullable Bundle savedInstanceState) {
    if (getApplicationInfo().targetSdkVersion > O && mActivityInfo.isFixedOrientation()) {
       final TypedArray ta = obtainStyledAttributes(com.android.internal.R.styleable.Window);
        final boolean isTranslucentOrFloating = ActivityInfo.isTranslucentOrFloating(ta);
            ta.recycle();

        if (isTranslucentOrFloating) {
        throw new IllegalStateException(
                "Only fullscreen opaque activities can request orientation");
        }
    }
}
//windowIsTranslucent,windowSwipeToDismiss,windowIsFloating返回true
public static boolean isTranslucentOrFloating(TypedArray attributes) {
        final boolean isTranslucent =
                attributes.getBoolean(com.android.internal.R.styleable.Window_windowIsTranslucent,
                        false);
       final boolean isSwipeToDismiss = !attributes.hasValue(
                com.android.internal.R.styleable.Window_windowIsTranslucent)
                && attributes.getBoolean(
                        com.android.internal.R.styleable.Window_windowSwipeToDismiss, false);
        final boolean isFloating =
                attributes.getBoolean(com.android.internal.R.styleable.Window_windowIsFloating,
                        false);

        return isFloating || isTranslucent || isSwipeToDismiss;
    }
17.360加固配置多个签名时如何选择签名的?
//360加固配置多个签名时会自动选择加固前签名完成自动签名
18.Android 5.1 webview加载网页空白页面,提示Uncaught SyntaxError: Unexpected xxxx
#不支持高级语法#
//不要用ajax
//不要使用 let
//箭头函数
//等等

你可能感兴趣的:(Android开发问题汇总)