My app crashes and gives me the following trace:
05-08 08:49:15.228: E/AndroidRuntime(1022): FATAL EXCEPTION: main
05-08 08:49:15.228: E/AndroidRuntime(1022): java.lang.IllegalStateException: Activity has been destroyed
05-08 08:49:15.228: E/AndroidRuntime(1022): at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1365)
05-08 08:49:15.228: E/AndroidRuntime(1022): at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:595)
05-08 08:49:15.228: E/AndroidRuntime(1022): at android.support.v4.app.BackStackRecord.commitAllowingStateLoss(BackStackRecord.java:578)
05-08 08:49:15.228: E/AndroidRuntime(1022): at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:161)
05-08 08:49:15.228: E/AndroidRuntime(1022): at com.automation.standards.VerticalViewPager.populate(VerticalViewPager.java:965)
05-08 08:49:15.228: E/AndroidRuntime(1022): at com.automation.standards.VerticalViewPager.populate(VerticalViewPager.java:811)
05-08 08:49:15.228: E/AndroidRuntime(1022): at com.automation.standards.VerticalViewPager.setAdapter(VerticalViewPager.java:334)
05-08 08:49:15.228: E/AndroidRuntime(1022): at com.automation.isolace.Lighting.assign_vertical_gangs_swipping(Lighting.java:505)
05-08 08:49:15.228: E/AndroidRuntime(1022): at com.automation.isolace.Lighting.select_room(Lighting.java:403)
05-08 08:49:15.228: E/AndroidRuntime(1022): at com.automation.isolace.Lighting$11.onClick(Lighting.java:351)
05-08 08:49:15.228: E/AndroidRuntime(1022): at android.view.View.performClick(View.java:4084)
05-08 08:49:15.228: E/AndroidRuntime(1022): at android.view.View$PerformClick.run(View.java:16966)
05-08 08:49:15.228: E/AndroidRuntime(1022): at android.os.Handler.handleCallback(Handler.java:615)
05-08 08:49:15.228: E/AndroidRuntime(1022): at android.os.Handler.dispatchMessage(Handler.java:92)
05-08 08:49:15.228: E/AndroidRuntime(1022): at android.os.Looper.loop(Looper.java:137)
05-08 08:49:15.228: E/AndroidRuntime(1022): at android.app.ActivityThread.main(ActivityThread.java:4745)
05-08 08:49:15.228: E/AndroidRuntime(1022): at java.lang.reflect.Method.invokeNative(Native Method)
05-08 08:49:15.228: E/AndroidRuntime(1022): at java.lang.reflect.Method.invoke(Method.java:511)
05-08 08:49:15.228: E/AndroidRuntime(1022): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
05-08 08:49:15.228: E/AndroidRuntime(1022): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
05-08 08:49:15.228: E/AndroidRuntime(1022): at dalvik.system.NativeStart.main(Native Method)
The point is I can't deal with that Activity Destroy thing as the Activity is Destroyed without calling onDestroy() method and I figured that because I override the onDestroy method but it didn't go through it, also I checked the isDestroyed() output but the strange thing it even not giving me true despite I put the Line that makes the Activity crashes in a try-ctach block, and prints isDestroyed in the catch block (which can mean that that line itself is the one which makes the Activity crashes) and here's the code area that the app crashes in:
List<Fragment> temp_fragments = fragments; // list of fragments to add to a VerticalViewPager and return it through pageAdapter
TabAdapter2 = new LightVerticalPageAdapter(super.getSupportFragmentManager(), temp_fragments);
Tab2 = (VerticalViewPager) SomeFragment.views.findViewById(R.id.vertical_pager);// "SomeFragment" is the fragment that contains the VerticalPager and the "views" var is the var that stores Fragmrnt view when hitting fragment onViewCreated at the first time
Tab2.setAdapter(TabAdapter2); // HERE IS WHERE THE APP CRASHES AND NOT CALLS ACTIVITY onDestroy()
Related
I download the example from here. I imported the project in eclipse, added support library v4 to build path. When I run the app, it always crashes. This is the error in LogCat: Could anyone please help me? Thanks.
05-08 22:39:41.396: E/dalvikvm(22444): Could not find class 'com.example.android.scheduler.SampleAlarmReceiver', referenced from method com.example.android.scheduler.MainActivity.<init>
05-08 22:39:41.406: E/AndroidRuntime(22444): FATAL EXCEPTION: main
05-08 22:39:41.406: E/AndroidRuntime(22444): java.lang.NoClassDefFoundError: com.example.android.scheduler.SampleAlarmReceiver
05-08 22:39:41.406: E/AndroidRuntime(22444): at com.example.android.scheduler.MainActivity.<init>(MainActivity.java:34)
05-08 22:39:41.406: E/AndroidRuntime(22444): at java.lang.Class.newInstanceImpl(Native Method)
05-08 22:39:41.406: E/AndroidRuntime(22444): at java.lang.Class.newInstance(Class.java:1319)
05-08 22:39:41.406: E/AndroidRuntime(22444): at android.app.Instrumentation.newActivity(Instrumentation.java:1071)
05-08 22:39:41.406: E/AndroidRuntime(22444): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
05-08 22:39:41.406: E/AndroidRuntime(22444): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2521)
05-08 22:39:41.406: E/AndroidRuntime(22444): at android.app.ActivityThread.access$600(ActivityThread.java:162)
05-08 22:39:41.406: E/AndroidRuntime(22444): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1370)
05-08 22:39:41.406: E/AndroidRuntime(22444): at android.os.Handler.dispatchMessage(Handler.java:99)
05-08 22:39:41.406: E/AndroidRuntime(22444): at android.os.Looper.loop(Looper.java:158)
05-08 22:39:41.406: E/AndroidRuntime(22444): at android.app.ActivityThread.main(ActivityThread.java:5777)
05-08 22:39:41.406: E/AndroidRuntime(22444): at java.lang.reflect.Method.invokeNative(Native Method)
05-08 22:39:41.406: E/AndroidRuntime(22444): at java.lang.reflect.Method.invoke(Method.java:511)
05-08 22:39:41.406: E/AndroidRuntime(22444): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1083)
05-08 22:39:41.406: E/AndroidRuntime(22444): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:850)
05-08 22:39:41.406: E/AndroidRuntime(22444): at dalvik.system.NativeStart.main(Native Method)
I got the same issue when I added support v4 lib via "add external jar" in build path.
To solve it:
remove the support v4 lib from build path
create a directory named "libs" in the root on the project
copy the lib into the newly created directory.
Eclipse should now show a new "library directory" in your project called "Android Private Libraries" which include support library v4
Refresh, clean ... and it should work.
I am displaying Image in Android App from Hosted Server. So, I need to set StrictMode Policy.
But as I have checked, It requires Api 9 and I want to make it supportable in Api 8 also. So how can I solve this issue ? I am already using this in AsyncTask.
My Code :
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
If I am not using StrictMode then getting Error.
Logcat :
05-08 12:25:08.711: E/AndroidRuntime(27622): android.os.NetworkOnMainThreadException
05-08 12:25:08.711: E/AndroidRuntime(27622): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1208)
05-08 12:25:08.711: E/AndroidRuntime(27622): at java.net.InetAddress.lookupHostByName(InetAddress.java:388)
05-08 12:25:08.711: E/AndroidRuntime(27622): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:239)
05-08 12:25:08.711: E/AndroidRuntime(27622): at java.net.InetAddress.getAllByName(InetAddress.java:214)
05-08 12:25:08.711: E/AndroidRuntime(27622): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:70)
05-08 12:25:08.711: E/AndroidRuntime(27622): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
05-08 12:25:08.711: E/AndroidRuntime(27622): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340)
05-08 12:25:08.711: E/AndroidRuntime(27622): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
05-08 12:25:08.711: E/AndroidRuntime(27622): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
05-08 12:25:08.711: E/AndroidRuntime(27622): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:315)
05-08 12:25:08.711: E/AndroidRuntime(27622): at libcore.net.http.HttpEngine.connect(HttpEngine.java:310)
05-08 12:25:08.711: E/AndroidRuntime(27622): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:289)
05-08 12:25:08.711: E/AndroidRuntime(27622): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:239)
05-08 12:25:08.711: E/AndroidRuntime(27622): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:273)
05-08 12:25:08.711: E/AndroidRuntime(27622): at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:168)
05-08 12:25:08.711: E/AndroidRuntime(27622): at com.mytestbuddy.careermirror.Profile$UserProfile.onPostExecute(Profile.java:193)
05-08 12:25:08.711: E/AndroidRuntime(27622): at com.mytestbuddy.careermirror.Profile$UserProfile.onPostExecute(Profile.java:1)
05-08 12:25:08.711: E/AndroidRuntime(27622): at android.os.AsyncTask.finish(AsyncTask.java:631)
05-08 12:25:08.711: E/AndroidRuntime(27622): at android.os.AsyncTask.access$600(AsyncTask.java:177)
05-08 12:25:08.711: E/AndroidRuntime(27622): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
05-08 12:25:08.711: E/AndroidRuntime(27622): at android.os.Handler.dispatchMessage(Handler.java:99)
05-08 12:25:08.711: E/AndroidRuntime(27622): at android.os.Looper.loop(Looper.java:155)
05-08 12:25:08.711: E/AndroidRuntime(27622): at android.app.ActivityThread.main(ActivityThread.java:5511)
05-08 12:25:08.711: E/AndroidRuntime(27622): at java.lang.reflect.Method.invokeNative(Native Method)
05-08 12:25:08.711: E/AndroidRuntime(27622): at java.lang.reflect.Method.invoke(Method.java:511)
05-08 12:25:08.711: E/AndroidRuntime(27622): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
05-08 12:25:08.711: E/AndroidRuntime(27622): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:796)
05-08 12:25:08.711: E/AndroidRuntime(27622): at dalvik.system.NativeStart.main(Native Method)
To solve the NetworkOnMainThreadException you're seeing, read the HTTP response input stream in your doInBackground() and not in onPostExecute().
StrictMode is available from 2.3 only, So you can't use it in 2.2.
There is tow possible ways I can give you.
Go with 2.3 [or]
Use AsyncTask in android.
I go with AsyncTsk
I hope this will help you.
I'm creating a native extension that shows a native Google Map from a Flex-based AIR application. You can watch lee brimelow's demo to get the idea: https://plus.google.com/110495278155587072613/posts/degSYVx8423
I got a working demo of a native extension, just to show an Activity with some buttons, but I got stuck when I tried to show the map. Here is the exception I'm getting on setContentView(layoutID):
05-08 11:48:40.624: I/System.out(27917): WebViewActivity.onCreate failed with error:
05-08 11:48:40.634: I/System.out(27917): "android.view.InflateException: Binary XML file line #9: Error inflating class fragment"
05-08 11:48:40.644: W/dalvikvm(27917): threadid=1: thread exiting with uncaught exception (group=0x40fd8468)
05-08 11:48:40.654: E/AndroidRuntime(27917): FATAL EXCEPTION: main
05-08 11:48:40.654: E/AndroidRuntime(27917): java.lang.RuntimeException: Unable to start activity ComponentInfo{air.GoogleMapsApp.debug/com.trasys.googlemaps.WebViewActivity}: java.lang.RuntimeException: Attempting to create multiple DataRequestDispatchers
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2351)
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.ActivityThread.access$600(ActivityThread.java:151)
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1331)
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.os.Handler.dispatchMessage(Handler.java:99)
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.os.Looper.loop(Looper.java:155)
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.ActivityThread.main(ActivityThread.java:5454)
05-08 11:48:40.654: E/AndroidRuntime(27917): at java.lang.reflect.Method.invokeNative(Native Method)
05-08 11:48:40.654: E/AndroidRuntime(27917): at java.lang.reflect.Method.invoke(Method.java:511)
05-08 11:48:40.654: E/AndroidRuntime(27917): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
05-08 11:48:40.654: E/AndroidRuntime(27917): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:796)
05-08 11:48:40.654: E/AndroidRuntime(27917): at dalvik.system.NativeStart.main(Native Method)
05-08 11:48:40.654: E/AndroidRuntime(27917): Caused by: java.lang.RuntimeException: Attempting to create multiple DataRequestDispatchers
05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.ak.n.b(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.ak.n.a(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.ak.h.a(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.af.w.a(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.z.ab.a(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.z.ab.a(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.z.ag.a(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.z.ag.a(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.z.bw.a(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.z.r.onCreateView(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at com.google.android.gms.maps.internal.IMapFragmentDelegate$Stub.onTransact(IMapFragmentDelegate.java:107)
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.os.Binder.transact(Binder.java:326)
05-08 11:48:40.654: E/AndroidRuntime(27917): at com.google.android.gms.maps.internal.IMapFragmentDelegate$a$a.onCreateView(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at com.google.android.gms.maps.MapFragment$b.onCreateView(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at com.google.android.gms.internal.e$4.a(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at com.google.android.gms.internal.e.a(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at com.google.android.gms.internal.e.onCreateView(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at com.google.android.gms.maps.MapFragment.onCreateView(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:809)
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1037)
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1019)
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1804)
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.Activity.performCreate(Activity.java:5069)
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1101)
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307)
05-08 11:48:40.654: E/AndroidRuntime(27917): ... 11 more
I'm pretty convinced the communication between AIR and Android is ok, so I'm only posting my native code. (When I remove the map, the native extension works with no issues)
Here is the layout xml file
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical" >
<fragment android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="300dp" />
</LinearLayout>
Here is my FREFunction
public class GoogleMapsFunction implements FREFunction {
#Override
public FREObject call(FREContext ctx, FREObject[] passedArgs) {
int layoutID, googleMapID;
Intent i = new Intent(ctx.getActivity(), WebViewActivity.class);
layoutID = ctx.getResourceId("layout.activity_google_maps");
googleMapID = ctx.getResourceId("id.map");
i.putExtra("layoutID", layoutID);
i.putExtra("googleMapID", googleMapID);
ctx.getActivity().startActivity(i);
return null;
}
}
Here is my Activity
public class WebViewActivity extends Activity {
private GoogleMap map;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
int layoutID = getIntent().getIntExtra("layoutID", -1);
setContentView(layoutID);
int googleMapID = getIntent().getIntExtra("googleMapID", -1);
map = ((MapFragment) getFragmentManager().findFragmentById(googleMapID))
.getMap();
} catch(Exception e){
System.out.printf("WebViewActivity.onCreate failed with error:\n\"%s\"\n",
e.toString());
Toast.makeText(this, "WebViewActivity.onCreate failed: " +
e.toString(), Toast.LENGTH_SHORT).show();
}
}
}
Here is my AndroidManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.trasys.googlemaps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="17" />
<permission android:name="com.example.helloworld.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.example.helloworld.permission.C2D_MESSAGE" />
<permission android:name="com.example.helloworld.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<uses-permission android:name="com.example.helloworld.permission.MAPS_RECEIVE"/>
<!-- App receives GCM messages. -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!-- GCM connects to Google Services. -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<!-- Keeps the processor from sleeping when a message is received. -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- The following two permissions are not required to use
Google Maps Android API v2, but are recommended. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name">
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="MyApiKey"/>
</application>
</manifest>
I see some com.google.android.gms. entries in the stacktrace, so I assume all google libraries are loaded correctly.
I created a separate pure native android application for testing purpose.
In this app I managed to create an activity which displays the map, this activity uses the same layout XML, the same google libraries and the same API key.
Any idea's?
You need to include third party classes on the jar file that is why fragment class is not found "Error inflating class fragment" .
After exporting your java files open the jar file with any zip tool like 7-zip, browse to com folder and copy the packages from third party jar file (opening it same way). After that you will need to recreate the ane file.
I have this strange behavior I cannot explain.
My layout is quite simple: An EditText:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:padding="10dp" >
<EditText
android:id="#+id/etPass"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
When I try to longPress it (to paste some text) I got an imediate Force Close and this error:
05-08 16:56:16.838: E/AndroidRuntime(12164): FATAL EXCEPTION: main
05-08 16:56:16.838: E/AndroidRuntime(12164): android.view.InflateException: Binary XML file line #17: Error inflating class <unknown>
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
05-08 16:56:16.838: E/AndroidRuntime(12164): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.Editor$ActionPopupWindow.initContentView(Editor.java:2995)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.Editor$PinnedPopupWindow.<init>(Editor.java:2280)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:2968)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:2968)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.Editor$HandleView.showActionPopupWindow(Editor.java:3189)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.Editor$InsertionHandleView.showWithActionPopup(Editor.java:3416)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.Editor$InsertionPointCursorController.showWithActionPopup(Editor.java:3652)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.Editor.performLongClick(Editor.java:870)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.TextView.performLongClick(TextView.java:7973)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.view.View$CheckForLongPress.run(View.java:17140)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.os.Handler.handleCallback(Handler.java:615)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.os.Handler.dispatchMessage(Handler.java:92)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.os.Looper.loop(Looper.java:213)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.app.ActivityThread.main(ActivityThread.java:4786)
05-08 16:56:16.838: E/AndroidRuntime(12164): at java.lang.reflect.Method.invokeNative(Native Method)
05-08 16:56:16.838: E/AndroidRuntime(12164): at java.lang.reflect.Method.invoke(Method.java:511)
05-08 16:56:16.838: E/AndroidRuntime(12164): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
05-08 16:56:16.838: E/AndroidRuntime(12164): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
05-08 16:56:16.838: E/AndroidRuntime(12164): at dalvik.system.NativeStart.main(Native Method)
05-08 16:56:16.838: E/AndroidRuntime(12164): Caused by: java.lang.reflect.InvocationTargetException
05-08 16:56:16.838: E/AndroidRuntime(12164): at java.lang.reflect.Constructor.constructNative(Native Method)
05-08 16:56:16.838: E/AndroidRuntime(12164): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
05-08 16:56:16.838: E/AndroidRuntime(12164): ... 25 more
05-08 16:56:16.838: E/AndroidRuntime(12164): Caused by: java.lang.ArrayIndexOutOfBoundsException: length=15; index=491
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.content.res.StringBlock.get(StringBlock.java:64)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.content.res.XmlBlock$Parser.getPooledString(XmlBlock.java:458)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.content.res.TypedArray.loadStringValueAt(TypedArray.java:720)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.content.res.TypedArray.getString(TypedArray.java:124)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.TextView.<init>(TextView.java:800)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.TextView.<init>(TextView.java:450)
05-08 16:56:16.838: E/AndroidRuntime(12164): ... 28 more
I have really no clue what's happening, and I would be pleased to get some help!
Just to be clear, I have nothing in my Activity related to a listener on this EditText:
import android.app.Activity;
import android.os.Bundle;
public class ProActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.activity_pro);
}
}
Just remove this line from your custom style
This single line:
<item name="android:fontFamily">sans-serif-light</item>
Will make the EditText crash when long pressing it.
The Android copy/paste popup was the root cause of the error.
this link solved my issue, although the auto-complete in xml files was not working, but the code in this example is correct, i declared all in the same styles file and it worked :
https://github.com/rengwuxian/MaterialEditText/issues/162
and that's what was said in it :
Seems to be an error in styles, verify if you have
<item name="android:fontFamily"></item>
in your application theme, not in the themes view, in application theme.
The same error happened to me until i removed this line of my style.xml, if you have that line, remove them, if you need this property, you can stylize textviews and buttons with:
<style name="TextViewStyle" parent="android:Widget.TextView">
<item name="android:fontFamily">sans-serif-medium</item>
</style>
<style name="ButtonStyle" parent="android:Widget.Holo.Button">
<item name="android:fontFamily">sans-serif-medium</item>
</style>
And in your app theme, use:
<item name="android:textViewStyle">#style/TextViewStyle</item>
<item name="android:buttonStyle">#style/ButtonStyle</item>
I have also encountered this problem ;
but the cause of it is that i use ContextThemeWrapper;
here is how we get LayoutInflater from ContextThemeWrapper
#Override
public Object getSystemService(String name) {
if (LAYOUT_INFLATER_SERVICE.equals(name)) {
if (mInflater == null) {
mInflater = LayoutInflater.from(mBase).cloneInContext(this);
}
return mInflater;
}
return mBase.getSystemService(name);
}
from the code block above, we can see that it handle LayoutInflater specially, which is the source of the problem.
my solution is : override this method as follow
#Override
public Object getSystemService(String name){
return getBaseContext().getSystemService(name);
}
I face this problem when using <item name="android:fontFamily">sans-serif</item> in style.xml
It CRASH on
Samsung S4 (SC-04E) (5.0.1)
Samsung Galaxy Node 5 (5.1.1)
It NOT CRASH on
Samsung S7 Edge (SM-G935F) (7.0)
Xiaomi A2 (8.0.1)
Pixel XL (8.1.0)
Sony Xperia Z5 Au (SOV32) (6.0)
Arrow NX (F-04G) (6.0.1)
Kyocera (S2) (7.0)
At first, I think this problem will only happened on Samsung but Samsung S7 don't crash.
Then I think the API may cause this problem because current crash device have API < 6.0. However I am not sure about it because I don't have much device for testing
Summary: It will crash in some device
TO FIX THIS PROBLEM
First, remove sans-serif
Then download Roboto font from https://github.com/google/fonts/tree/master/apache/roboto then add to project following https://developer.android.com/guide/topics/ui/look-and-feel/fonts-in-xml
Why Roboto font?
You are facing this problem when using sans-serif font right?
sans-serif in Android is Roboto font (see here Android default font)
If you know some device which will crash, please edit my answer, it may help for testing.
Hope it help
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
05-08 11:04:12.336: E/AndroidRuntime(678): FATAL EXCEPTION: main
05-08 11:04:12.336: E/AndroidRuntime(678): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android/com.android.Calendar_googleActivity}: android.os.NetworkOnMainThreadException
05-08 11:04:12.336: E/AndroidRuntime(678): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
05-08 11:04:12.336: E/AndroidRuntime(678): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-08 11:04:12.336: E/AndroidRuntime(678): at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-08 11:04:12.336: E/AndroidRuntime(678): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-08 11:04:12.336: E/AndroidRuntime(678): at android.os.Handler.dispatchMessage(Handler.java:99)
05-08 11:04:12.336: E/AndroidRuntime(678): at android.os.Looper.loop(Looper.java:137)
05-08 11:04:12.336: E/AndroidRuntime(678): at android.app.ActivityThread.main(ActivityThread.java:4424)
05-08 11:04:12.336: E/AndroidRuntime(678): at java.lang.reflect.Method.invokeNative(Native Method)
05-08 11:04:12.336: E/AndroidRuntime(678): at java.lang.reflect.Method.invoke(Method.java:511)
05-08 11:04:12.336: E/AndroidRuntime(678): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-08 11:04:12.336: E/AndroidRuntime(678): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-08 11:04:12.336: E/AndroidRuntime(678): at dalvik.system.NativeStart.main(Native Method)
05-08 11:04:12.336: E/AndroidRuntime(678): Caused by: android.os.NetworkOnMainThreadException
05-08 11:04:12.336: E/AndroidRuntime(678): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099)
05-08 11:04:12.336: E/AndroidRuntime(678): at java.net.InetAddress.lookupHostByName(InetAddress.java:391)
05-08 11:04:12.336: E/AndroidRuntime(678): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242)
05-08 11:04:12.336: E/AndroidRuntime(678): at java.net.InetAddress.getAllByName(InetAddress.java:220)
05-08 11:04:12.336: E/AndroidRuntime(678): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:71)
05-08 11:04:12.336: E/AndroidRuntime(678): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
05-08 11:04:12.336: E/AndroidRuntime(678): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:351)
05-08 11:04:12.336: E/AndroidRuntime(678): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:86)
05-08 11:04:12.336: E/AndroidRuntime(678): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
05-08 11:04:12.336: E/AndroidRuntime(678): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:308)
05-08 11:04:12.336: E/AndroidRuntime(678): at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:460)
05-08 11:04:12.336: E/AndroidRuntime(678): at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.connect(HttpsURLConnectionImpl.java:432)
05-08 11:04:12.336: E/AndroidRuntime(678): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282)
05-08 11:04:12.336: E/AndroidRuntime(678): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232)
05-08 11:04:12.336: E/AndroidRuntime(678): at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
05-08 11:04:12.336: E/AndroidRuntime(678): at libcore.net.http.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:164)
05-08 11:04:12.336: E/AndroidRuntime(678): at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:88)
05-08 11:04:12.336: E/AndroidRuntime(678): at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:814)
05-08 11:04:12.336: E/AndroidRuntime(678): at com.google.api.client.googleapis.json.GoogleJsonResponseException.execute(GoogleJsonResponseException.java:182)
05-08 11:04:12.336: E/AndroidRuntime(678): at com.google.api.client.googleapis.services.GoogleClient.executeUnparsed(GoogleClient.java:115)
05-08 11:04:12.336: E/AndroidRuntime(678): at com.google.api.client.http.json.JsonHttpRequest.executeUnparsed(JsonHttpRequest.java:112)
05-08 11:04:12.336: E/AndroidRuntime(678): at com.google.api.services.calendar.Calendar$CalendarList$List.execute(Calendar.java:510)
05-08 11:04:12.336: E/AndroidRuntime(678): at com.android.Calendar_googleActivity.onAuthToken(Calendar_googleActivity.java:267)
05-08 11:04:12.336: E/AndroidRuntime(678): at com.android.Calendar_googleActivity.gotAccount(Calendar_googleActivity.java:118)
05-08 11:04:12.336: E/AndroidRuntime(678): at com.android.Calendar_googleActivity.onCreate(Calendar_googleActivity.java:108)
05-08 11:04:12.336: E/AndroidRuntime(678): at android.app.Activity.performCreate(Activity.java:4465)
05-08 11:04:12.336: E/AndroidRuntime(678): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
05-08 11:04:12.336: E/AndroidRuntime(678): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
05-08 11:04:12.336: E/AndroidRuntime(678): ... 11 more
Caused by: android.os.NetworkOnMainThreadException
You've always been warned against doing networking on the UI thread as that could lead to UI lag and application not responding errors if the network operation is delayed.
In recent releases you are now actually prohibited - by the proactive error above - from attempting to 'get away with it'
So get your network usage off of the UI thread and you should be all set. We do not need to discuss how to do that here - it's well covered in the documentation and previous questions.