android里用了个百度定位的sdk出现如下错误
08-12 23:55:42.527: W/System.err(2678): java.lang.NoSuchMethodException: startScan [boolean]08-12 23:55:42.536: W/System.err(2678): at java.lang.Class.getConstructorOrMethod(Class.java:423)
08-12 23:55:42.536: W/System.err(2678): at java.lang.Class.getDeclaredMethod(Class.java:589)
08-12 23:55:42.536: W/System.err(2678): at com.baidu.location.e.try(Unknown Source)
08-12 23:55:42.547: W/System.err(2678): at com.baidu.location.f.onCreate(Unknown Source)
08-12 23:55:42.547: W/System.err(2678): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2577)
08-12 23:55:42.547: W/System.err(2678): at android.app.ActivityThread.access$1600(ActivityThread.java:141)
08-12 23:55:42.547: W/System.err(2678): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1338)
08-12 23:55:42.547: W/System.err(2678): at android.os.Handler.dispatchMessage(Handler.java:99)
08-12 23:55:42.556: W/System.err(2678): at android.os.Looper.loop(Looper.java:137)
08-12 23:55:42.556: W/System.err(2678): at android.app.ActivityThread.main(ActivityThread.java:5103)
08-12 23:55:42.556: W/System.err(2678): at java.lang.reflect.Method.invokeNative(Native Method)
08-12 23:55:42.556: W/System.err(2678): at java.lang.reflect.Method.invoke(Method.java:525)
08-12 23:55:42.556: W/System.err(2678): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
08-12 23:55:42.566: W/System.err(2678): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-12 23:55:42.566: W/System.err(2678): at dalvik.system.NativeStart.main(Native Method)
08-12 23:55:42.566: D/baidu_location_service(2678): baidu location service start1 ...2678
08-12 23:55:42.587: D/baidu_location_client(2602): baidu location connected ...
08-12 23:55:42.687: D/dalvikvm(2678): Trying to load lib /data/app-lib/com.example.baidugps-1/liblocSDK3.so 0x41750a08
08-12 23:55:42.718: D/dalvikvm(2678): Added shared lib /data/app-lib/com.example.baidugps-1/liblocSDK3.so 0x41750a08
08-12 23:55:42.718: D/dalvikvm(2678): No JNI_OnLoad found in /data/app-lib/com.example.baidugps-1/liblocSDK3.so 0x41750a08, skipping init
08-12 23:55:43.447: D/dalvikvm(2678): GC_FOR_ALLOC freed 301K, 14% free 2718K/3136K, paused 48ms, total 52ms
部分Java代码如下
public void onClick(View arg0) {
// TODO Auto-generated method stub
if(mIsStart==false)
{
starBtn.setText("停止");
mIsStart=true;
setLocationOption();
locationClient.start();
locationClient.requestLocation();//返回定位(经纬度)到OnReceived()的参数location里面(异步返回)
String longitude=((Location)getApplication()).longitude;
String altitude=((Location)getApplication()).altitude;
values2.clear();
values2.add("12345678910");
values2.add(longitude);
values2.add(altitude);
Thread thread=new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
HttpConnSoap soap=new HttpConnSoap();
InputStream in= soap.GetServer("AddPoint","http://dingwei.aybm.cn/LocateWs.asmx", para2, values2);
}
});
thread.start();
}
else
{
locationClient.stop();
starBtn.setText("开始");
mIsStart=false;
}
}
Location类
public class Location extends Application{Android --------------------编程问答-------------------- 方法名写错了,或者就是该声明的没声明,该在清单文件中注册的没注册。 --------------------编程问答-------------------- 百度api有一個服務要註冊吧。
public LocationClient mLocationClient=null;
private String mdata;
public TextView mTV;
public MyLocationListener myLocationListener=new MyLocationListener();
String longitude="";
String altitude="";
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
mLocationClient=new LocationClient(getApplicationContext());
mLocationClient.registerLocationListener(myLocationListener);
}
public class MyLocationListener implements BDLocationListener{
public MyLocationListener() {
super();
}
@Override
public void onReceiveLocation(BDLocation arg0) {
// TODO Auto-generated method stub
if(arg0==null)
return;
TelephonyManager mTelephoneMgr=(TelephonyManager)getSystemService(getApplicationContext().TELEPHONY_SERVICE);
String imsi=mTelephoneMgr.getSubscriberId();
StringBuffer sb=new StringBuffer(256);
sb.append("phonenumber(imsi):"+imsi);
sb.append("\nlatitude:");
sb.append(arg0.getLatitude());
sb.append("\nlongitude:");
sb.append(arg0.getLongitude());
longitude=String.valueOf(arg0.getLongitude());
altitude=String.valueOf(arg0.getAltitude());
if(mTV!=null)
{
mTV.setText(sb.toString());
}
}
@Override
public void onReceivePoi(BDLocation arg0) {
// TODO Auto-generated method stub
}
}
}
<!-- 百度定位service -->
<service
android:name="com.baidu.location.f"
android:enabled="true"
android:process=":remote"/>
加上試試。 --------------------编程问答--------------------
我注册了 --------------------编程问答-------------------- 怎么解决啊,我也是这个问题! --------------------编程问答-------------------- 百度有文档,写一个demo试一下。我就按百度文档来的,没出问题 --------------------编程问答-------------------- 请问这个问题解决了么?我也存在这个问题,找到了其中的原因
http://bbs.lbsyun.baidu.com/viewthread.php?tid=4143
补充:移动开发 , Android