android真机调试遇到的问题
由于想把hjdang.com用quasar提供的capacitor模式打包成apk。结果在调试时各种问题。
1. 在quasar dev -m capacitor -T android 然后自动打开了android studio开始build。在提示下不小心升级了Gradle,结果发生报错:Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0. 删掉了.gradle目录没用,需要删除src-capacitor, 然后重新quasar mode add capacitor
2. 用USB连接手机和mac,想用chrome的 chrome://inspect/#devices 功能调试h5,结果遇到“Pending authentication: please accept debugging session on the device.”的问题
解决:
进入开发者选项 -> 撤销USB调试授权 ->关闭USB调试->拔掉连接线 -> 打开USB调试-> 重新插上USB线 ,手机上会跳出 仅充电-数据传输-照片传输的选项,选数据传输
3. 为了看下relaese包里为何阿里云的图片显示不出来,看App里的请求Refer是什么(加了防盗链)Android用clarles抓包时在安装了根证书之后发生了ssl shake hand错误。
SSL handshake with client failed: An unknown issue occurred processing the certificate (certificate_unknown)
解决 根据clarles文档:https://www.charlesproxy.com/documentation/using-charles/ssl-certificates/
As of Android N, you need to add configuration to your app in order to have it trust the SSL certificates generated by Charles SSL Proxying. This means that you can only use SSL Proxying with apps that you control.
In order to configure your app to trust Charles, you need to add a Network Security Configuration File to your app. This file can override the system default, enabling your app to trust user installed CA certificates (e.g. the Charles Root Certificate). You can specify that this only applies in debug builds of your application, so that production builds use the default trust profile.
Add a file res/xml/network_security_config.xml to your app:
<network-security-config> 
  <debug-overrides> 
    <trust-anchors> 
      <!-- Trust user added CAs while debuggable only -->
      <certificates src="user" /> 
    </trust-anchors> 
  </debug-overrides> 
</network-security-config>
Then add a reference to this file in your app's manifest, as follows:
<?xml version="1.0" encoding="utf-8"?>
<manifest ... >
    <application android:networkSecurityConfig="@xml/network_security_config" ... >
        ...
    </application>
</manifest>
注意这个时debug包。
4. 在android studio模拟器上调试,在“Medium Phone”模拟器上网络连不上,换到Pixel 7 Emuler 上网络就能用了,百度可以打开。具体原因还未知
5. 在Pixel 7 Emuler上运行时 webview上网页无法打开:android studio net:ERR_CLEARTEXT_NOT_PERMITTED
这是由于不是https的请求:
解决方法:https://stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted/50834600#50834600
Option 1 -
First try hitting the URL with https:// instead of http://
Option 2 -
Create file res/xml/network_security_config.xml - <?xml version="1.0" encoding="utf-8"?> <network-security-config> <domain-config cleartextTrafficPermitted="true"> <domain includeSubdomains="true">api.example.com(to be adjusted)</domain> </domain-config> </network-security-config> AndroidManifest.xml - <?xml version="1.0" encoding="utf-8"?> <manifest ...> <uses-permission android:name="android.permission.INTERNET" /> <application ... android:networkSecurityConfig="@xml/network_security_config" ...> ... </application> </manifest> Option 3 - android:usesCleartextTraffic Doc AndroidManifest.xml - <?xml version="1.0" encoding="utf-8"?> <manifest ...> <uses-permission android:name="android.permission.INTERNET" /> <application ... android:usesCleartextTraffic="true" ...> ... </application> </manifest>
6: android studio模拟器运行hjdang打开后,chrome上输入chrome://insepctor/#devices调试android studio 里android里的h5页面,可以看到Remote Target里有页面了,但点击inspector跳出的对话框是黑屏,过了好久显示404.打不开,原因是网络没有FQ,打开vpn就能连上了。国内网络连不上
网上的方法大多是以下几点:
现象
在发布一个app的时候,每次走到waiting for all target devices to come online之后,就没有后续了,模拟器没有调起来,更不用谈后续的install。
原因
暂时不明
解决方法
在网上搜索的有很多种解决方法,但是对我的问题都没有效,但是也把这些方法罗列下来做一个记录。
a.在avd maanger中,选择Wipe Data擦除,然后在重启app。
b.重启Android studio,重启系统。
c.在paltform-tools目录下,执行adb kill-server,然后执行adb start-server。
d.更新SDK tool或者paltform tool。
e.删除C:\Users\Administrator.android\avd\Pixel_XL_API_28.avd目录下.lock文件,然后重新载入。
上述五种方法我都尝试过,但是对我都没有效果。后续我尝试在avd manager中选择 Cold Boot Now,先把模拟器启动,然后在运行app,发现有效。
                    
                
                
            
        
浙公网安备 33010602011771号