I try to run iperf server and client in my android device so i develop an app using exec() and it is working fine for ls, ping etc. command but when i try to run iperf -s i got error, Here is the code and i added internet permission in manifest file. Help will appreciate
What will be the working directory and environment for iperf command??
StringBuffer output = new StringBuffer();
Process p;
try {
p = Runtime.getRuntime().exec(command);
p.waitFor();
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = "";
while ((line = reader.readLine())!= null) {
output.append(line + "\n");
}
}
I got following Error
06-14 13:14:01.023: W/System.err(1465): java.io.IOException: Error running exec(). Command: [iperf, -s] Working Directory: null Environment: null
06-14 13:14:01.033: W/System.err(1465): at java.lang.ProcessManager.exec(ProcessManager.java:211)
06-14 13:14:01.033: W/System.err(1465): at java.lang.Runtime.exec(Runtime.java:173)
06-14 13:14:01.053: W/System.err(1465): at java.lang.Runtime.exec(Runtime.java:246)
06-14 13:14:01.053: W/System.err(1465): at java.lang.Runtime.exec(Runtime.java:189)
06-14 13:14:01.053: W/System.err(1465): at com.learn2crack.androidshell.ShellExecuter.Executer(ShellExecuter.java:20)
06-14 13:14:01.053: W/System.err(1465): at com.learn2crack.androidshell.MainActivity$1.onClick(MainActivity.java:33)
06-14 13:14:01.063: W/System.err(1465): at android.view.View.performClick(View.java:4438)
06-14 13:14:01.063: W/System.err(1465): at android.view.View$PerformClick.run(View.java:18422)
06-14 13:14:01.063: W/System.err(1465): at android.os.Handler.handleCallback(Handler.java:733)
06-14 13:14:01.063: W/System.err(1465): at android.os.Handler.dispatchMessage(Handler.java:95)
06-14 13:14:01.063: W/System.err(1465): at android.os.Looper.loop(Looper.java:136)
06-14 13:14:01.073: W/System.err(1465): at android.app.ActivityThread.main(ActivityThread.java:5017)
06-14 13:14:01.073: W/System.err(1465): at java.lang.reflect.Method.invokeNative(Native Method)
06-14 13:14:01.073: W/System.err(1465): at java.lang.reflect.Method.invoke(Method.java:515)
06-14 13:14:01.083: W/System.err(1465): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
06-14 13:14:01.083: W/System.err(1465): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
06-14 13:14:01.103: W/System.err(1465): at dalvik.system.NativeStart.main(Native Method)
06-14 13:14:01.113: W/System.err(1465): Caused by: java.io.IOException: Permission denied
06-14 13:14:01.113: W/System.err(1465): at java.lang.ProcessManager.exec(Native Method)
06-14 13:14:01.113: W/System.err(1465): at java.lang.ProcessManager.exec(ProcessManager.java:209)
06-14 13:14:01.123: W/System.err(1465): ... 16 more
Sound a permissions problem check your logcat line:
Caused by: java.io.IOException: Permission denied
Maybe you can try execute a binary iperf in a external sd card? try to add permissions to read/write external storage.
Related
I am getting the following error in nexus 5 when I play the video for 5-10 minutes.This error is not occurring always.It is working in nexus 9 and samsung duos.
10-08 09:03:14.033 14588-14599 W/AudioSystem﹕ AudioFlinger server died!
10-08 09:03:14.033 14588-14778 W/IMediaDeathNotifier﹕ media server died
10-08 09:03:14.043 14588-14778 E/MediaPlayer﹕ error (100, 0)
10-08 09:03:14.043 14588-14588 D/AndroidRuntime﹕ Shutting down VM
10-08 09:03:14.043 14588-14588 W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41849ba8)
10-08 09:03:14.043 14588-14588 E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: , PID: 14588
java.lang.RuntimeException: failure code: -32
at android.media.MediaPlayer.invoke(MediaPlayer.java:664)
at android.media.MediaPlayer.getInbandTrackInfo(MediaPlayer.java:1692)
at android.media.MediaPlayer.scanInternalSubtitleTracks(MediaPlayer.java:1851)
at android.media.MediaPlayer.access$600(MediaPlayer.java:529)
at android.media.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:2198)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
It is working in nexus 5 emulator also.What might be the problem?and how to solve it?
Main reasons is memory issues, second could be mutlithread access on MediaPlayer. Do you have the code so we can elaborate more?
I am trying connect to a local XMPP server (Vysper) from an Android App using this code:
// ...
ConnectionConfiguration connectionConfig = new ConnectionConfiguration("192.168.1.107", 5222);
// load file from "Pictures" directory from Internal Memory
File file = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
file.mkdirs();
connectionConfig.setSecurityMode(ConnectionConfiguration.SecurityMode.required);
System.setProperty("javax.net.ssl.trustStore", file + "/clientkeystore");
Log.i("Info", file.getAbsolutePath());
XMPPConnection connection = new XMPPTCPConnection(connectionConfig);
SASLAuthentication.supportSASLMechanism("PLAIN", 0);
connection.connect();
//...
This is the stack trace:
01-27 20:41:07.489 3229-3229/ E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.bm.sam, PID: 3229
java.lang.IllegalStateException: Could not execute method of the activity
at android.view.View$1.onClick(View.java:3823)
at android.view.View.performClick(View.java:4438)
at android.view.View$PerformClick.run(View.java:18422)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at android.view.View$1.onClick(View.java:3818)
at android.view.View.performClick(View.java:4438)
at android.view.View$PerformClick.run(View.java:18422)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException: println needs a message
at android.util.Log.println_native(Native Method)
at android.util.Log.e(Log.java:232)
at com.bm.sam.LoginActivity.onClickLoginButton(LoginActivity.java:187)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at android.view.View$1.onClick(View.java:3818)
at android.view.View.performClick(View.java:4438)
at android.view.View$PerformClick.run(View.java:18422)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
I am using aSmack 4.0.6 and the Android API 19.
Android network permissions and file permissions have been granted:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
What is wrong?
Your error log says you have a Log.e that is empty, so check that Log first:
Caused by: java.lang.NullPointerException: println needs a message
at android.util.Log.println_native(Native Method)
at android.util.Log.e(Log.java:232)
when I import the viewpagerindicator project library into my application that works without the support library, it crashes on launch. I've tried it with more than one application with the same results. Here is the logcat output:
06-14 17:19:02.351: E/AndroidRuntime(589): FATAL EXCEPTION: main
06-14 17:19:02.351: E/AndroidRuntime(589): Process: com.example.android.navigationdrawerexample, PID: 589
06-14 17:19:02.351: E/AndroidRuntime(589): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.android.navigationdrawerexample/com.example.android.navigationdrawerexample.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.android.navigationdrawerexample.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.android.navigationdrawerexample-9.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.android.navigationdrawerexample-9, /vendor/lib, /system/lib]]
06-14 17:19:02.351: E/AndroidRuntime(589): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)
06-14 17:19:02.351: E/AndroidRuntime(589): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
06-14 17:19:02.351: E/AndroidRuntime(589): at android.app.ActivityThread.access$900(ActivityThread.java:161)
06-14 17:19:02.351: E/AndroidRuntime(589): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
06-14 17:19:02.351: E/AndroidRuntime(589): at android.os.Handler.dispatchMessage(Handler.java:102)
06-14 17:19:02.351: E/AndroidRuntime(589): at android.os.Looper.loop(Looper.java:157)
06-14 17:19:02.351: E/AndroidRuntime(589): at android.app.ActivityThread.main(ActivityThread.java:5356)
06-14 17:19:02.351: E/AndroidRuntime(589): at java.lang.reflect.Method.invokeNative(Native Method)
06-14 17:19:02.351: E/AndroidRuntime(589): at java.lang.reflect.Method.invoke(Method.java:515)
06-14 17:19:02.351: E/AndroidRuntime(589): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
06-14 17:19:02.351: E/AndroidRuntime(589): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
06-14 17:19:02.351: E/AndroidRuntime(589): at dalvik.system.NativeStart.main(Native Method)
06-14 17:19:02.351: E/AndroidRuntime(589): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.android.navigationdrawerexample.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.android.navigationdrawerexample-9.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.android.navigationdrawerexample-9, /vendor/lib, /system/lib]]
06-14 17:19:02.351: E/AndroidRuntime(589): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
06-14 17:19:02.351: E/AndroidRuntime(589): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
06-14 17:19:02.351: E/AndroidRuntime(589): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
06-14 17:19:02.351: E/AndroidRuntime(589): at android.app.Instrumentation.newActivity(Instrumentation.java:1079)
06-14 17:19:02.351: E/AndroidRuntime(589): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2222)
06-14 17:19:02.351: E/AndroidRuntime(589): ... 11 more
So it turns out that the problem was that all of my android-support-v4.jar library files were different. So all I did was copied the latest v4 .jar files into the "libs" folder of both my project and library, added it to the build path, and voilà no more crashes!
I am using code to populate an EditText view with a string from an array. I then use the .setSelection() function to move the cursor to the end of the view to more easily allow the user to append characters to the string. This works well for all strings of 8 characters or less. However, if the string from the array is greater than 8 characters I am receiving the following error message:
java.lang.IndexOutOfBoundsException: setSpan (9 ... 9) ends beyond length 8
Here is the code:
TransactionDataView = (EditText) findViewById(R.id.etTransactionData);
TransactionDataView.setText(TransactionData[TransactionDataIndex]);
TransactionDataView.setSelection(TransactionData[TransactionDataIndex].length());
From the LogCat I can see what the array subscript is, the string value and the length of the string. Immediately after trying to set the selection I receive the IndexOutOfBoundsException.
06-14 10:18:52.244: D/DataEntry(706): TransactionDataIndex = 0
06-14 10:18:52.244: D/DataEntry(706): TransactionData = 123456789
06-14 10:18:52.244: D/DataEntry(706): TransactionData.Length = 9
06-14 10:18:52.244: W/dalvikvm(706): threadid=1: thread exiting with uncaught exception (group=0x42065438)
06-14 10:18:52.264: E/AndroidRuntime(706): FATAL EXCEPTION: main
06-14 10:18:52.264: E/AndroidRuntime(706): java.lang.IllegalStateException: Could not execute method of the activity
06-14 10:18:52.264: E/AndroidRuntime(706): at android.view.View$1.onClick(View.java:3674)
06-14 10:18:52.264: E/AndroidRuntime(706): at android.view.View.performClick(View.java:4198)
06-14 10:18:52.264: E/AndroidRuntime(706): at android.view.View$PerformClick.run(View.java:17164)
06-14 10:18:52.264: E/AndroidRuntime(706): at android.os.Handler.handleCallback(Handler.java:615)
06-14 10:18:52.264: E/AndroidRuntime(706): at android.os.Handler.dispatchMessage(Handler.java:92)
06-14 10:18:52.264: E/AndroidRuntime(706): at android.os.Looper.loop(Looper.java:137)
06-14 10:18:52.264: E/AndroidRuntime(706): at android.app.ActivityThread.main(ActivityThread.java:4918)
06-14 10:18:52.264: E/AndroidRuntime(706): at java.lang.reflect.Method.invokeNative(Native Method)
06-14 10:18:52.264: E/AndroidRuntime(706): at java.lang.reflect.Method.invoke(Method.java:511)
06-14 10:18:52.264: E/AndroidRuntime(706): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
06-14 10:18:52.264: E/AndroidRuntime(706): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
06-14 10:18:52.264: E/AndroidRuntime(706): at dalvik.system.NativeStart.main(Native Method)
06-14 10:18:52.264: E/AndroidRuntime(706): Caused by: java.lang.reflect.InvocationTargetException
06-14 10:18:52.264: E/AndroidRuntime(706): at java.lang.reflect.Method.invokeNative(Native Method)
06-14 10:18:52.264: E/AndroidRuntime(706): at java.lang.reflect.Method.invoke(Method.java:511)
06-14 10:18:52.264: E/AndroidRuntime(706): at android.view.View$1.onClick(View.java:3669)
06-14 10:18:52.264: E/AndroidRuntime(706): ... 11 more
06-14 10:18:52.264: E/AndroidRuntime(706): Caused by: java.lang.IndexOutOfBoundsException: setSpan (9 ... 9) ends beyond length 8
06-14 10:18:52.264: E/AndroidRuntime(706): at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1016)
06-14 10:18:52.264: E/AndroidRuntime(706): at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:592)
06-14 10:18:52.264: E/AndroidRuntime(706): at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:588)
06-14 10:18:52.264: E/AndroidRuntime(706): at android.text.Selection.setSelection(Selection.java:104)
06-14 10:18:52.264: E/AndroidRuntime(706): at android.text.Selection.setSelection(Selection.java:115)
06-14 10:18:52.264: E/AndroidRuntime(706): at android.widget.EditText.setSelection(EditText.java:108)
06-14 10:18:52.264: E/AndroidRuntime(706): at com.worldgiftcard.mobileterminal.DataEntry.onClick(DataEntry.java:152)
06-14 10:18:52.264: E/AndroidRuntime(706): ... 14 more
Has anyone else encountered this? Is this a bug in the Android code? Can anyone suggest a work around?
Any assistance would be appreciated. Thanks.
Try changing
TransactionDataView.setSelection(TransactionData[TransactionDataIndex].length());
to
TransactionDataView.setSelection(TransactionDataView.getText().length());
In your IndexOutOfBoundsException, the length at the end (8) is not the length of the value of the EditText but is its android:maxLength attribute value.
In your case, this value is implicitely or explicitely set to 8, hence the reason for your exception.
You need to make sure you don't setSelection() beyond the maxLength of your EditText.
Rgds.
06-14 22:13:33.992: ERROR/AndroidRuntime(331): Uncaught handler: thread main exiting due to uncaught exception
06-14 22:13:34.031: ERROR/AndroidRuntime(331): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.example.HelloMap}: android.view.InflateException: Binary XML file line #6: Error inflating class com.google.android.maps.MapView
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at android.os.Handler.dispatchMessage(Handler.java:99)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at android.os.Looper.loop(Looper.java:123)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at android.app.ActivityThread.main(ActivityThread.java:4363)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at java.lang.reflect.Method.invokeNative(Native Method)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at java.lang.reflect.Method.invoke(Method.java:521)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at dalvik.system.NativeStart.main(Native Method)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class com.google.android.maps.MapView
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at android.view.LayoutInflater.createView(LayoutInflater.java:513)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at android.app.Activity.setContentView(Activity.java:1622)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at com.example.HelloMap.onCreate(HelloMap.java:16)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): ... 11 more
06-14 22:13:34.031: ERROR/AndroidRuntime(331): Caused by: java.lang.reflect.InvocationTargetException
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at com.google.android.maps.MapView.<init>(MapView.java:237)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at java.lang.reflect.Constructor.constructNative(Native Method)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at android.view.LayoutInflater.createView(LayoutInflater.java:500)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): ... 21 more
06-14 22:13:34.031: ERROR/AndroidRuntime(331): Caused by: java.lang.IllegalArgumentException: MapViews can only be created inside instances of MapActivity.
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at com.google.android.maps.MapView.<init>(MapView.java:281)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): at com.google.android.maps.MapView.<init>(MapView.java:254)
06-14 22:13:34.031: ERROR/AndroidRuntime(331): ... 25 more
I had done all configuration.
Here is my manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<application android:icon="#drawable/icon" android:label="#string/app_name">
<uses-library android:name="com.google.android.maps" />
<activity android:name="com.example.HelloMap"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
and my layout file main.xml is
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/mainlayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<com.google.android.maps.MapView
android:id="#+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="*************"
/>
</RelativeLayout>
And my Hellomap.java
public class HelloMap extends Activity {
LinearLayout linearLayout;
MapView mapView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mapview);
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
}
protected boolean isRouteDisplayed() {
return false;
}
}
Something I am missing I guess, or maybe the issue is with 2.1 Google API?
i got my answere myself
just see the exception log
last lines
MapViews can only be created inside instances of MapActivity. 06-14 22:13:34.031: ERROR/AndroidRuntime(331): at com.google.android.maps.MapView.(MapView.java:281) 06-14 22:13:34.031:
that means you need to extend your activity with MapActivity not Activity i guess most of you know but i got to know now
:)
I had this problem and solved it by the following 2 steps:
1) Put the following line in the application (important) element of AndroidManifest.xml file.
<uses-library android:name="com.google.android.maps" />
2) extend MapActivity instead of Activity.
enjoy!
Here i change Activity to MapActivity.
So Instead of
public class HelloMap extends Activity {
change it to
public class HelloMap extends MapActivity {
If you are new in using google maps and you have set the xml and activity and you got this type of error, then it means that you have't extend your class from MapsActivity, so extend your class from mapsactivity, it will start working !
//wrong usage of activity
public class A extends Actvitiy
{
}
//correct usage
public class A extedns MapsActivity {
//your all program...
}