安卓學習幾個月,感覺腦瓜子嗡嗡的。
榮耀Magic 2編譯錯誤,暫時未定位問題,擱置。。。
E/AwareLog: AtomicFileUtils: readFileLines file not exist: android.util.AtomicFile@d0e88ec
E/AwareLog: AtomicFileUtils: readFileLines file not exist: android.util.AtomicFile@f7064b5
E/MemoryLeakMonitorManager: MemoryLeakMonitor.jar is not exist!
F4606E37F4397573E3B85F943DCEA341.png
安卓手機投屏vysor
禁止View響應點擊
myview.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
安卓復制工程與原工程沖突處理
- 解除svn關聯:
Project : -idea->vcs.xml->vcs="" - 更改applicationID
File->Project Structure
Modules->Default Config
Application ID - 不需要增加到版本庫
.idea 文件夾,此文件夾是用來保存開發工具的設置信息。
.gradle 文件夾,此文件夾是用來保存gradle的依賴信息。
所有的 build 文件夾,build文件夾是用來保存編譯后的文件目錄。
所有的 .iml 文件,是用來保存開發工具信息。
local.properties 文件,是用來保存項目依賴信息。
打包APK前如果代碼,簽名jks都確認正確,沒有問題,但是release版安裝沒有原因的閃退,那么clean工程可以解決這個問題。這個閃退困擾我兩天,結果一個clean柳暗花明又一村。
- 生成jks:Error Key was created with errors: JKS密鑰庫使用專用格式 :
keytool -importkeystore -srckeystore ~/2020.jks -destkeystore ~/2020key.jks-deststoretype pkcs12
- 按鈕調整圖片尺寸
Drawable[] drawable = btn.getCompoundDrawables();
Rect rect = new Rect(0,0,50,50);
drawable[1].setBounds(rect);
btn.setCompoundDrawables(null,drawable[1],null,null);
- Chrome調試移動設備webview
//打開允許調試開關
webview.setWebContentsDebuggingEnabled(true);
//瀏覽器輸入地址
chrome://inspect/#devices
- JS交互常見錯誤
- 在JS接口的回調方法里面添加 throw Exception
- Web端不進行對象存在判斷
- 傳遞參數類型不一致
[1,2,3,"hello"];此時hello被置換為0 - 字符串類型參數為空時顯示為undefined
判斷為空改傳“”
- 取消請求
if (mOkHttpClient != null) {
for (Call call : mOkHttpClient.dispatcher().runningCalls()) {
Log.i("cancel","cancel");
call.cancel();
}
}
- Error:A problem occurred configuring project ':app'.
JNI相關使用到C/C++庫 需引用NDK
File->Project Structure 配置正確的NDK
安卓讀取相冊圖片無法正常顯示,拍攝視頻無法播放,缺乏權限:
SDKVersion = 29時需要
android:requestLegacyExternalStorage="true"
- 獲取高德地圖Debug SHA1
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
- 集成高德地圖定位,搜索模塊與導航模塊沖突
//定位功能
implementation 'com.amap.api:location:latest.integration'
//搜索功能
implementation 'com.amap.api:search:latest.integration'
//導航功能
implementation 'com.amap.api:navi-3dmap:latest.integration'
- 編譯錯誤信息
Duplicate class com.amap.api.fence.DistrictItem found in modules jetified-location-6.1.0.jar (com.amap.api:location:6.1.0) and jetified-navi-3dmap-9.3.0_3dmap9.3.0.jar (com.amap.api:navi-3dmap:9.3.0_3dmap9.3.0)
處理方法:最新版導航SDK包含了定位,搜索功能,所以可以不依賴定位,搜索包,注釋即可。依賴重復
- jcenter上大概率沒有該依賴庫版本 click here. 查找你需要的依賴庫版本,降低一下版本,更改一下
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
> Could not resolve com.你集成的依賴庫.
Required by:
project :app
> Skipped due to earlier error
- 應用置灰
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getLayoutResId());
//=====================================================
View decorView = this.getWindow().getDecorView();
ColorMatrix cm = new ColorMatrix();
cm.setSaturation(0);
Paint paint = new Paint();
paint.setColorFilter(new ColorMatrixColorFilter(cm));
decorView.setLayerType(View.LAYER_TYPE_SOFTWARE,paint);
//=======================================================
mBind = ButterKnife.bind(this);
initView();
initEvent();
initPresenter();
}