Android: Google scheduler example does not work - android

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.

Related

google maps ane: RuntimeException: Attempting to create multiple DataRequestDispatchers

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.

Android EditText on longPress: ArrayIndexOutOfBoundsException: length=15; index=491

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

Android ComponentInfo ClassNotFoundException on some devices

Please help to understand strange application behaviour.
In almost all devices in production everything is OK, I'm using ACRA to collect crash reports. But here is what I've got from Alpha GTR device:
ComponentInfo{com.xxxxxxxxxxx /com.xxxxxxxxxxx.xxxxActivity}: java.lang.ClassNotFoundException: com.xxxxxxxxxxx.xxxxActivity
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2108)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2211)
at android.app.ActivityThread.access$600(ActivityThread.java:149)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1300)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:4987)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.xxxxxxxxxxx.xxxxActivity
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2099)
... 11 more
java.lang.ClassNotFoundException: com.xxxxxxxxxxx.xxxxActivity
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2099)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2211)
at android.app.ActivityThread.access$600(ActivityThread.java:149)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1300)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:4987)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
at dalvik.system.NativeStart.main(Native Method)
So application failed to start with strange exception. I've already checked SO questions about it, and just adding libraries as Unable to instantiate activity... Caused by ClassNotFoundException doesn't help here.
Could it be some device-specific exception? My app uses Camera, Google Maps and GPS.
Maybe you have to check if GPS or Camera are supported by the device first?
LocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);

Adding microsoft excel jar file in eclipse

How to add excel jar Libraries in Eclipse and which jar file should i add and where to add in eclipse. please provide me full details.
i already check in this site but i am not getting any ideal. http://www.vogella.com/articles/Eclipse/article.html#classpath
please provide me external site that should show step by step process.
i have already added jxl-2.6 jar file .
And please tell me the configuration of Emulator. Because i am getting an error
05-08 16:47:07.585: ERROR/AndroidRuntime(335): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.com/com.com.test}: java.lang.ClassNotFoundException: com.com.test in loader dalvik.system.PathClassLoader[/data/app/com.com-1.apk]
05-08 16:47:07.585: ERROR/AndroidRuntime(335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
05-08 16:47:07.585: ERROR/AndroidRuntime(335): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-08 16:47:07.585: ERROR/AndroidRuntime(335): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-08 16:47:07.585: ERROR/AndroidRuntime(335): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-08 16:47:07.585: ERROR/AndroidRuntime(335): at android.os.Handler.dispatchMessage(Handler.java:99)
05-08 16:47:07.585: ERROR/AndroidRuntime(335): at android.os.Looper.loop(Looper.java:123)
05-08 16:47:07.585: ERROR/AndroidRuntime(335): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-08 16:47:07.585: ERROR/AndroidRuntime(335): at java.lang.reflect.Method.invokeNative(Native Method)
05-08 16:47:07.585: ERROR/AndroidRuntime(335): at java.lang.reflect.Method.invoke(Method.java:521)
05-08 16:47:07.585: ERROR/AndroidRuntime(335): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-08 16:47:07.585: ERROR/AndroidRuntime(335): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-08 16:47:07.585: ERROR/AndroidRuntime(335): at dalvik.system.NativeStart.main(Native Method)
05-08 16:47:07.585: ERROR/AndroidRuntime(335): Caused by: java.lang.ClassNotFoundException: com.com.test in loader dalvik.system.PathClassLoader[/data/app/com.com-1.apk]
05-08 16:47:07.585: ERROR/AndroidRuntime(335): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
05-08 16:47:07.585: ERROR/AndroidRuntime(335): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
05-08 16:47:07.585: ERROR/AndroidRuntime(335): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
05-08 16:47:07.585: ERROR/AndroidRuntime(335): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
05-08 16:47:07.585: ERROR/AndroidRuntime(335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
The error you included has nothing to do with the library you want to use.
It looks more that Android can not find your main activity class com.com.test.
Please check AndroidManifest.xml if all activities specified here are really implemented.
If everything looks OK make sure to execute "Clean" from the "Project" menu in Eclipse - sometimes the Android plugin in Eclipse has some problems maintaining all files in the latest state.

On rotate android application crashes

I have a application which use two layouts in portrait ans landscape. To load content form web at the initial load I use a AsyncTask and a progress bar.
I checked this. Since I have two layouts this is not the solution.
The exception is given below.
> 05-08 16:44:43.483: E/WindowManager(20138): Activity com.news.one has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView#482b0130 that was originally added here
05-08 16:44:43.483: E/WindowManager(20138): android.view.WindowLeaked: Activity com.news.one has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView#482b0130 that was originally added here
05-08 16:44:43.483: E/WindowManager(20138): at android.view.ViewRoot.<init>(ViewRoot.java:247)
05-08 16:44:43.483: E/WindowManager(20138): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:181)
05-08 16:44:43.483: E/WindowManager(20138): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:124)
05-08 16:44:43.483: E/WindowManager(20138): at android.view.Window$LocalWindowManager.addView(Window.java:424)
05-08 16:44:43.483: E/WindowManager(20138): at android.app.Dialog.show(Dialog.java:241)
05-08 16:44:43.483: E/WindowManager(20138): at com.news.one$DownloadNews.onPreExecute(AdaDeranaTabActivity.java:365)
05-08 16:44:43.483: E/WindowManager(20138): at android.os.AsyncTask.execute(AsyncTask.java:391)
05-08 16:44:43.483: E/WindowManager(20138): at com.news.one.onCreate(AdaDeranaTabActivity.java:201)
05-08 16:44:43.483: E/WindowManager(20138): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-08 16:44:43.483: E/WindowManager(20138): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
05-08 16:44:43.483: E/WindowManager(20138): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-08 16:44:43.483: E/WindowManager(20138): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-08 16:44:43.483: E/WindowManager(20138): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-08 16:44:43.483: E/WindowManager(20138): at android.os.Handler.dispatchMessage(Handler.java:99)
05-08 16:44:43.483: E/WindowManager(20138): at android.os.Looper.loop(Looper.java:123)
05-08 16:44:43.483: E/WindowManager(20138): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-08 16:44:43.483: E/WindowManager(20138): at java.lang.reflect.Method.invokeNative(Native Method)
05-08 16:44:43.483: E/WindowManager(20138): at java.lang.reflect.Method.invoke(Method.java:521)
05-08 16:44:43.483: E/WindowManager(20138): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
05-08 16:44:43.483: E/WindowManager(20138): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
05-08 16:44:43.483: E/WindowManager(20138): at dalvik.system.NativeStart.main(Native Method)
05-08 16:44:54.065: E/AndroidRuntime(20138): FATAL EXCEPTION: main
05-08 16:44:54.065: E/AndroidRuntime(20138): java.lang.IllegalArgumentException: View not attached to window manager
05-08 16:44:54.065: E/AndroidRuntime(20138): at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:388)
05-08 16:44:54.065: E/AndroidRuntime(20138): at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:233)
05-08 16:44:54.065: E/AndroidRuntime(20138): at android.view.Window$LocalWindowManager.removeView(Window.java:432)
05-08 16:44:54.065: E/AndroidRuntime(20138): at android.app.Dialog.dismissDialog(Dialog.java:278)
05-08 16:44:54.065: E/AndroidRuntime(20138): at android.app.Dialog.access$000(Dialog.java:71)
05-08 16:44:54.065: E/AndroidRuntime(20138): at android.app.Dialog$1.run(Dialog.java:111)
05-08 16:44:54.065: E/AndroidRuntime(20138): at android.app.Dialog.dismiss(Dialog.java:268)
05-08 16:44:54.065: E/AndroidRuntime(20138): at com.news.one$DownloadNews.onPostExecute(AdaDeranaTabActivity.java:376)
05-08 16:44:54.065: E/AndroidRuntime(20138): at com.news.one$DownloadNews.onPostExecute(AdaDeranaTabActivity.java:1)
05-08 16:44:54.065: E/AndroidRuntime(20138): at android.os.AsyncTask.finish(AsyncTask.java:417)
05-08 16:44:54.065: E/AndroidRuntime(20138): at android.os.AsyncTask.access$300(AsyncTask.java:127)
05-08 16:44:54.065: E/AndroidRuntime(20138): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
05-08 16:44:54.065: E/AndroidRuntime(20138): at android.os.Handler.dispatchMessage(Handler.java:99)
05-08 16:44:54.065: E/AndroidRuntime(20138): at android.os.Looper.loop(Looper.java:123)
05-08 16:44:54.065: E/AndroidRuntime(20138): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-08 16:44:54.065: E/AndroidRuntime(20138): at java.lang.reflect.Method.invokeNative(Native Method)
05-08 16:44:54.065: E/AndroidRuntime(20138): at java.lang.reflect.Method.invoke(Method.java:521)
05-08 16:44:54.065: E/AndroidRuntime(20138): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
05-08 16:44:54.065: E/AndroidRuntime(20138): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
05-08 16:44:54.065: E/AndroidRuntime(20138): at dalvik.system.NativeStart.main(Native Method)
Is there a method to lock the rotation change till the application loads it self?
Or and other idea?
Thanks in advance.
When you switch orientations, Android will create a new View. You're probably getting crashes because your background thread is trying to change the state on the old one. (It may also be having trouble because your background thread isn't on the UI thread).
These are the solutions:
How to handle screen orientation change when progress dialog and background thread active?
Activity restart on rotation Android
I called the progressDialog.dismiss() in the onDestroy() method.
During a orientation change, the activity restarts. So before restart we have to destroy the current progressDialog. This does the trick. :D
You are getting WindowLeak Exception, this exception occur when any dialog/progressBar uses the reference of context and context reference lost due to orientation change.
So put below code for all activity tag in manifest file.
android:configChanges="orientation|keyboard"
example:
<activity
android:name=".InviteActivity" android:configChanges="orientation|keyboard"/>
and use below code in activity
#Override
public void onConfigurationChanged(Configuration newConfig)
{
setContentView(R.layout.YOUR_LAYOUT);
super.onConfigurationChanged(newConfig);
}
I had the same problem and solved it that way that I locked the orientation before start synchronisation and set it back after synchronize:
// before
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
// after synchronisation:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);

Categories

Resources