Unable to instantiate fragment com.google.android.gms.MapFragment - android

I know this question is asked so many times. but not working in my case tried so many solution. so help please
my mainActivity extends Activity within onCreate map generates this way.
private void initilizeMap() {
if (googleMap == null) {
googleMap = ((MapFragment) getFragmentManager()
.findFragmentById(R.id.map)).getMap();
// check if map is created successfully or not
if (googleMap == null) {
Toast.makeText(getApplicationContext(),
"Sorry! unable to create maps", Toast.LENGTH_SHORT)
.show();
}
}
}
and xml view is
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
support:
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="21" />
error em getting:
03-01 13:29:20.089: E/AndroidRuntime(26406): FATAL EXCEPTION: main
03-01 13:29:20.089: E/AndroidRuntime(26406): Process: com.commteldigital.cinecorn.activity, PID: 26406
03-01 13:29:20.089: E/AndroidRuntime(26406): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.commteldigital.cinecorn.activity/com.commteldigital.cmovies.activity.LocationActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
03-01 13:29:20.089: E/AndroidRuntime(26406): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2338)
03-01 13:29:20.089: E/AndroidRuntime(26406): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
03-01 13:29:20.089: E/AndroidRuntime(26406): at android.app.ActivityThread.access$800(ActivityThread.java:151)
03-01 13:29:20.089: E/AndroidRuntime(26406): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
03-01 13:29:20.089: E/AndroidRuntime(26406): at android.os.Handler.dispatchMessage(Handler.java:110)
03-01 13:29:20.089: E/AndroidRuntime(26406): at android.os.Looper.loop(Looper.java:193)
03-01 13:29:20.089: E/AndroidRuntime(26406): at android.app.ActivityThread.main(ActivityThread.java:5299)
03-01 13:29:20.089: E/AndroidRuntime(26406): at java.lang.reflect.Method.invokeNative(Native Method)
03-01 13:29:20.089: E/AndroidRuntime(26406): at java.lang.reflect.Method.invoke(Method.java:515)
03-01 13:29:20.089: E/AndroidRuntime(26406): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:825)
03-01 13:29:20.089: E/AndroidRuntime(26406): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
03-01 13:29:20.089: E/AndroidRuntime(26406): at dalvik.system.NativeStart.main(Native Method)
03-01 13:29:20.089: E/AndroidRuntime(26406): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
03-01 13:29:20.089: E/AndroidRuntime(26406): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
03-01 13:29:20.089: E/AndroidRuntime(26406): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
03-01 13:29:20.089: E/AndroidRuntime(26406): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
03-01 13:29:20.089: E/AndroidRuntime(26406): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
03-01 13:29:20.089: E/AndroidRuntime(26406): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
03-01 13:29:20.089: E/AndroidRuntime(26406): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:305)
03-01 13:29:20.089: E/AndroidRuntime(26406): at android.app.Activity.setContentView(Activity.java:1944)
03-01 13:29:20.089: E/AndroidRuntime(26406): at com.commteldigital.cmovies.activity.LocationActivity.onCreate(LocationActivity.java:27)
03-01 13:29:20.089: E/AndroidRuntime(26406): at android.app.Activity.performCreate(Activity.java:5264)
03-01 13:29:20.089: E/AndroidRuntime(26406): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
03-01 13:29:20.089: E/AndroidRuntime(26406): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)
03-01 13:29:20.089: E/AndroidRuntime(26406): ... 11 more
03-01 13:29:20.089: E/AndroidRuntime(26406): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.MapFragment: make sure class name exists, is public, and has an empty constructor that is public
03-01 13:29:20.089: E/AndroidRuntime(26406): at android.app.Fragment.instantiate(Fragment.java:597)
03-01 13:29:20.089: E/AndroidRuntime(26406): at android.app.Fragment.instantiate(Fragment.java:561)
03-01 13:29:20.089: E/AndroidRuntime(26406): at android.app.Activity.onCreateView(Activity.java:4811)
03-01 13:29:20.089: E/AndroidRuntime(26406): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
03-01 13:29:20.089: E/AndroidRuntime(26406): ... 21 more
03-01 13:29:20.089: E/AndroidRuntime(26406): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.MapFragment" on path: DexPathList[[zip file "/data/app/com.commteldigital.cinecorn.activity-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.commteldigital.cinecorn.activity-2, /vendor/lib, /system/lib]]
03-01 13:29:20.089: E/AndroidRuntime(26406): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
03-01 13:29:20.089: E/AndroidRuntime(26406): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
03-01 13:29:20.089: E/AndroidRuntime(26406): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
03-01 13:29:20.089: E/AndroidRuntime(26406): at android.app.Fragment.instantiate(Fragment.java:583)
03-01 13:29:20.089: E/AndroidRuntime(26406): ... 24 more
well. have imported google play lib from extras folder. why the class is unavailable. thanks in advance

It seems you are using a wrong name. Use this code:
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android" >
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
</merge>
In addition, getMap() is now deprecated, you are using an old API.

Change
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
to
<fragment
android:id="#+id/map"
class="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />

add those lines in your manifest files within application tag if you didn't add them
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />

Related

E/AndroidRuntime: FATAL EXCEPTION: main PID: 5112 [duplicate]

This question already has answers here:
What is a NullPointerException, and how do I fix it?
(12 answers)
Closed 5 years ago.
Hy
I am new to Android / Java is I am facing a BMO problem
I code it but it does not work
an idea ??
thank you
<string name="onCreate_Go">onCreate Go</string>
<TextView
android:id="#+id/scrollTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp" />
import android.widget.TextView;
private final TextView txt = (TextView) this.findViewById(R.id.scrollTxt);
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txt.setText(R.string.onCreate_Go);
}
5112-5112/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.gmail.test1, PID: 5112
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.gmail.test1/com.gmail.test1.MainActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.support.v7.app.AppCompatDelegateImplBase.(AppCompatDelegateImplBase.java:117)
at android.support.v7.app.AppCompatDelegateImplV9.(AppCompatDelegateImplV9.java:149)
at android.support.v7.app.AppCompatDelegateImplV11.(AppCompatDelegateImplV11.java:29)
at android.support.v7.app.AppCompatDelegateImplV14.(AppCompatDelegateImplV14.java:54)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:202)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:183)
at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:519)
at android.support.v7.app.AppCompatActivity.findViewById(AppCompatActivity.java:190)
at com.gmail.test1.MainActivity.(MainActivity.java:13)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1208)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
at android.app.ActivityThread.access$800(ActivityThread.java:135) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5017) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
at dalvik.system.NativeStart.main(Native Method) 
02-16 16:41:21.634 5112-5112/? I/Process: Sending signal. PID: 5112 SIG: 9
Please add your Activity in your AndroidManifest.xml. like below code:
<activity android:name=".activities.MainActivity"/>
Also put the findViewById() after setContentView() so it can actually return something other than null.
You can't initialize the textView before call "setContentView" method. I recommend you create a "init" method where initialize all layout's elements and call it after "setContentView"

Android Google maps application: getting error in android manifest.xml which is an lib file

I am developing a simple Android app which uses the Google Maps API,
I had registered with Google for the API key and added it to my app but I am getting an error:
FATAL EXCEPTION: main
Process: com.s56.maps, PID: 866
12-17 09:28:56.070: E/AndroidRuntime(866): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.s56.maps/com.s56.maps.MainActivity}: android.view.InflateException: Binary XML file line #15: Error inflating class fragment
12-17 09:28:56.070: E/AndroidRuntime(866): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.app.ActivityThread.access$700(ActivityThread.java:135)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.os.Handler.dispatchMessage(Handler.java:102)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.os.Looper.loop(Looper.java:137)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.app.ActivityThread.main(ActivityThread.java:4998)
12-17 09:28:56.070: E/AndroidRuntime(866): at java.lang.reflect.Method.invokeNative(Native Method)
12-17 09:28:56.070: E/AndroidRuntime(866): at java.lang.reflect.Method.invoke(Method.java:515)
12-17 09:28:56.070: E/AndroidRuntime(866): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
12-17 09:28:56.070: E/AndroidRuntime(866): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
12-17 09:28:56.070: E/AndroidRuntime(866): at dalvik.system.NativeStart.main(Native Method)
12-17 09:28:56.070: E/AndroidRuntime(866): Caused by: android.view.InflateException: Binary XML file line #15: Error inflating class fragment
12-17 09:28:56.070: E/AndroidRuntime(866): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
12-17 09:28:56.070: E/AndroidRuntime(866): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.app.Activity.setContentView(Activity.java:1928)
12-17 09:28:56.070: E/AndroidRuntime(866): at com.s56.maps.MainActivity.onCreate(MainActivity.java:19)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.app.Activity.performCreate(Activity.java:5243)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
12-17 09:28:56.070: E/AndroidRuntime(866): ... 11 more
***12-17 09:28:56.070: E/AndroidRuntime(866): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4030500 but found 0. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />***
12-17 09:28:56.070: E/AndroidRuntime(866): at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
12-17 09:28:56.070: E/AndroidRuntime(866): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
12-17 09:28:56.070: E/AndroidRuntime(866): at com.google.android.gms.maps.internal.q.v(Unknown Source)
12-17 09:28:56.070: E/AndroidRuntime(866): at com.google.android.gms.maps.internal.q.u(Unknown Source)
12-17 09:28:56.070: E/AndroidRuntime(866): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
12-17 09:28:56.070: E/AndroidRuntime(866): at com.google.android.gms.maps.MapFragment$b.cE(Unknown Source)
12-17 09:28:56.070: E/AndroidRuntime(866): at com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
12-17 09:28:56.070: E/AndroidRuntime(866): at com.google.android.gms.dynamic.a.a(Unknown Source)
12-17 09:28:56.070: E/AndroidRuntime(866): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
12-17 09:28:56.070: E/AndroidRuntime(866): at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.app.Activity.onCreateView(Activity.java:4784)
12-17 09:28:56.070: E/AndroidRuntime(866): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
12-17 09:28:56.070: E/AndroidRuntime(866): ... 21 more
And my XML file is
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.s56.maps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
/>
<permission
android:name="com.s56.maps.permission.MAPS_RECEIVE"
android:protectionLevel="signature"></permission>
<uses-permission
android:name="com.s56.maps.permission.MAPS_RECEIVE"/>
<uses-permission
android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission
android:name="android.permission.INTERNET"/>
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.s56.maps.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="A***MY_API_KEY***M"/>
</application>
</manifest>
and my activity_main.xml has
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment"/>
And my main class i.e activity class has,
public class MainActivity extends Activity
{
private GoogleMap mMap;
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mMap=
((MapFragment)getFragmentManager().findFragmentById(R.id.map)).getMap();
mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
final LatLng CIU = new LatLng(17.426944259701596, 78.5340459823017);
Marker c = mMap.addMarker(new MarkerOptions()
.position(CIU).title("s56 labs"));
}
#Override
public boolean onCreateOptionsMenu(Menu menu)
{
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
} }
I had added Google Play services as library to Eclipse work space.
Kindly help me with this, and I am new to Android.
You must add this to your AndroidManifest.xml:
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />

android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3147)

Any idea why would this crash appear? The trace has only native code so very hard to track it down. Happens on Samsung Galaxy s3 platform 4.1.2 when I run animation inside a Fragment and when animation ends I call notifyDataSetChanged for the FragmentStatePagerAdapter. The issue is not 100% reproducible.
Thanks.
Trace:
03-01 11:50:11.836: E/AndroidRuntime(21136): FATAL EXCEPTION: main
03-01 11:50:11.836: E/AndroidRuntime(21136): java.lang.NullPointerException
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3147)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12646)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12754)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3151)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12646)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12754)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3151)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12646)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12754)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3151)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12646)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12754)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3151)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12646)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12754)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3151)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12646)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12754)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3151)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12646)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12754)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3151)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12646)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12754)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3151)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12646)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12754)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3151)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12646)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12754)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3151)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12646)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12754)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1144)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewRootImpl.draw(ViewRootImpl.java:2273)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2145)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1956)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1112)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4472)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.Choreographer.doCallbacks(Choreographer.java:555)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.Choreographer.doFrame(Choreographer.java:525)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.os.Handler.handleCallback(Handler.java:615)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.os.Handler.dispatchMessage(Handler.java:92)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.os.Looper.loop(Looper.java:137)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.app.ActivityThread.main(ActivityThread.java:4898)
03-01 11:50:11.836: E/AndroidRuntime(21136): at java.lang.reflect.Method.invokeNative(Native Method)
03-01 11:50:11.836: E/AndroidRuntime(21136): at java.lang.reflect.Method.invoke(Method.java:511)
03-01 11:50:11.836: E/AndroidRuntime(21136): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
03-01 11:50:11.836: E/AndroidRuntime(21136): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
03-01 11:50:11.836: E/AndroidRuntime(21136): at dalvik.system.NativeStart.main(Native Method)
Fix was simple but no idea why works.
In the AnimationListener's onAnimationEnd callback I had a callback which triggered notifyDataSetChanged. I add that callback into Runnable and ran the Runnable with getView().post
#Override
public void onAnimationEnd(Animation animation) {
getView().post(new Runnable() {
#Override
public void run() {
// notifyDataSetChanged here
}
});
}
Good answer but as in all things Android these answers become dated pretty quickly.
I would use runOnUiThread now. I was running in a baseclass with the animator as a private class. For a deeper dive on runOnUiThread see
Android basics: running code in the UI thread
#Override
public void onAnimationEnd(Animator animation) {
//
MyBaseActivity.this.runOnUiThread(new Runnable() {
public void run() {
Log.d("UI thread", "I am the UI thread");
}
});
}

Fatal error on LoadedApk,makeApplication

I'm developing an application here and it's been working good so far, but now I've put the HoloEverywhere lib to update the layout to the ICS look, and I started getting a random error on startup.
I searched for this error and found out that it could be related to the Eclipse ADT plugin incorrectly building the apk or something like that, but the error doesn't occurs only when I starde from Eclipse, it occurs frequently almost every time I reopen the application after not using it for a while.
And there's really nothing wrong with my application, because it worked well before HoloEverywhere, and when I get this crash (The app crashed everytime I get the error), I just have to reopen it again and it'll work.
This is what I'm getting:
03-01 12:37:03.913: E/AndroidRuntime(29273): FATAL EXCEPTION: main
03-01 12:37:03.913: E/AndroidRuntime(29273): java.lang.RuntimeException: Unable to instantiate application br.uff.uffmobile.context.UffMobileApplication: java.lang.NullPointerException
03-01 12:37:03.913: E/AndroidRuntime(29273): at android.app.LoadedApk.makeApplication(LoadedApk.java:501)
03-01 12:37:03.913: E/AndroidRuntime(29273): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4159)
03-01 12:37:03.913: E/AndroidRuntime(29273): at android.app.ActivityThread.access$1400(ActivityThread.java:134)
03-01 12:37:03.913: E/AndroidRuntime(29273): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1277)
03-01 12:37:03.913: E/AndroidRuntime(29273): at android.os.Handler.dispatchMessage(Handler.java:99)
03-01 12:37:03.913: E/AndroidRuntime(29273): at android.os.Looper.loop(Looper.java:137)
03-01 12:37:03.913: E/AndroidRuntime(29273): at android.app.ActivityThread.main(ActivityThread.java:4856)
03-01 12:37:03.913: E/AndroidRuntime(29273): at java.lang.reflect.Method.invokeNative(Native Method)
03-01 12:37:03.913: E/AndroidRuntime(29273): at java.lang.reflect.Method.invoke(Method.java:511)
03-01 12:37:03.913: E/AndroidRuntime(29273): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
03-01 12:37:03.913: E/AndroidRuntime(29273): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
03-01 12:37:03.913: E/AndroidRuntime(29273): at dalvik.system.NativeStart.main(Native Method)
03-01 12:37:03.913: E/AndroidRuntime(29273): Caused by: java.lang.NullPointerException
03-01 12:37:03.913: E/AndroidRuntime(29273): at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:377)
03-01 12:37:03.913: E/AndroidRuntime(29273): at android.app.LoadedApk.getClassLoader(LoadedApk.java:320)
03-01 12:37:03.913: E/AndroidRuntime(29273): at android.app.LoadedApk.makeApplication(LoadedApk.java:493)
03-01 12:37:03.913: E/AndroidRuntime(29273): ... 11 more
I have also put try/catches everywhere I could to see if I could avoid this nullpointer, but it seems it's either a HoloEverywhere problem or an internal Android bug. I'm testing it with a 4.1.2 android Galaxy S Advance.

Permission denied exception is coming while retrieving the icon in android

I have created an application which will allow the user to set a new theme to their phone. I am trying to change the icons of the default applications(mms,camera,calculator etc) after applying the theme. I am trying to do this by storing the theme icon images into the local memory.
In Iconcache.java I have modified the code. I am checking there which theme is currently used and if it is not default theme then I am checking the local memory to get which theme is assigned and getting icon location and assigning that particular icon.
I am getting icon location correctly there, but not able open it. It is showing permission denied exception. See the logs below.
03-01 12:14:30.324: INFO/System.out(197): CN: ComponentInfo{com.android.settings/com.android.settings.Settings}
03-01 12:14:30.324: INFO/System.out(197): *********In Try*******
03-01 12:14:30.324: INFO/System.out(197): getfullresiconnnnnnnnnnnnnnnn
03-01 12:14:30.334: DEBUG/IconCache(197): getFullResIcon : info ResolveInfo{410b09f8 com.android.settings.Settings p=0 o=0 m=0x0}
03-01 12:14:30.334: DEBUG/IconCache(197): getFullResIcon :try settingsContext android.app.ContextImpl#4108b660
03-01 12:14:30.354: DEBUG/IconCache(197): getFullResIcon : currentThemePackage Default Theme
03-01 12:14:30.354: INFO/System.out(197): current theme package :Default Theme
03-01 12:14:30.374: DEBUG/IconCache(197): if currenttheme!=default
03-01 12:14:30.374: INFO/System.out(197): Icon file :/data/data/com.android.settings/app_themes/settings.png
03-01 12:14:30.424: DEBUG/IconCache(197): getFullResIcon : iconFile /data/data/com.android.settings/app_themes/settings.png
03-01 12:14:30.424: DEBUG/IconCache(197): if iconFile!=null
03-01 12:14:30.434: DEBUG/IconCache(197): if iconFile!=null : ico val /data/data/com.android.settings/app_themes/settings.png
03-01 12:14:30.483: WARN/System.err(197): java.io.FileNotFoundException: /data/data/com.android.settings/app_themes/settings.png: open failed: EACCES (Permission denied)
03-01 12:14:30.493: WARN/System.err(197): at libcore.io.IoBridge.open(IoBridge.java:406)
03-01 12:14:30.533: DEBUG/dalvikvm(76): GC_CONCURRENT freed 1570K, 24% free 12477K/16263K, paused 5ms+81ms
03-01 12:14:30.583: WARN/ActivityManager(76): Activity idle timeout for ActivityRecord{410e4510 com.android.launcher/com.android.launcher2.Launcher}
03-01 12:14:30.703: WARN/System.err(197): at java.io.FileInputStream.<init>(FileInputStream.java:78)
03-01 12:14:30.703: WARN/System.err(197): at com.android.launcher2.IconCache.getFullResIcon(IconCache.java:142)
03-01 12:14:30.723: WARN/System.err(197): at com.android.launcher2.IconCache.cacheLocked(IconCache.java:282)
03-01 12:14:30.723: WARN/System.err(197): at com.android.launcher2.IconCache.getIcon(IconCache.java:250)
03-01 12:14:30.746: WARN/System.err(197): at com.android.launcher2.LauncherModel.getShortcutInfo(LauncherModel.java:1641)
03-01 12:14:30.746: WARN/System.err(197): at com.android.launcher2.LauncherModel$LoaderTask.loadWorkspace(LauncherModel.java:1041)
03-01 12:14:30.755: WARN/System.err(197): at com.android.launcher2.LauncherModel$LoaderTask.loadAndBindWorkspace(LauncherModel.java:756)
03-01 12:14:30.763: WARN/System.err(197): at com.android.launcher2.LauncherModel$LoaderTask.run(LauncherModel.java:821)
03-01 12:14:30.763: WARN/System.err(197): at android.os.Handler.handleCallback(Handler.java:605)
03-01 12:14:30.763: WARN/System.err(197): at android.os.Handler.dispatchMessage(Handler.java:92)
03-01 12:14:30.773: DEBUG/StrictMode(271): StrictMode policy violation; ~duration=249 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=2711 violation=2
03-01 12:14:30.773: DEBUG/StrictMode(271): at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1074)
03-01 12:14:30.773: DEBUG/StrictMode(271): at android.app.SharedPreferencesImpl.awaitLoadedLocked(SharedPreferencesImpl.java:184)
03-01 12:14:30.773: DEBUG/StrictMode(271): at android.app.SharedPreferencesImpl.getBoolean(SharedPreferencesImpl.java:241)
03-01 12:14:30.773: DEBUG/StrictMode(271): at com.android.calendar.Utils.getHideDeclinedEvents(Utils.java:464)
03-01 12:14:30.773: DEBUG/StrictMode(271): at com.android.calendar.widget.CalendarAppWidgetService$CalendarFactory.initLoader(CalendarAppWidgetService.java:356)
03-01 12:14:30.773: DEBUG/StrictMode(271): at com.android.calendar.widget.CalendarAppWidgetService$CalendarFactory.onReceive(CalendarAppWidgetService.java:525)
03-01 12:14:30.773: DEBUG/StrictMode(271): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2118)
03-01 12:14:30.773: DEBUG/StrictMode(271): at android.app.ActivityThread.access$1500(ActivityThread.java:122)
03-01 12:14:30.773: DEBUG/StrictMode(271): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
03-01 12:14:30.773: DEBUG/StrictMode(271): at android.os.Handler.dispatchMessage(Handler.java:99)
03-01 12:14:30.773: DEBUG/StrictMode(271): at android.os.Looper.loop(Looper.java:137)
03-01 12:14:30.773: DEBUG/StrictMode(271): at android.app.ActivityThread.main(ActivityThread.java:4340)
03-01 12:14:30.773: DEBUG/StrictMode(271): at java.lang.reflect.Method.invokeNative(Native Method)
03-01 12:14:30.773: DEBUG/StrictMode(271): at java.lang.reflect.Method.invoke(Method.java:511)
03-01 12:14:30.773: DEBUG/StrictMode(271): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-01 12:14:30.773: DEBUG/StrictMode(271): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-01 12:14:30.773: DEBUG/StrictMode(271): at dalvik.system.NativeStart.main(Native Method)
03-01 12:14:30.783: WARN/System.err(197): at android.os.Looper.loop(Looper.java:137)
03-01 12:14:30.803: WARN/System.err(197): at android.os.HandlerThread.run(HandlerThread.java:60)
03-01 12:14:30.863: WARN/System.err(197): Caused by: libcore.io.ErrnoException: open failed: EACCES (Permission denied)
03-01 12:14:30.863: WARN/System.err(197): at libcore.io.Posix.open(Native Method)
03-01 12:14:30.902: WARN/System.err(197): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:98)
03-01 12:14:30.902: WARN/System.err(197): at libcore.io.IoBridge.open(IoBridge.java:390)
03-01 12:14:30.913: DEBUG/dalvikvm(152): GC_CONCURRENT freed 4820K, 41% free 7254K/12231K, paused 4ms+270ms
03-01 12:14:30.954: INFO/ActivityManager(76): Start proc com.android.providers.calendar for content provider com.android.providers.calendar/.CalendarProvider2: pid=310 uid=10009 gids={3003, 1015}
03-01 12:14:31.044: WARN/System.err(197): ... 12 more
03-01 12:14:31.044: DEBUG/Launcher.IconCache(197): getFullResIcon
03-01 12:14:31.074: INFO/System.out(197): *********Executed******
03-01 12:14:31.103: DEBUG/PowerManagerService(76): bootCompleted
03-01 12:14:31.173: VERBOSE/DevicePolicyManagerService(76): Sending password expiration notifications for action android.intent.action.BOOT_COMPLETED
03-01 12:14:31.204: INFO/SurfaceFlinger(33): Boot is finished (32818 ms)
03-01 12:14:31.204: INFO/SurfaceFlinger(33):
03-01 12:14:31.334 76:0x75 F/NetworkStats ]
03-01 12:14:31.204: INFO/SurfaceFlinger(33): problem reading network stats
03-01 12:14:31.204: INFO/SurfaceFlinger(33): java.lang.IllegalStateException: problem parsing line: null
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at com.android.server.NetworkManagementService.getNetworkStatsUidDetail(NetworkManagementService.java:1234)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at com.android.server.net.NetworkStatsService.performPollLocked(NetworkStatsService.java:810)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at com.android.server.net.NetworkStatsService.updateIfacesLocked(NetworkStatsService.java:721)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at com.android.server.net.NetworkStatsService.updateIfaces(NetworkStatsService.java:699)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at com.android.server.net.NetworkStatsService.access$000(NetworkStatsService.java:128)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at com.android.server.net.NetworkStatsService$8.handleMessage(NetworkStatsService.java:1546)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at android.os.Handler.dispatchMessage(Handler.java:95)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at android.os.Looper.loop(Looper.java:137)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at android.os.HandlerThread.run(HandlerThread.java:60)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): Caused by: java.io.FileNotFoundException: /proc/net/xt_qtaguid/stats: open failed: ENOENT (No such file or directory)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at libcore.io.IoBridge.open(IoBridge.java:406)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at java.io.FileInputStream.<init>(FileInputStream.java:78)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at java.io.FileReader.<init>(FileReader.java:42)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at com.android.internal.net.NetworkStatsFactory.readNetworkStatsDetail(NetworkStatsFactory.java:272)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): ... 9 more
03-01 12:14:31.204: INFO/SurfaceFlinger(33): Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at libcore.io.Posix.open(Native Method)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:98)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at libcore.io.IoBridge.open(IoBridge.java:390)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): ... 12 more
03-01 12:14:31.384: INFO/System.out(197): CN: ComponentInfo{com.android.contacts/com.android.contacts.activities.DialtactsActivity}
03-01 12:14:31.663: DEBUG/dalvikvm(34): GC_EXPLICIT freed 33K, 4% free 6825K/7107K, paused 3ms+4ms
03-01 12:14:31.803: INFO/System.out(197): *********In Try*******
03-01 12:14:31.803: INFO/System.out(197): getfullresiconnnnnnnnnnnnnnnn
03-01 12:14:31.843: DEBUG/IconCache(197): getFullResIcon : info ResolveInfo{410f0068 com.android.contacts.activities.DialtactsActivity p=0 o=0 m=0x0}
03-01 12:14:31.843: DEBUG/IconCache(197): getFullResIcon :try settingsContext android.app.ContextImpl#410f69a8
03-01 12:14:31.884: DEBUG/IconCache(197): getFullResIcon : currentThemePackage Default Theme
03-01 12:14:31.884: INFO/System.out(197): current theme package :Default Theme
03-01 12:14:31.894: DEBUG/IconCache(197): if currenttheme!=default
03-01 12:14:31.894: INFO/System.out(197): Icon file :/data/data/com.android.settings/app_themes/contacts.png
03-01 12:14:31.894: DEBUG/IconCache(197): getFullResIcon : iconFile /data/data/com.android.settings/app_themes/contacts.png
03-01 12:14:31.894: DEBUG/IconCache(197): if iconFile!=null
03-01 12:14:31.894: DEBUG/IconCache(197): if iconFile!=null : ico val /data/data/com.android.settings/app_themes/contacts.png
03-01 12:14:31.924: WARN/System.err(197): java.io.FileNotFoundException: /data/data/com.android.settings/app_themes/contacts.png: open failed: EACCES (Permission denied)
03-01 12:14:31.924: WARN/System.err(197): at libcore.io.IoBridge.open(IoBridge.java:406)
03-01 12:14:31.964: WARN/System.err(197): at java.io.FileInputStream.<init>(FileInputStream.java:78)
03-01 12:14:31.964: WARN/System.err(197): at com.android.launcher2.IconCache.getFullResIcon(IconCache.java:142)
03-01 12:14:31.973: WARN/System.err(197): at com.android.launcher2.IconCache.cacheLocked(IconCache.java:282)
03-01 12:14:31.973: WARN/System.err(197): at com.android.launcher2.IconCache.getIcon(IconCache.java:250)
03-01 12:14:32.004: WARN/System.err(197): at com.android.launcher2.LauncherModel.getShortcutInfo(LauncherModel.java:1641)
03-01 12:14:32.004: WARN/System.err(197): at com.android.launcher2.LauncherModel$LoaderTask.loadWorkspace(LauncherModel.java:1041)
03-01 12:14:32.014: WARN/System.err(197): at com.android.launcher2.LauncherModel$LoaderTask.loadAndBindWorkspace(LauncherModel.java:756)
03-01 12:14:32.014: WARN/System.err(197): at com.android.launcher2.LauncherModel$LoaderTask.run(LauncherModel.java:821)
03-01 12:14:32.024: WARN/System.err(197): at android.os.Handler.handleCallback(Handler.java:605)
03-01 12:14:32.024: WARN/System.err(197): at android.os.Handler.dispatchMessage(Handler.java:92)
03-01 12:14:32.034: WARN/System.err(197): at android.os.Looper.loop(Looper.java:137)
03-01 12:14:32.044: WARN/System.err(197): at android.os.HandlerThread.run(HandlerThread.java:60)
03-01 12:14:32.044: WARN/System.err(197): Caused by: libcore.io.ErrnoException: open failed: EACCES (Permission denied)
03-01 12:14:32.064: WARN/System.err(197): at libcore.io.Posix.open(Native Method)
03-01 12:14:32.064: WARN/System.err(197): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:98)
03-01 12:14:32.114: WARN/System.err(197): at libcore.io.IoBridge.open(IoBridge.java:390)
03-01 12:14:32.114: WARN/System.err(197): ... 12 more
03-01 12:14:32.124: DEBUG/Launcher.IconCache(197): getFullResIcon
03-01 12:14:32.154: INFO/System.out(197): *********Executed******

Categories

Resources