再次解决,android 2.3运行凯立德问题
我的Hero最近刷了2.3的ROM,原来在2.1下可以使用的凯立德又FC了,估计又是android的API接口改变了,又不兼容了,还好当时在有过解决在1.5时代到2.1凯立德不兼容的经验(这个当时也我第一个发布可以在2.1下使用的凯立德,http://www.hiapk.com/bbs/thread-320372-1-1.html)
现在有好几个版本的凯立德,我试过都不能在2.3的hero(480*320)的分变率下运行
有个什么零售版的,这个可以支持3D路口显示,但是无奈,这个问题不要重,不容易解决,所以我还是选择了最早的哪个版本来攻破,对这个我也比较熟,搞起来方便
改好后的下载地址
http://www.hiapk.com/thread-928729-1-3.html
也说说这个版本凯立德为什么在2.3下又不能正常运行的主要原因,有兴趣的朋友也可以看一下,没兴趣你就跳过吧,
运行的时候,FC了,通过logcat可以看到,主要原因错误提示是
查了一下资料,发现 2.3的这个函数比2.2的多了两个参数,
requestLocationUpdates(java.lang.String provider, long minTime, float minDistance, android.location.ILocationListener listener) throws android.os.RemoteException;
2.3 的
requestLocationUpdates(java.lang.String provider, android.location.Criteria criteria, long minTime, float minDistance, boolean singleShot, android.location.ILocationListener listener) throws android.os.RemoteException;
所以调用一个不存在的函数,导致了基FC,解决方法就是把里面改成新版的,拿出我的小手术刀apktool,解开了凯立德的apk,找到相应的地方,改过来,就OK了,
首写凯立德是用aidl的方式直接调用 android.location.ILocationManager;接口来实现的,如果用LocationManager来实现就没有这个问题了,就是因为
ILocationManager更改了调用接口才引发了错误!
反编译后可以看到,一个android/location文件夹,这里面就是调用aidl自动生成的文件, 这里的文件全部要换成最新的,有个简单的方法,就是在android 2.3的源代码里找到,location下的几个aidl文件,下载回来,新建一个android工程,把这几个文件,添加到里面,有个地方要注意,就是使用aidl文件,一定要放在相应的包目录下,比如,这几个文件就必须放在android/location这样的目录下,
编译这个空的工程,生成apk,把这个apk 用apktool 也反编译了,可以看到里面也有个android/location文件夹,把这下面的文件全部复制替换到凯立德的下面,这样凯立德调用的也是最新的接口了,然后,找到凯立德中调用 requestLocationUpdates的地方
.method public openGPS()I .locals 9 .prologue const/4 v8, 0x0 const/4 v7, -0x1 .line 1278 iget-boolean v0, p0, Lcld/navi/mainframe/MainActivity;->mUseGpsEmu:Z if-eqz v0, :cond_1 .line 1280 invoke-virtual {p0}, Lcld/navi/mainframe/MainActivity;->resumeGpsEmu()V :cond_0 move v0, v8 .line 1309 :goto_0 return v0 .line 1284 :cond_1 iget-object v0, p0, Lcld/navi/mainframe/MainActivity;->mLocationProvider:Ljava/lang/String; if-nez v0, :cond_0 .line 1286 iget-object v0, p0, Lcld/navi/mainframe/MainActivity;->mLocationManager:Landroid/location/LocationManager; iget-object v1, p0, Lcld/navi/mainframe/MainActivity;->mCriteria:Landroid/location/Criteria; const/4 v2, 0x1 invoke-virtual {v0, v1, v2}, Landroid/location/LocationManager;->getBestProvider(Landroid/location/Criteria;Z)Ljava/lang/String; move-result-object v0 iput-object v0, p0, Lcld/navi/mainframe/MainActivity;->mLocationProvider:Ljava/lang/String; .line 1288 iget-object v0, p0, Lcld/navi/mainframe/MainActivity;->mLocationProvider:Ljava/lang/String; if-eqz v0, :cond_2 .line 1292 :try_start_0 iget-object v0, p0, Lcld/navi/mainframe/MainActivity;->mILM:Landroid/location/ILocationManager; iget-object v1, p0, Lcld/navi/mainframe/MainActivity;->mGPSStatusListener:Lcld/navi/mainframe/MainActivity$NaviGPSStatusListener; invoke-interface {v0, v1}, Landroid/location/ILocationManager;->addGpsStatusListener(Landroid/location/IGpsStatusListener;)Z .line 1293 iget-object v0, p0, Lcld/navi/mainframe/MainActivity;->mILM:Landroid/location/ILocationManager; iget-object v1, p0, Lcld/navi/mainframe/MainActivity;->mLocationProvider:Ljava/lang/String; iget-wide v2, p0, Lcld/navi/mainframe/MainActivity;->mMinTime:J iget v4, p0, Lcld/navi/mainframe/MainActivity;->mMinDistance:F iget-object v5, p0, Lcld/navi/mainframe/MainActivity;->mLocationListener:Lcld/navi/mainframe/MainActivity$NaviLocationListener; invoke-interface/range {v0 .. v5}, Landroid/location/ILocationManager;->requestLocationUpdates(Ljava/lang/String;JFLandroid/location/ILocationListener;)V #就是这里,就是因为这里调用了老的函数,所以引发了错误 :try_end_0 .catch Landroid/os/RemoteException; {:try_start_0 .. :try_end_0} :catch_0 move v0, v8 .line 1294 goto :goto_0 .line 1296 :catch_0 move-exception v0 move-object v6, v0 .line 1298 .local v6, e:Landroid/os/RemoteException; invoke-virtual {p0}, Lcld/navi/mainframe/MainActivity;->closeGPS()I move v0, v7 .line 1299 goto :goto_0 .end local v6 #e:Landroid/os/RemoteException; :cond_2 move v0, v7 .line 1304 goto :goto_0 .end method
把它改成以下,添加了几个参数,把参数改成最新的,哪两个新加的参数,一个为null,一个为false,就可以了
.locals 10
.prologue
const/4 v8, 0x0
const/4 v9, -0x1
.line 1278
iget-boolean v0, p0, Lcld/navi/mainframe/MainActivity;->mUseGpsEmu:Z
if-eqz v0, :cond_1
.line 1280
invoke-virtual {p0}, Lcld/navi/mainframe/MainActivity;->resumeGpsEmu()V
:cond_0
move v0, v8
.line 1309
:goto_0
return v0
.line 1284
:cond_1
iget-object v0, p0, Lcld/navi/mainframe/MainActivity;->mLocationProvider:Ljava/lang/String;
if-nez v0, :cond_0
.line 1286
iget-object v0, p0, Lcld/navi/mainframe/MainActivity;->mLocationManager:Landroid/location/LocationManager;
iget-object v1, p0, Lcld/navi/mainframe/MainActivity;->mCriteria:Landroid/location/Criteria;
const/4 v2, 0x1
invoke-virtual {v0, v1, v2}, Landroid/location/LocationManager;->getBestProvider(Landroid/location/Criteria;Z)Ljava/lang/String;
move-result-object v0
iput-object v0, p0, Lcld/navi/mainframe/MainActivity;->mLocationProvider:Ljava/lang/String;
.line 1288
iget-object v0, p0, Lcld/navi/mainframe/MainActivity;->mLocationProvider:Ljava/lang/String;
if-eqz v0, :cond_2
.line 1292
:try_start_0
iget-object v0, p0, Lcld/navi/mainframe/MainActivity;->mILM:Landroid/location/ILocationManager;
iget-object v1, p0, Lcld/navi/mainframe/MainActivity;->mGPSStatusListener:Lcld/navi/mainframe/MainActivity$NaviGPSStatusListener;
invoke-interface {v0, v1}, Landroid/location/ILocationManager;->addGpsStatusListener(Landroid/location/IGpsStatusListener;)Z
.line 1293
iget-object v0, p0, Lcld/navi/mainframe/MainActivity;->mILM:Landroid/location/ILocationManager;
iget-object v1, p0, Lcld/navi/mainframe/MainActivity;->mLocationProvider:Ljava/lang/String;
const/4 v2, 0x0
iget-wide v3, p0, Lcld/navi/mainframe/MainActivity;->mMinTime:J
iget v5, p0, Lcld/navi/mainframe/MainActivity;->mMinDistance:F
const/4 v6, 0x0
iget-object v7, p0, Lcld/navi/mainframe/MainActivity;->mLocationListener:Lcld/navi/mainframe/MainActivity$NaviLocationListener;
invoke-interface/range {v0 .. v7}, Landroid/location/ILocationManager;->requestLocationUpdates(Ljava/lang/String;Landroid/location/Criteria;JFZLandroid/location/ILocationListener;)V
:try_end_0
.catch Landroid/os/RemoteException; {:try_start_0 .. :try_end_0} :catch_0
move v0, v8
.line 1294
goto :goto_0
.line 1296
:catch_0
move-exception v0
move-object v6, v0
.line 1298
.local v6, e:Landroid/os/RemoteException;
invoke-virtual {p0}, Lcld/navi/mainframe/MainActivity;->closeGPS()I
move v0, v9
.line 1299
goto :goto_0
.end local v6 #e:Landroid/os/RemoteException;
:cond_2
move v0, v9
.line 1304
goto :goto_0
.end method