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...
}
Related
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 try to add Google MAP Api v2 in my application.but I am getting exception. Exception is
java.lang.RuntimeException: Unable to start activity ComponentInfo{info.androidhive.googlemapsv2/info.androidhive.googlemapsv2.MainActivity}: android.view.InflateException: Binary XML file line #5: Error inflating class fragment
Here is my xml class
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
this is my main class
public class MainActivity extends Activity {
private GoogleMap _googleMap=null;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try
{
//loading map
initilizeMap();
_googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
_googleMap.setMyLocationEnabled(true);
} catch (Exception e) {
e.printStackTrace();
}
}
private void initilizeMap() {
if(_googleMap==null)
{
_googleMap=((MapFragment)getFragmentManager().findFragmentById(R.id.map)).getMap();
if (_googleMap == null) {
Toast.makeText(getApplicationContext(),
"Sorry! unable to create maps", Toast.LENGTH_SHORT)
.show();
}
}
}
#Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
initilizeMap();
}
}
this is my logcat
01-31 14:20:55.603: E/AndroidRuntime(311): FATAL EXCEPTION: main
01-31 14:20:55.603: E/AndroidRuntime(311): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.demo/com.example.demo.MainActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
01-31 14:20:55.603: E/AndroidRuntime(311): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.os.Handler.dispatchMessage(Handler.java:99)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.os.Looper.loop(Looper.java:123)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.app.ActivityThread.main(ActivityThread.java:4627)
01-31 14:20:55.603: E/AndroidRuntime(311): at java.lang.reflect.Method.invokeNative(Native Method)
01-31 14:20:55.603: E/AndroidRuntime(311): at java.lang.reflect.Method.invoke(Method.java:521)
01-31 14:20:55.603: E/AndroidRuntime(311): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-31 14:20:55.603: E/AndroidRuntime(311): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-31 14:20:55.603: E/AndroidRuntime(311): at dalvik.system.NativeStart.main(Native Method)
01-31 14:20:55.603: E/AndroidRuntime(311): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
01-31 14:20:55.603: E/AndroidRuntime(311): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
01-31 14:20:55.603: E/AndroidRuntime(311): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.app.Activity.setContentView(Activity.java:1647)
01-31 14:20:55.603: E/AndroidRuntime(311): at com.example.demo.MainActivity.onCreate(MainActivity.java:22)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
01-31 14:20:55.603: E/AndroidRuntime(311): ... 11 more
01-31 14:20:55.603: E/AndroidRuntime(311): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/data/app/com.example.demo-2.apk]
01-31 14:20:55.603: E/AndroidRuntime(311): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
01-31 14:20:55.603: E/AndroidRuntime(311): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
01-31 14:20:55.603: E/AndroidRuntime(311): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:544)
01-31 14:20:55.603: E/AndroidRuntime(311): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
You should use SupportMapFragment instead of MapFragment.
Change
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
to
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
Also change
_googleMap=((MapFragment)getFragmentManager().findFragmentById(R.id.map)).getMap();
to
_googleMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(
R.id.map)).getMap();
And also If you're using fragments on older devices (pre Honeycomb) you should always extend your Activity from FragmentActivity.
and also check
Add the Google Play services version to your app's manifest
Edit your application's AndroidManifest.xml file, and add the
following declaration within the element. This embeds the version of
Google Play services that the app was compiled with.
You just need to add <meta-data> under <application> tag into your AndroidManifest.xml
....<application>
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
This is because latest google play services requires a version name, which is to be mentioned using <meta-data .. /> inside AndroidManifest.xml
Extend your MainActivity from FragmentActivity.
Refer this :
Inflating Google Maps v2 fragment causes ClassNotFoundException
If you are using Fragments your MainActivity must extends FragmentActivity:
public class MainActivity extends FragmentActivity {
//Stuff
}
If you are using the Support-Library so you can use your Fragments in lower Android API Levels use This:
public class MainActivity extends android.support.v4.app.FragmentActivity{
//Stuff
}
And use the SupportFragmentMap in your XML:
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
In your xml try to change from
android:name="com.google.android.gms.maps.MapFragment"
to
android:name="com.google.android.gms.maps.SupportMapFragment"
Check if this work.
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.
i got following strange exception on only andorid simulator 2.0
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.markupartist.android.example.pulltorefresh/com.markupartist.android.example.pulltorefresh.PullToRefreshActivity}: android.view.InflateException: Binary XML file line #10: Error inflating class com.markupartist.android.widget.PullToRefreshListView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class com.markupartist.android.widget.PullToRefreshListView
at android.view.LayoutInflater.createView(LayoutInflater.java:513)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
at android.app.Activity.setContentView(Activity.java:1647)
at com.markupartist.android.example.pulltorefresh.PullToRefreshActivity.onCreate(PullToRefresh Activity.java:21)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at com.markupartist.android.widget.PullToRefreshListView. (PullToRefreshListView.java:54)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
at android.view.LayoutInflater.createView(LayoutInflater.java:500)
... 21 more
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030002
at android.content.res.Resources.getValue(Resources.java:892)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:1869)
at android.content.res.Resources.getLayout(Resources.java:731)
at android.view.LayoutInflater.inflate(LayoutInflater.java:318)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.markupartist.android.widget.PullToRefreshListView.init(PullToRefreshListView.java:80)
... 25 more
when i tested on andorid 1.6 , 2.01,2.1,2.2,2.3 ,4.0 it works completely,
is this a simulator bug of 2.0
please give me some information about this
Thanks
I am trying to inflate a layout containing a Fragment using the backwards compatibility package. I took the jar file and placed it in the libs folder of my project. I extended Fragment and then tried to inflate it by setting the contentView of the Activity to
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<fragment
class="com.test.fragments.AdFragment"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/></LinearLayout>
But when I set the content view it fails with a ClassNotFoundException for the fragment tag.
Here is the logcat output.
java.lang.RuntimeException: Unable to start activity ComponentInfo{}: \
android.view.InflateException: Binary XML file line #51: \
Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1777)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1793)
at android.app.ActivityThread.access$1500(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3848)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #51: \
Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:211)
at android.app.Activity.setContentView(Activity.java:1657)
at com.test.base.activities.TabbedStoreActivity.onCreate(TabbedStoreActivity.java:46)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1731)
... 11 more
Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader \
dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar: \
/data/app/com.test.test.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at android.view.LayoutInflater.createView(LayoutInflater.java:471)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:549)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
... 20 more
Make sure your activity is inheriting from FragmentActivity, otherwise <fragment> does not work. Here is a sample project demonstrating this.