Animated toggle button Error inflating class android.widget.ToggleButton - android

im trying to make a toggle button with animation i use a toggle button and 4 XML to do so :
here is my main activity which toggle button is in it :
<ToggleButton
android:id="#+id/toggle"
android:layout_width="144dp"
android:layout_height="144dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#drawable/btn_toggle_bg"
android:checked="true"
android:onClick="OnPressToggle" />
and here is my btn_toggle_bg . xml which had background values :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+android:id/background" android:drawable="#android:color/transparent" />
<item android:id="#+android:id/toggle" android:drawable="#drawable/btn_toggle" />
</layer-list>
</LinearLayout>
and here is my btn_toggle . xml :
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="#drawable/btn_switch_on" />
<item android:state_checked="false" android:drawable="#drawable/btn_switch_off" />
</selector>
here is the new log cat
09-26 03:25:36.856: E/AndroidRuntime(19979): FATAL EXCEPTION: main
09-26 03:25:36.856: E/AndroidRuntime(19979): Process: com.soheil.prolight, PID: 19979
09-26 03:25:36.856: E/AndroidRuntime(19979): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.soheil.prolight/com.soheil.prolight.MainActivity}: android.view.InflateException: Binary XML file line #37: Error inflating class android.widget.ToggleButton
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.app.ActivityThread.access$800(ActivityThread.java:135)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.os.Handler.dispatchMessage(Handler.java:102)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.os.Looper.loop(Looper.java:136)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.app.ActivityThread.main(ActivityThread.java:5017)
09-26 03:25:36.856: E/AndroidRuntime(19979): at java.lang.reflect.Method.invokeNative(Native Method)
09-26 03:25:36.856: E/AndroidRuntime(19979): at java.lang.reflect.Method.invoke(Method.java:515)
09-26 03:25:36.856: E/AndroidRuntime(19979): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
09-26 03:25:36.856: E/AndroidRuntime(19979): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
09-26 03:25:36.856: E/AndroidRuntime(19979): at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
09-26 03:25:36.856: E/AndroidRuntime(19979): at dalvik.system.NativeStart.main(Native Method)
09-26 03:25:36.856: E/AndroidRuntime(19979): Caused by: android.view.InflateException: Binary XML file line #37: Error inflating class android.widget.ToggleButton
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.view.LayoutInflater.createView(LayoutInflater.java:620)
09-26 03:25:36.856: E/AndroidRuntime(19979): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
09-26 03:25:36.856: E/AndroidRuntime(19979): at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
09-26 03:25:36.856: E/AndroidRuntime(19979): at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:631)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.view.LayoutInflater.inflate(Native Method)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
09-26 03:25:36.856: E/AndroidRuntime(19979): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.app.Activity.setContentView(Activity.java:1929)
09-26 03:25:36.856: E/AndroidRuntime(19979): at com.soheil.prolight.MainActivity.onCreate(MainActivity.java:84)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.app.Activity.performCreate(Activity.java:5231)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
09-26 03:25:36.856: E/AndroidRuntime(19979): ... 12 more
09-26 03:25:36.856: E/AndroidRuntime(19979): Caused by: java.lang.reflect.InvocationTargetException
09-26 03:25:36.856: E/AndroidRuntime(19979): at java.lang.reflect.Constructor.constructNative(Native Method)
09-26 03:25:36.856: E/AndroidRuntime(19979): at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.view.LayoutInflater.createView(LayoutInflater.java:594)
09-26 03:25:36.856: E/AndroidRuntime(19979): ... 28 more
09-26 03:25:36.856: E/AndroidRuntime(19979): Caused by: android.content.res.Resources$NotFoundException: File res/drawable-hdpi/btn_toggle_bg.xml from drawable resource ID #0x7f020005
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.content.res.Resources.loadDrawable(Resources.java:2096)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.content.res.XResources$XTypedArray.getDrawable(XResources.java:965)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.view.View.<init>(View.java:3554)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.widget.TextView.<init>(TextView.java:623)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.widget.Button.<init>(Button.java:107)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.widget.CompoundButton.<init>(CompoundButton.java:68)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.widget.ToggleButton.<init>(ToggleButton.java:51)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.widget.ToggleButton.<init>(ToggleButton.java:64)
09-26 03:25:36.856: E/AndroidRuntime(19979): ... 31 more
09-26 03:25:36.856: E/AndroidRuntime(19979): Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #2: invalid drawable tag LinearLayout
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:933)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.graphics.drawable.Drawable.createFromXml(Drawable.java:877)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.content.res.Resources.loadDrawable(Resources.java:2092)
09-26 03:25:36.856: E/AndroidRuntime(19979): ... 39 more

Your drawable names cannot start with numbers:
Rename all of them to, for example:
<item android:drawable="#drawable/d1" android:duration="50"/>
<item android:drawable="#drawable/d2" android:duration="50"/>
...
Here are the naming rules you should follow:
needs to start with a letter and not a number
cannot contain upper case letters
cannot contain anything other than letters and numbers

Move you "btn_toggle_bg.xml" file from "res\drawable-hdpi" to "res\drawable" folder.
It will resolve the issue

Related

Having troubles with File.contains(file) and File.add(file)

I try to code an Android App.
The code below should add the parent of a file to my list, but only if the parent is not already in the list.
files[] is an array of Files in a directory
imageFolders is created like this:
private List <File> imageFolders;
private String [] extensions;
File [] files = folder.listFiles();
extensions = new String [] {".png",".jpg",".jpeg"};
//important part:
if(files[i].toString().contains(extensions[b]))
{
System.out.println("Checkpoint 1");
if(!imageFolders.contains((File)files[i].getParentFile()))
{
System.out.println("Checkpoint 2");
imageFolders.add((File)files[i].getParentFile());
}
}
And then the log gives me this and the app shuts down:
09-26 08:33:55.580: I/System.out(1753): /system/lib/hw/camera.goldfish.jpeg.so //gives me the file[i]
09-26 08:33:55.580: I/System.out(1753): Checkpoint 1
09-26 08:33:55.590: D/AndroidRuntime(1753): Shutting down VM
09-26 08:33:55.610: W/dalvikvm(1753): threadid=1: thread exiting with uncaught exception
(group=0xb1a87ba8)
09-26 08:33:55.650: E/AndroidRuntime(1753): FATAL EXCEPTION: main
09-26 08:33:55.650: E/AndroidRuntime(1753): Process: de.FriedSloth.fastphotomanager, PID: 1753
09-26 08:33:55.650: E/AndroidRuntime(1753): java.lang.RuntimeException: Unable to start activity
ComponentInfo{de.FriedSloth.fastphotomanager/de.FriedSloth.fastphotomanager.Side2}: java.lang.NullPointerException
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.app.ActivityThread.access$800(ActivityThread.java:135)
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.os.Handler.dispatchMessage(Handler.java:102)
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.os.Looper.loop(Looper.java:136)
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.app.ActivityThread.main(ActivityThread.java:5017)
09-26 08:33:55.650: E/AndroidRuntime(1753): at java.lang.reflect.Method.invokeNative(Native
Method)
09-26 08:33:55.650: E/AndroidRuntime(1753): at java.lang.reflect.Method.invoke(Method.java:515)
09-26 08:33:55.650: E/AndroidRuntime(1753): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
09-26 08:33:55.650: E/AndroidRuntime(1753): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
09-26 08:33:55.650: E/AndroidRuntime(1753): at dalvik.system.NativeStart.main(Native Method)
09-26 08:33:55.650: E/AndroidRuntime(1753): Caused by: java.lang.NullPointerException
09-26 08:33:55.650: E/AndroidRuntime(1753): at de.FriedSloth.fastphotomanager.Side2.hSearchImages(Side2.java:61)
09-26 08:33:55.650: E/AndroidRuntime(1753): at de.FriedSloth.fastphotomanager.Side2.hSearchImages(Side2.java:52)
09-26 08:33:55.650: E/AndroidRuntime(1753): at de.FriedSloth.fastphotomanager.Side2.hSearchImages(Side2.java:52)
09-26 08:33:55.650: E/AndroidRuntime(1753): at de.FriedSloth.fastphotomanager.Side2.onCreate(Side2.java:32)
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.app.Activity.performCreate(Activity.java:5231)
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
09-26 08:33:55.650: E/AndroidRuntime(1753): ... 11 more

Store/Save & Retrieve to/from SharedPreference Failure

I've been having so much problem with this Live Wallpaper.
I have read alot online about these, and I thought I understood and got them.
When I tried to apply them to this live wallpaper, everything has been going very rough.
I've spent all day and night :-(
Could you someone please help me out?
My goal is to store the new password from edittextpreference to the
Sharedpreference, and then retrieve this password to compared with the login
password to if they are matched.
For example,
I have 2 edittextpreferences:
1) is for create new password which will be saved to the SharedPreference
2) is for login password.
The users will be granted the access when the login password is matched with the
one in the SharedPreference.
Please help me out,
I would be appreciated for your help.
prefs.java Code:
#SuppressWarnings("deprecation")
#Override
protected void onDestroy() {
getPreferenceManager().getSharedPreferences()
.unregisterOnSharedPreferenceChangeListener(this);
super.onDestroy();
}
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) {
// TODO Auto-generated method stub
{
}
}
{
SharedPreferences mlogin_password = this.getSharedPreferences("data_storage", MODE_PRIVATE);
Editor login_password = mlogin_password.edit();
login_password.putString("login", "login_pw2");
login_password.commit();
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(Context);
String s = sp.getString("login", null);
Sorry for 10000000 of error codes :-(
Logcat:
at android.util.Log.println_native(Native Method)
at android.util.Log.v(Log.java:117)
at rare_war.weapons.prefs.<init>(prefs.java:60)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at rare_war.weapons.prefs.<init>(prefs.java:65)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at rare_war.weapons.prefs.<init>(prefs.java:65)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:167)
at rare_war.weapons.prefs.<init>(prefs.java:62)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:167)
at rare_war.weapons.prefs.<init>(prefs.java:62)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:167)
at rare_war.weapons.prefs.<init>(prefs.java:62)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:167)
at rare_war.weapons.prefs.<init>(prefs.java:62)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:167)
at rare_war.weapons.prefs.<init>(prefs.java:62)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:167)
at rare_war.weapons.prefs.<init>(prefs.java:64)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.content.ContextWrapper.getPackageName(ContextWrapper.java:135)
at android.preference.PreferenceManager.getDefaultSharedPreferencesName(PreferenceManager.java:374)
at android.preference.PreferenceManager.getDefaultSharedPreferences(PreferenceManager.java:369)
at rare_war.weapons.prefs.<init>(prefs.java:66)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:167)
at rare_war.weapons.prefs.<init>(prefs.java:63)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.content.ContextWrapper.getPackageName(ContextWrapper.java:135)
at android.preference.PreferenceManager.getDefaultSharedPreferencesName(PreferenceManager.java:374)
at android.preference.PreferenceManager.getDefaultSharedPreferences(PreferenceManager.java:369)
at rare_war.weapons.prefs.<init>(prefs.java:65)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.preference.PreferenceManager.getDefaultSharedPreferencesName(PreferenceManager.java:374)
at android.preference.PreferenceManager.getDefaultSharedPreferences(PreferenceManager.java:369)
at rare_war.weapons.prefs.<init>(prefs.java:68)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.preference.PreferenceManager.getDefaultSharedPreferencesName(PreferenceManager.java:374)
at android.preference.PreferenceManager.getDefaultSharedPreferences(PreferenceManager.java:369)
at rare_war.weapons.prefs.<init>(prefs.java:68)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.preference.PreferenceManager.getDefaultSharedPreferencesName(PreferenceManager.java:374)
at android.preference.PreferenceManager.getDefaultSharedPreferences(PreferenceManager.java:369)
at rare_war.weapons.prefs.<init>(prefs.java:68)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.preference.PreferenceManager.getDefaultSharedPreferencesName(PreferenceManager.java:374)
at android.preference.PreferenceManager.getDefaultSharedPreferences(PreferenceManager.java:369)
at rare_war.weapons.prefs.<init>(prefs.java:75)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.preference.PreferenceManager.getDefaultSharedPreferencesName(PreferenceManager.java:374)
at android.preference.PreferenceManager.getDefaultSharedPreferences(PreferenceManager.java:369)
at rare_war.weapons.prefs.<init>(prefs.java:74)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:167)
at rare_war.weapons.prefs.<init>(prefs.java:68)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:167)
at rare_war.weapons.prefs.<init>(prefs.java:68)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:167)
at rare_war.weapons.prefs.<init>(prefs.java:68)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.preference.PreferenceManager.getDefaultSharedPreferencesName(PreferenceManager.java:374)
at android.preference.PreferenceManager.getDefaultSharedPreferences(PreferenceManager.java:369)
at rare_war.weapons.prefs.<init>(prefs.java:75)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:167)
at rare_war.weapons.prefs.<init>(prefs.java:68)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
My goal is to store the new password from edittextpreference to the
Sharedpreference...
Not a good idea. You shouldn't store passwords on SharedPreferences
I would suggest using a different approach like storing the encrypted password on a server and then check what the user entered against it.
Please, also make sure you read the Android guide on SharedPreferences
Hi you are saving password on sharedPreference named 'data_storage' and retrieving from default sharedPreference thats why you are not getting saved password.Try to save and retrieve preference value from same sharedPreference.
Why don't you use getSharedPreferences for the key "data_storage" and not for getDefaultSharedPreferences, in other words, Context? I'm not really sure about it, but you should try.
The mechanism works as follows: you save the key under a string name "date_storage" then you retrieve they key. In both cases you need to get the SharedPreferences with the line:
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(Context);
After that use the "sp.get()" methods to get the required value for the saved string key ("data_storage").

Exception "inflating class fragment"

Getting run time exception as "inflating class fragment" when I tried to add Google map in my android application. I go through all the previous comments similar to which I have posted. But I couldn't solve it.
Log file is attached here
08-07 05:30:41.587: E/AndroidRuntime(2574): FATAL EXCEPTION: main
08-07 05:30:41.587: E/AndroidRuntime(2574): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.newapp/com.example.newapp.NewApp}: android.view.InflateException: Binary XML file line #17: Error inflating class fragment
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.app.ActivityThread.access$600(ActivityThread.java:141)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.os.Handler.dispatchMessage(Handler.java:99)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.os.Looper.loop(Looper.java:137)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.app.ActivityThread.main(ActivityThread.java:5103)
08-07 05:30:41.587: E/AndroidRuntime(2574): at java.lang.reflect.Method.invokeNative(Native Method)
08-07 05:30:41.587: E/AndroidRuntime(2574): at java.lang.reflect.Method.invoke(Method.java:525)
08-07 05:30:41.587: E/AndroidRuntime(2574): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
08-07 05:30:41.587: E/AndroidRuntime(2574): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-07 05:30:41.587: E/AndroidRuntime(2574): at dalvik.system.NativeStart.main(Native Method)
08-07 05:30:41.587: E/AndroidRuntime(2574): Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class fragment
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
08-07 05:30:41.587: E/AndroidRuntime(2574): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.app.Activity.setContentView(Activity.java:1895)
08-07 05:30:41.587: E/AndroidRuntime(2574): at com.example.newapp.NewApp.onCreate(NewApp.java:12)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.app.Activity.performCreate(Activity.java:5133)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
08-07 05:30:41.587: E/AndroidRuntime(2574): ... 11 more
08-07 05:30:41.587: E/AndroidRuntime(2574): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.SupportMapFragment: make sure class name exists, is public, and has an empty constructor that is public
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.support.v4.app.Fragment.instantiate(Fragment.java:409)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.support.v4.app.Fragment.instantiate(Fragment.java:377)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:277)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
08-07 05:30:41.587: E/AndroidRuntime(2574): ... 21 more
08-07 05:30:41.587: E/AndroidRuntime(2574): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.SupportMapFragment" on path: DexPathList[[zip file "/data/app/com.example.newapp-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.newapp-1, /vendor/lib, /system/lib]]
08-07 05:30:41.587: E/AndroidRuntime(2574): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
08-07 05:30:41.587: E/AndroidRuntime(2574): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
08-07 05:30:41.587: E/AndroidRuntime(2574): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.support.v4.app.Fragment.instantiate(Fragment.java:399)
08-07 05:30:41.587: E/AndroidRuntime(2574): ... 24 more
08-07 05:30:47.677: I/Process(2574): Sending signal. PID: 2574 SIG: 9
08-07 05:30:53.767: D/AndroidRuntime(2650): Shutting down VM
08-07 05:30:53.767: W/dalvikvm(2650): threadid=1: thread exiting with uncaught exception (group=0x414c4700)
08-07 05:30:53.857: E/AndroidRuntime(2650): FATAL EXCEPTION: main
08-07 05:30:53.857: E/AndroidRuntime(2650): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.newapp/com.example.newapp.NewApp}: android.view.InflateException: Binary XML file line #17: Error inflating class fragment
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.app.ActivityThread.access$600(ActivityThread.java:141)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.os.Handler.dispatchMessage(Handler.java:99)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.os.Looper.loop(Looper.java:137)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.app.ActivityThread.main(ActivityThread.java:5103)
08-07 05:30:53.857: E/AndroidRuntime(2650): at java.lang.reflect.Method.invokeNative(Native Method)
08-07 05:30:53.857: E/AndroidRuntime(2650): at java.lang.reflect.Method.invoke(Method.java:525)
08-07 05:30:53.857: E/AndroidRuntime(2650): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
08-07 05:30:53.857: E/AndroidRuntime(2650): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-07 05:30:53.857: E/AndroidRuntime(2650): at dalvik.system.NativeStart.main(Native Method)
08-07 05:30:53.857: E/AndroidRuntime(2650): Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class fragment
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
08-07 05:30:53.857: E/AndroidRuntime(2650): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.app.Activity.setContentView(Activity.java:1895)
08-07 05:30:53.857: E/AndroidRuntime(2650): at com.example.newapp.NewApp.onCreate(NewApp.java:12)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.app.Activity.performCreate(Activity.java:5133)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
08-07 05:30:53.857: E/AndroidRuntime(2650): ... 11 more
08-07 05:30:53.857: E/AndroidRuntime(2650): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.SupportMapFragment: make sure class name exists, is public, and has an empty constructor that is public
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.support.v4.app.Fragment.instantiate(Fragment.java:409)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.support.v4.app.Fragment.instantiate(Fragment.java:377)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:277)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
08-07 05:30:53.857: E/AndroidRuntime(2650): ... 21 more
08-07 05:30:53.857: E/AndroidRuntime(2650): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.SupportMapFragment" on path: DexPathList[[zip file "/data/app/com.example.newapp-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.newapp-1, /vendor/lib, /system/lib]]
08-07 05:30:53.857: E/AndroidRuntime(2650): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
08-07 05:30:53.857: E/AndroidRuntime(2650): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
08-07 05:30:53.857: E/AndroidRuntime(2650): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.support.v4.app.Fragment.instantiate(Fragment.java:399)
08-07 05:30:53.857: E/AndroidRuntime(2650): ... 24 more
08-07 05:30:56.837: I/Process(2650): Sending signal. PID: 2650 SIG: 9
manifest.xml file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.newapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="********************************" />
<permission
android:name="com.venky.maps.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.newapp.maps.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<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:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.newapp.NewApp"
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 the java file NewApp.java
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
public class NewApp extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_app);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.new_app, menu);
return true;
}
}
activity_new_app.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".NewApp" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Please help me to solve this problem.
One visible mistake
https://developers.google.com/maps/documentation/android/start
Your meta tag must be a child of application tag in manifest
<meta-data // should be inside application tag.
android:name="com.google.android.maps.v2.API_KEY"
android:value="********************************" />
Change this
<permission
android:name="com.venky.maps.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
to
<permission
android:name="com.example.newapp.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />

viewflipper not works on 4.0

i have developed an application that works fine on android 2.1 version but when i launch it on android 4.0 version it does not run and throws the stack trace like this:
09-26 19:45:10.961: E/AndroidRuntime(785): FATAL EXCEPTION: main
09-26 19:45:10.961: E/AndroidRuntime(785): java.lang.OutOfMemoryError
09-26 19:45:10.961: E/AndroidRuntime(785): at android.graphics.Bitmap.nativeCreate(Native Method)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:524)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:499)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:773)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.content.res.Resources.loadDrawable(Resources.java:1937)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.content.res.Resources.getDrawable(Resources.java:664)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.widget.ImageView.resolveUri(ImageView.java:542)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.widget.ImageView.setImageResource(ImageView.java:315)
09-26 19:45:10.961: E/AndroidRuntime(785): at com.deedatech.AnimalsNameForKids.AnimalsNameForKidsActivity.onCreate(AnimalsNameForKidsActivity.java:85)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.app.Activity.performCreate(Activity.java:4465)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.app.ActivityThread.access$600(ActivityThread.java:122)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.os.Handler.dispatchMessage(Handler.java:99)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.os.Looper.loop(Looper.java:137)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.app.ActivityThread.main(ActivityThread.java:4340)
09-26 19:45:10.961: E/AndroidRuntime(785): at java.lang.reflect.Method.invokeNative(Native Method)
09-26 19:45:10.961: E/AndroidRuntime(785): at java.lang.reflect.Method.invoke(Method.java:511)
09-26 19:45:10.961: E/AndroidRuntime(785): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-26 19:45:10.961: E/AndroidRuntime(785): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-26 19:45:10.961: E/AndroidRuntime(785): at dalvik.system.NativeStart.main(Native Method)
i just dont understand why this happens because the same program runs perfect on android 2.1 version but throws outOfMemoryError on 4.0 version. please help if u have some idea..
If you are decoding a Bitmap from the UI thread, there is a risk to get the outOfMemoryError. Try to change your decode stream to an asynTask.
Contrary to what Anis said, decoding yor Bitmap on a different thread will not help you avoid an Out Of Memory (OOM) Error, you're still loading exactly the same amount of data into your application.
You need to either reduce the size of the image you are loading or downsample it so you aren't loading in all of the data, for more information on this take a look at Loading Large Bitmaps Efficiently.

Class Loader Exception while working with Maps in android

I got the following Class not found exception while working with map based application
09-26 15:33:19.810: ERROR/AndroidRuntime(27866):
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.zyksatwo/com.zyksatwo.MapRouteActivity}:
java.lang.ClassNotFoundException: com.zyksatwo.MapRouteActivity in
loader dalvik.system.PathClassLoader[/data/app/com.zyksatwo-1.apk]
09-26 15:33:19.810: ERROR/AndroidRuntime(27866): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1618)
09-26 15:33:19.810: ERROR/AndroidRuntime(27866): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1716)
09-26 15:33:19.810: ERROR/AndroidRuntime(27866): at
android.app.ActivityThread.access$1500(ActivityThread.java:124) 09-26
15:33:19.810: ERROR/AndroidRuntime(27866): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:968)
09-26 15:33:19.810: ERROR/AndroidRuntime(27866): at
android.os.Handler.dispatchMessage(Handler.java:99) 09-26
15:33:19.810: ERROR/AndroidRuntime(27866): at
android.os.Looper.loop(Looper.java:130) 09-26 15:33:19.810:
ERROR/AndroidRuntime(27866): at
android.app.ActivityThread.main(ActivityThread.java:3806) 09-26
15:33:19.810: ERROR/AndroidRuntime(27866): at
java.lang.reflect.Method.invokeNative(Native Method) 09-26
15:33:19.810: ERROR/AndroidRuntime(27866): at
java.lang.reflect.Method.invoke(Method.java:507) 09-26 15:33:19.810:
ERROR/AndroidRuntime(27866): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-26 15:33:19.810: ERROR/AndroidRuntime(27866): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 09-26
15:33:19.810: ERROR/AndroidRuntime(27866): at
dalvik.system.NativeStart.main(Native Method) 09-26 15:33:19.810:
ERROR/AndroidRuntime(27866): Caused by:
java.lang.ClassNotFoundException: com.zyksatwo.MapRouteActivity in loader dalvik.system.PathClassLoader[/data/app/com.zyksatwo-1.apk
Please help me to figure out the mistake I did here
did you add <uses-library android:name="com.google.android.maps" /> in your menifest file?
if not then plz add this Tag inside your Application Tag in your Menifest.xml file

Categories

Resources