1Android Studio
Android Studio安装
Mac安装android studio
建议从官网下载:官网下载地址-
下载版本选择:
上图说明:
(1)PC端版本,适用于Windows系统
(2)Mac端版本,适用于Macbook非M系列
(3)Mac端ARM版本,适用于Macbook M系列(包括M1和M2) 参考:
https://blog.csdn.net/qq_38436214/article/details/106658550
https://ceshiren.com/t/topic/4001
https://blog.csdn.net/qq_35892584/article/details/109746886
https://ceshiren.com/t/topic/4001
MacBook m2芯片电脑安装哪个版本的Android studio
说明:Mac上选择Android studio需要选择带arm的版本。不然会安装不起来。
具体版本见前面“Android Studio安装”。
android studio默认安装路径Mac
- 本机安装地址为:
/Users/hh/Library/Application Support/Google/AndroidStudio2020.3
Android studio升级问题
-
AS启动之后,一般会有如下弹框,
如果不幸点了上面的Gradle升级弹框,没出问题则罢,出了问题大概率情况需要重新安装Android studio。
注意:重装AS前,最好清理掉如下3个位置:
1)AS安装目录
比如Mac上目录如下:
/Applications/Android Studio.app
2)AS下载的SDK目录
比如Mac目录如下(这是自定义目录,根据安装时目录具体找):
/Users/hh/Documents/android/sdk
3)gradle所在目录
比如Mac上目录如下:
/Users/hh/.gradle
Gradle sync失败
8:03 下午 Gradle sync failed: Sync failed: reason unknown (3 s 397 ms)
2021-11-24 20:03:56,534 [2025237] ERROR - intellij.openapi.progress.Task - Module: 'app' platform 'android-29' not found.
处理:
缺少platform 'android-29',从setting->sdk 中下载platform 'android-29',重新同步。参考:
https://blog.csdn.net/qq_28078489/article/details/120024317
AS(Android Studio)显示工具栏步骤:
- 主要使用点击到回到上一页/下一页功能。
- 结论:
View -- Appearance -- Toolbar 打上勾就会显示了。
build.gradle配置
gradle清理缓存
- 强制清除gradle 缓存/Mac gradle清理缓存
Windows:
gradlew build --refresh-dependencies
Mac:
./gradlew build --refresh-dependencies
- Mac如果遇到如下问题:
zsh: no such file or directory: ./gradlew
处理:最简单的方式就是终端执行cd命令到gradlew下(每个Android工程都有该工具),然后再执行上述命令。
参考:
https://blog.csdn.net/DaiZZZZZ/article/details/92982577
https://www.cnblogs.com/tdskee/p/15495261.html
https://blog.csdn.net/tangkuntktk/article/details/103510304
//www.greatytc.com/p/7bb89077682e
2 开发问题
AS导入aar
android获取定位
android获取GPS定位
参考:
//www.greatytc.com/p/e708b12aadd1
https://www.cnblogs.com/powerwu/articles/9228307.html注意:
使用Android原生代码(LocationManager)可以获取到经纬度。日志信息如下:
D/@hh: locationManager has android.location.LocationManager@dd48cc0
D/@hh: isGpsEnabled is true
D/@hh: current longitude:113.10160875320435, latitude:28.240157961845398
百度地图导入:
Android导入jnilibs
ACCESS_MOCK_LOCATION 模拟定位
- 参考:
https://blog.csdn.net/dangxw_/article/details/18604425
https://blog.csdn.net/breakpoints_/article/details/103644164
修改app_name后报错
"app_name" is not translated in "zh" (Chinese)
- 处理:在res下的strings.xml中添加translatable:
<string name="app_name" translatable="false">APPDEMO</string>
- 参考:
//www.greatytc.com/p/800b19c4b328?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation
https://blog.csdn.net/zgy621101/article/details/76134650
https://blog.csdn.net/msn465780/article/details/78490085
Android检查定位权限
参考:
https://blog.csdn.net/qq_40638618/article/details/110956443
https://blog.csdn.net/qq_35592743/article/details/88634514ACCESS_COARSE_LOCATION ACCESS_FINE_LOCATION
定位的两个权限
参考:
https://www.cnblogs.com/zjutlitao/p/5589572.htmlandroid跳转定位设置页面
参考:
https://www.cnblogs.com/gisoracle/p/7623236.html
https://blog.csdn.net/qq_40733723/article/details/96993586android跳转位置信息设置页面
参考:
https://blog.csdn.net/fsx_xiaomei/article/details/79448115
https://blog.csdn.net/weixin_30396777/article/details/117837615?spm=1001.2101.3001.6650.4&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-4.pc_relevant_paycolumn_v2&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-4.pc_relevant_paycolumn_v2&utm_relevant_index=9
ActivityCompat.OnRequestPermissionsResultCallback
- 参考:
https://blog.csdn.net/u012483116/article/details/73798383
https://www.thinbug.com/q/56909398
https://stackoverflow.com/questions/56909398/activitycompat-onrequestpermissionsresult-not-called
android判断权限为询问状态
- 参考:
https://baijiahao.baidu.com/s?id=1690052502740516139&wfr=spider&for=pc
https://blog.csdn.net/linxinfa/article/details/89396663
shouldShowRequestPermissionRationale
- 参考:
https://blog.csdn.net/wangpf2011/article/details/80589648
//www.greatytc.com/p/32427ec636ec
https://qa.1r1g.com/sf/ask/3222809901/
//www.greatytc.com/p/6fc1f94ebc6a
//www.greatytc.com/p/5dd5d4808cdd
Android延时函数
andorid获取上下文
Android字典和json格式
- 参考:
https://blog.csdn.net/weixin_42303461/article/details/117567787
https://blog.csdn.net/weixin_30029951/article/details/117594357
fastjson
java单例模式
android broadcastreceiver
Android广播注册
- 参考:
https://blog.csdn.net/qq_26500807/article/details/79960659
https://blog.csdn.net/weixin_42097508/article/details/117544056
9patch图
/Users/hh/Documents/androidProject//app-demo-android//app-demo-android/app/src/main/res/drawable-hdpi/splash.9.png: AAPT: error: file failed to compile.
- 处理:
由于着急用,干脆不用9patch图,直接用png图
SharedPreferences
Android从后台回到前台回调
- 参考:
https://blog.csdn.net/weixin_38754349/article/details/105259785
https://blog.csdn.net/weixin_39554021/article/details/112836705
android方法设置callback为参数
android软件安装列表权限
参考:
//www.greatytc.com/p/dee8bc1fb847
https://blog.csdn.net/weixin_33662445/article/details/117508253
https://www.cnblogs.com/allen12/p/14328209.htmlandroid软件安装列表
参考:
https://blog.csdn.net/q384415054/article/details/72972405/
android.permission.GET_TASKS
queryIntentActivities
Build.MANUFACTURER.equalsIgnoreCase
Android加载控件loading
参考:
https://blog.csdn.net/u014449096/article/details/51151142
https://www.cnblogs.com/androiddream/p/9188032.htmlloadingView
参考:
//www.greatytc.com/p/7534ca237423
https://www.jb51.net/article/143292.htm
Android获取最上层的view
- 参考:
获取最顶层
https://blog.csdn.net/blog_yue/article/details/48325845
https://blog.csdn.net/weixin_39944638/article/details/112028024
Android的Activity获取监听广播
处理:这里使用了LocalBroadcastManager
其实也可以使用BroadcastReceiver参考:
https://blog.csdn.net/weixin_44720673/article/details/118771302
https://blog.csdn.net/xdy1120/article/details/107064096/
应用适配Android12
- 说明:如果targetSdkVersion设置31或以上,则需要适配Android 12,看资料可知需要将工程中AndroidManifest.xml所有exported的地方设置为true,包括引入的库也需要做适配(比如在app下的build.gradl做配置,具体见如下参考)。如果工程不对这个做要求,可以降低targetSdkVersion版本(低于31)即可。
android:exported="true"
- 参考:
https://blog.csdn.net/lmx9813/article/details/121786643
https://blog.csdn.net/minping9101/article/details/123351017
https://blog.csdn.net/weixin_40611659/article/details/119645712?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Edefault-1-119645712-blog-123351017.pc_relevant_without_ctrlist_v4&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Edefault-1-119645712-blog-123351017.pc_relevant_without_ctrlist_v4&utm_relevant_index=2
targetSdkVersion
Build.MANUFACTURE
android:allowBackup
provider authorities
- 参考:
https://zhidao.baidu.com/question/519872919182752245.html
https://www.tuiyang.com/article-573439-1.html
Android新建module后运行找不到类
- 参考:
https://www.csdn.net/tags/MtTaEg3sMTczMDE2LWJsb2cO0O0O.html
https://blog.csdn.net/weixin_39576133/article/details/117730658
https://qa.1r1g.com/sf/ask/1783393671/
https://www.jb51.net/softjc/451097.html
android的module里再引入module
- 说明:这里是以IM实时通讯引入举例:
(1)主工程app下build.gradle配置dependencies库:
api project(':offlinepush')
(2)offlinepush模块(module)下build.gradle配置dependencies库:
api project(':pushcore')
(3)pushcore模块(module)下build.gradle配置dependencies库:
if (projects.contains("imsdk-plus")) {
api project(':imsdk-plus')
} else {
api 'com.tencent.imsdk:imsdk-plus:6.3.2609'
}
具体遇到的问题,见后面“ 6 IM实时通讯”(具体配置以这里为准)。
- 参考:
https://blog.csdn.net/sinat_35958166/article/details/89468978
https://www.pianshen.com/article/86631905492/
https://blog.csdn.net/qq_21358401/article/details/79042434
https://blog.csdn.net/XIAO_GUANGYOU/article/details/90751919
https://blog.csdn.net/AlexYoung28/article/details/81664472?spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1-81664472-blog-86262031.pc_relevant_multi_platform_whitelistv1&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1-81664472-blog-86262031.pc_relevant_multi_platform_whitelistv1&utm_relevant_index=1
android provider
3 调试
4 真机/模拟器
AS的AVD模拟器安装问题
Installation did not complete successfully. See the IDE log for detals.
AVD启动问题
AVD Manager
The emulator process for AVD Pixel_2_API_30 has teminated.
参考:
https://blog.csdn.net/weixin_45846799/article/details/120167552处理:
Tools->SDK manager->Appearance&Behavior->System Settings->Android SDK->SDK Tools 下的HAXM已安装安装HAXM报错:
Unable to install Intel HAXM
HAXM can only be installed on Windows or Mac.
Please file a bug against Android Studio.
参考:
https://blog.csdn.net/liulanzaijia/article/details/84870972
https://blog.csdn.net/u013475983/article/details/108767595
Mac安装HAXM:
https://blog.csdn.net/hello_wyq/article/details/78218219处理:暂时仍不能成功。
AVD成功启动模拟器
(1)虚拟器 AVD:安装apk,报错
hh@hhdeMacBook-Pro ~ % adb devices
List of devices attached
emulator-5554 device
hh@hhdeMacBook-Pro ~ % adb install /Users/hh/Documents/COSBrowser/app/4.07.23/prd-uniapp-V4.07.23.apk
Performing Streamed Install
adb: failed to install /Users/hh/Documents/COSBrowser/app/4.07.23/prd-uniapp-V4.07.23.apk:
Exception occurred while executing 'install':
android.os.ParcelableException: java.io.IOException: Requested internal only, but not enough space
at android.util.ExceptionUtils.wrap(ExceptionUtils.java:34)
at com.android.server.pm.PackageInstallerService.createSession(PackageInstallerService.java:595)
at com.android.server.pm.PackageManagerShellCommand.doCreateSession(PackageManagerShellCommand.java:3434)
at com.android.server.pm.PackageManagerShellCommand.doRunInstall(PackageManagerShellCommand.java:1446)
at com.android.server.pm.PackageManagerShellCommand.runInstall(PackageManagerShellCommand.java:1408)
at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:221)
at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
at android.os.ShellCommand.exec(ShellCommand.java:38)
at com.android.server.pm.PackageManagerService$IPackageManagerImpl.onShellCommand(PackageManagerService.java:5954)
at android.os.Binder.shellCommand(Binde%
参考:
https://blog.csdn.net/qq_36651718/article/details/117221670
https://blog.csdn.net/Liu_Rechar/article/details/123052037AS模拟器内存设置:
https://blog.csdn.net/yax405/article/details/9369093查看AS模拟器的内存:找到模拟器位置:
/Users/hh/.android/avd/Pixel_3a_API_33_arm64-v8a``.avd/
查看config.ini文件:
- 说明:
找到hw.ramSize=1536,该键用于设置内存大小,默认好像是256M
上面的值为:hw.ramSize=1536
修改为:hw.ramSize=15360
(2)还是不行,重新创建了一个AVD:
/Users/hh/.android/avd/Pixel_3a_XL_Edited_API_33.avd
- 终于运行起来了。
Mate20通过浏览器安装apk无法安装
说明:华为Mate20手机进入“设置 - 安全 - 更多安全设置”里,打开两个开关:“外部来源应用下载“和”安装外部来源应用“。
参考:
https://jingyan.baidu.com/article/95c9d20de3749fac4e7561df.html如果华为mate30除了华为应用市场别的APP都安装不了其他的软件是手机内存不够了
参考:
https://zhidao.baidu.com/question/527693134016272965.html
mac上AS模拟器上不了网
- 参考:
https://www.cnblogs.com/mukekeheart/p/14313853.html
https://blog.csdn.net/weixin_41891385/article/details/116546811
小米手机安装失败
03/07 21:14:40: Launching 'app' on Xiaomi M2102J2SC.
Installation did not succeed.
The application could not be installed: INSTALL_FAILED_USER_RESTRICTED
处理:
开发者选项-usb安装 开关打开就好了参考:
https://blog.csdn.net/qinwei1993/article/details/90756946
oppo手机截屏怎么截
- 说明:最便捷的方式就是:三指同时向下划动。
参考:
https://baijiahao.baidu.com/s?id=1706077872957155693
5 应用市场审核
华为应用审核提示获取安装列表
- 参考:
https://ask.dcloud.net.cn/question/140937
https://ask.dcloud.net.cn/question/133780
https://ask.dcloud.net.cn/article/39073
https://ask.dcloud.net.cn/article/36937
https://blog.csdn.net/weixin_35523579/article/details/117759587
https://www.csdn.net/tags/MtTaEg2sNzYwMTU2LWJsb2cO0O0O.html
您的应用存在获取用户的软件安装列表等敏感信息行为
华为应用市场审核问题:
经检测发现,您的应用存在获取用户的软件安装列表敏感信息行为,且未在应用内的隐私政策/在AppGallery Connect上提交的隐私政策网址中进行说明
vivo应用存在强制用户使用定向推送功能--不通过
vivo应用存在强制用户使用定向推送功能--被驳回
参考:
http://www.techweb.com.cn/internet/2019-11-04/2762069.shtml
6 IM实时通讯
IM推送:日志
Cannot resolve symbol 'HmsMessageService'
- 参考:
https://blog.csdn.net/qq_46429858/article/details/124248770
https://blog.csdn.net/qq_44295125/article/details/107482434
IM推送:工程接入:日志
(1)第一个问题
Could not determine the dependencies of task ':app:compileAPPMASTERDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:APPMASTERDebugCompileClasspath'.
> Could not resolve project :com.app.demo.pushcore.
Required by:
project :app > project :offlinepush
> No matching configuration of project :com.app.demo.pushcore was found. The consumer was configured to find an API of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'buildType' with value 'APPMASTER' but:
- None of the consumable configurations have attributes.
Build file '/Users/hh/Documents/androidProject/app-demo-android/app-demo-android/offlinepush/build.gradle' line: 65
A problem occurred evaluating project ':offlinepush'.
> Project with path ':pushcore' could not be found in project ':offlinepush'.
Execution failed for task ':offlinepush:generateReleaseRFile'.
> Could not resolve all files for configuration ':offlinepush:releaseCompileClasspath'.
> Could not find com.huawei.hms:push:5.0.2.300.
Required by:
project :offlinepush
- 处理:按照前面介绍的引入module的方式即可解决。
api project(':xxxxx')
IM推送:启动崩溃:日志
java.lang.RuntimeException: Unable to get provider com.app.demo.offlinepush.OfflinePushService: java.lang.ClassNotFoundException: Didn't find class "com.app.demo.offlinepush.OfflinePushService" on path: DexPathList[[zip file "/data/app/com.app.demo-HT2QvzzgeOC4gRSARfORWg==/base.apk"],nativeLibraryDirectories=[/data/app/com.app.demo-HT2QvzzgeOC4gRSARfORWg==/lib/arm64, /data/app/com.app.demo-HT2QvzzgeOC4gRSARfORWg==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
- 参考:
https://blog.csdn.net/haojiagou/article/details/84918005
https://blog.csdn.net/fuckingone/article/details/107488765
https://www.bbsmax.com/A/Vx5MYx6G5N/
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.app.demo.pushcore.ServiceInitializer" on path: DexPathList[[zip file "/data/app/com.app.demo-Be3Tve4GJG5ZY-d3uOQ1DA==/base.apk"],nativeLibraryDirectories=[/data/app/com.app.demo-Be3Tve4GJG5ZY-d3uOQ1DA==/lib/arm64, /data/app/com.app.demo-Be3Tve4GJG5ZY-d3uOQ1DA==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
原因:原来包名写错了,改正之后,导致的导入包出错。
参考:
https://blog.csdn.net/wan903531306/article/details/117114137
https://blog.csdn.net/weixin_37587365/article/details/124150772最终原因:在 AndroidStudio 和 Gradle 编译环境中,如果要使用 multidex,需要配置。
IM推送:工程配置,日志
/Users/hh/Documents/androidProject/app-demo-android//app-demo-android/app/src/main/AndroidManifest.xml:148:9-150:47 Error:
Attribute meta-data#XG_V2_ACCESS_ID@value at AndroidManifest.xml:148:9-150:47 requires a placeholder substitution but no value for <XG_ACCESS_ID> is provided.
/Users/hh/Documents/androidProject//app-demo-android//app-demo-android/app/src/main/AndroidManifest.xml:152:9-154:48 Error:
Attribute meta-data#XG_V2_ACCESS_KEY@value at AndroidManifest.xml:152:9-154:48 requires a placeholder substitution but no value for <XG_ACCESS_KEY> is provided.
参考:
https://blog.csdn.net/weixin_40420578/article/details/109850636
https://blog.csdn.net/weixin_40750371/article/details/93630375
https://www.freesion.com/article/34391356237/处理:
在app的build.gradle里的placeholder部分,添加 XG_ACCESS_ID 和 XG_ACCESS_KEY 两个即可。(这两个属于腾讯信鸽对应的SDK的配置ID)
oppo推送申请channelid
push : registerID
- 说明:IM会获取手机设备的token,作为registerID。
推送:IM: 检测
oppo推送:
sign校验不通过,无效签名(OPPO返回错误码: 16),请检查您上传的证书参数是否有误(特别注意:OPPO需要上传的是MasterSecret, 而不是AppSecret。) 具体可参考:https://cloud.tencent.com/document/product/269/37729处理:重新在IM上更正MasterSecret和添加ChannelID后,推送检测成功(但手机为收到):
token: ****599b 已成功推送。如果仍无法接收,请确认接收方手机已经打开您APP的通知功能。
7其他
keystore获取md5
hh@hhdeMacBook-Pro bin % pwd
/Applications/Android Studio.app/Contents/jre/Contents/Home/bin
hh@hhdeMacBook-Pro bin % ls
jaotc javac jdeprscan jimage jrunscript rmiregistry
jar javadoc jdeps jjs keytool serialver
jarsigner javap jfr jlink pack200 unpack200
java jdb jhsdb jmod rmid
hh@hhdeMacBook-Pro bin %
hh@hhdeMacBook-Pro bin % keytool -list -v -keystore /Users/hh/Documents/androidProject/wvpn-sany-lt-shipper-android/keystore/sanylighttruck.keystore
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
参考:
https://blog.51cto.com/shijianfeng/5151392
//www.greatytc.com/p/fe6b68295479说明:需要安装Java JDK
Android Studio自带的JDK目录:
https://blog.csdn.net/qq_29364417/article/details/126005543
http://t.zoukankan.com/morlin-p-4647447.html
https://www.jb51.cc/mac/2923682.html说明:Android Studio自带的JDK没法用,只好额外安装JDK。
安装了JDK18:
java version "18.0.2.1" 2022-08-18
Java(TM) SE Runtime Environment (build 18.0.2.1+1-1)
Java HotSpot(TM) 64-Bit Server VM (build 18.0.2.1+1-1, mixed mode, sharing)
通过keytool命令:
keytool -list -v -keystore + keystore的绝对路径
能够拿到证书指纹,包括SHA1和SHA256,但是获取不到MD5.
解决:需要降低JDK版本,比如安装Java7就可以获取到MD5.