FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo - android

I am working on Map view using android API v2, I am following this tutorial, I have followed what he explained in tutorial, but still I am getting Fatal exception. here is my xml code with log cat.
<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=".MainActivity" >
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment" />
</RelativeLayout>
logcat:
05-08 10:38:22.121: E/AndroidRuntime(954): FATAL EXCEPTION: main
05-08 10:38:22.121: E/AndroidRuntime(954): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.map/com.example.map.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
05-08 10:38:22.121: E/AndroidRuntime(954): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.app.ActivityThread.access$600(ActivityThread.java:141)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.os.Handler.dispatchMessage(Handler.java:99)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.os.Looper.loop(Looper.java:137)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.app.ActivityThread.main(ActivityThread.java:5041)
05-08 10:38:22.121: E/AndroidRuntime(954): at java.lang.reflect.Method.invokeNative(Native Method)
05-08 10:38:22.121: E/AndroidRuntime(954): at java.lang.reflect.Method.invoke(Method.java:511)
05-08 10:38:22.121: E/AndroidRuntime(954): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-08 10:38:22.121: E/AndroidRuntime(954): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-08 10:38:22.121: E/AndroidRuntime(954): at dalvik.system.NativeStart.main(Native Method)
05-08 10:38:22.121: E/AndroidRuntime(954): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
05-08 10:38:22.121: E/AndroidRuntime(954): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
05-08 10:38:22.121: E/AndroidRuntime(954): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.app.Activity.setContentView(Activity.java:1881)
05-08 10:38:22.121: E/AndroidRuntime(954): at com.example.map.MainActivity.onCreate(MainActivity.java:12)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.app.Activity.performCreate(Activity.java:5104)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
05-08 10:38:22.121: E/AndroidRuntime(954): ... 11 more
05-08 10:38:22.121: E/AndroidRuntime(954): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.MapFragment: make sure class name exists, is public, and has an empty constructor that is public
05-08 10:38:22.121: E/AndroidRuntime(954): at android.app.Fragment.instantiate(Fragment.java:592)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.app.Fragment.instantiate(Fragment.java:560)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.app.Activity.onCreateView(Activity.java:4709)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
05-08 10:38:22.121: E/AndroidRuntime(954): ... 21 more
05-08 10:38:22.121: E/AndroidRuntime(954): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.MapFragment" on path: /data/app/com.example.map-2.apk
05-08 10:38:22.121: E/AndroidRuntime(954): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
05-08 10:38:22.121: E/AndroidRuntime(954): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
05-08 10:38:22.121: E/AndroidRuntime(954): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.app.Fragment.instantiate(Fragment.java:582)
05-08 10:38:22.121: E/AndroidRuntime(954): ... 24 more
And my manifest is looks like this.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.map"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission
android:name="com.example.map.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="com.example.map.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" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.map.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="AIzaSyDSW0CfwDN0LyrF8PBeihEjrAkj25TDhUQ" />
</application>
</manifest>

You are trying to import existing project into library. You should be importing the library using following method.
Right click package explorer. Import -> Expand Android -> Existing
Android Code Into Workspace.
Select the google-play-services library. And check the copy to
workspace checkbox.
Once this is done. Reference the library project
Right click on the project. Select Android in the left pane. In the right pane bottom you would see a frame with label Library. Click on add and add the imported library.
To add support library to your project:
Right click on the project Androids Tools -> Add Support library.
If you decide to use support libraries you will have to replace the code
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment" />
with
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
also in your java file you will have to use SupportMapFragment.
mMap = ((SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map)).getMap();

Make sure that you are using Google APIs in the project build target. Go to project Properties > Android to check this.

Are you using the correct API (GOOGLE API) in Eclipse? Make sure to use the GOOGLE APIs if you want to use google maps in android!

You are probably having an import problem. Just check in right click on project -> properties -> Java build path you have imported the libs. See this link for clarity

This error is usually derived from incorrect referencing of google-play-services library.
To do it correctly please follow the first 3 steps of this blog post guide I wrote on integrating Google Maps API V2 in your application:
Google Maps API V2

""Caused by: java.lang.ClassNotFoundException: Didn't find class"com.google.android.gms.maps.MapFragment" on path: /data/app/com.example.map-2.apk""
Have you checked this?
I think you should Add this (com.google.android.gms.maps.MapFragment)ACTIVITY in your AndroidManifest.XML.
Give a try to the three "caused by..." errors in the LogCat.

Related

java.lang.ClassNotFoundException: Didn't find class "com.millennialmedia.android.VideoPlayer"

I recently moved to MoPub and it all appears to be working well except for I have started getting this exception saying that com.millennialmedia.android.VideoPlayer can not be found. I looked and it isn't on the Millennial jar (I just got the latest from their site). Also my AndroidManifest mentions that class and Android Studio also says it can't be found.
This is what I have there:
<activity android:name="com.millennialmedia.android.MMActivity" android:theme="#android:style/Theme.Translucent.NoTitleBar" android:configChanges="keyboardHidden|orientation|keyboard" />
<activity android:name="com.millennialmedia.android.VideoPlayer" android:configChanges="keyboardHidden|orientation|keyboard" />
On Android Studio the VideoPlayer part is red.
This is the exception I got:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{mypackage/com.millennialmedia.android.VideoPlayer}: java.lang.ClassNotFoundException: Didn't find class "com.millennialmedia.android.VideoPlayer" on path: /data/app/mypackage-1.apk
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.millennialmedia.android.VideoPlayer" on path: /data/app/mypackage-1.apk
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(NativeStart.java)
Looking at the latest Millennial Media documentation, it looks like
com.millennialmedia.android.VideoPlayer
isn't included. This may be an update that needs to be made.
Alice

Getting FATAL EXCEPTION in extended calendar

I was initially using the calendar view and that was fine.
i wanted to display my events in the calendar view so i tried extended calendar view library.
When i imported the library project and integrated the code i am getting the following error.
FATAL EXCEPTION: main
android.view.InflateException: Binary XML file line #7: Error inflating class provider
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:698)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at com.ithoughtz.sns.MainActivity$PlaceholderFragment.onCreateView(MainActivity.java:171)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1786)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1126)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:454)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: android.view.provider
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.view.LayoutInflater.createView(LayoutInflater.java:552)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:643)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
... 19 more
Kindly let me know if i need to post code.
XML for calendar view as follows
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:orientation="vertical" >
<provider
android:name="com.tyczj.extendedcalendarview.CalendarProvider"
android:authorities="com.tyczj.extendedcalendarview.calendarprovider" />
<com.tyczj.extendedcalendarview.ExtendedCalendarView
android:id="#+id/calendar"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
provider is a tag that has to be declared in the AndroidManifast.xml file of your project for declaring ContentProviders and not in the layout file.
provider is not an xml tag that is why your exception stack states the cause to be provider class not found.
right click on project->Build path->configer Build path-> order and export-> checked all option->press OK...
Now try to run your project

google maps ane: RuntimeException: Attempting to create multiple DataRequestDispatchers

I'm creating a native extension that shows a native Google Map from a Flex-based AIR application. You can watch lee brimelow's demo to get the idea: https://plus.google.com/110495278155587072613/posts/degSYVx8423
I got a working demo of a native extension, just to show an Activity with some buttons, but I got stuck when I tried to show the map. Here is the exception I'm getting on setContentView(layoutID):
05-08 11:48:40.624: I/System.out(27917): WebViewActivity.onCreate failed with error:
05-08 11:48:40.634: I/System.out(27917): "android.view.InflateException: Binary XML file line #9: Error inflating class fragment"
05-08 11:48:40.644: W/dalvikvm(27917): threadid=1: thread exiting with uncaught exception (group=0x40fd8468)
05-08 11:48:40.654: E/AndroidRuntime(27917): FATAL EXCEPTION: main
05-08 11:48:40.654: E/AndroidRuntime(27917): java.lang.RuntimeException: Unable to start activity ComponentInfo{air.GoogleMapsApp.debug/com.trasys.googlemaps.WebViewActivity}: java.lang.RuntimeException: Attempting to create multiple DataRequestDispatchers
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2351)
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.ActivityThread.access$600(ActivityThread.java:151)
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1331)
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.os.Handler.dispatchMessage(Handler.java:99)
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.os.Looper.loop(Looper.java:155)
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.ActivityThread.main(ActivityThread.java:5454)
05-08 11:48:40.654: E/AndroidRuntime(27917): at java.lang.reflect.Method.invokeNative(Native Method)
05-08 11:48:40.654: E/AndroidRuntime(27917): at java.lang.reflect.Method.invoke(Method.java:511)
05-08 11:48:40.654: E/AndroidRuntime(27917): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
05-08 11:48:40.654: E/AndroidRuntime(27917): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:796)
05-08 11:48:40.654: E/AndroidRuntime(27917): at dalvik.system.NativeStart.main(Native Method)
05-08 11:48:40.654: E/AndroidRuntime(27917): Caused by: java.lang.RuntimeException: Attempting to create multiple DataRequestDispatchers
05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.ak.n.b(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.ak.n.a(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.ak.h.a(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.af.w.a(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.z.ab.a(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.z.ab.a(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.z.ag.a(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.z.ag.a(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.z.bw.a(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.z.r.onCreateView(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at com.google.android.gms.maps.internal.IMapFragmentDelegate$Stub.onTransact(IMapFragmentDelegate.java:107)
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.os.Binder.transact(Binder.java:326)
05-08 11:48:40.654: E/AndroidRuntime(27917): at com.google.android.gms.maps.internal.IMapFragmentDelegate$a$a.onCreateView(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at com.google.android.gms.maps.MapFragment$b.onCreateView(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at com.google.android.gms.internal.e$4.a(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at com.google.android.gms.internal.e.a(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at com.google.android.gms.internal.e.onCreateView(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at com.google.android.gms.maps.MapFragment.onCreateView(Unknown Source)
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:809)
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1037)
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1019)
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1804)
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.Activity.performCreate(Activity.java:5069)
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1101)
05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307)
05-08 11:48:40.654: E/AndroidRuntime(27917): ... 11 more
I'm pretty convinced the communication between AIR and Android is ok, so I'm only posting my native code. (When I remove the map, the native extension works with no issues)
Here is the layout xml file
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical" >
<fragment android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="300dp" />
</LinearLayout>
Here is my FREFunction
public class GoogleMapsFunction implements FREFunction {
#Override
public FREObject call(FREContext ctx, FREObject[] passedArgs) {
int layoutID, googleMapID;
Intent i = new Intent(ctx.getActivity(), WebViewActivity.class);
layoutID = ctx.getResourceId("layout.activity_google_maps");
googleMapID = ctx.getResourceId("id.map");
i.putExtra("layoutID", layoutID);
i.putExtra("googleMapID", googleMapID);
ctx.getActivity().startActivity(i);
return null;
}
}
Here is my Activity
public class WebViewActivity extends Activity {
private GoogleMap map;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
int layoutID = getIntent().getIntExtra("layoutID", -1);
setContentView(layoutID);
int googleMapID = getIntent().getIntExtra("googleMapID", -1);
map = ((MapFragment) getFragmentManager().findFragmentById(googleMapID))
.getMap();
} catch(Exception e){
System.out.printf("WebViewActivity.onCreate failed with error:\n\"%s\"\n",
e.toString());
Toast.makeText(this, "WebViewActivity.onCreate failed: " +
e.toString(), Toast.LENGTH_SHORT).show();
}
}
}
Here is my AndroidManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.trasys.googlemaps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="17" />
<permission android:name="com.example.helloworld.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.example.helloworld.permission.C2D_MESSAGE" />
<permission android:name="com.example.helloworld.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<uses-permission android:name="com.example.helloworld.permission.MAPS_RECEIVE"/>
<!-- App receives GCM messages. -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!-- GCM connects to Google Services. -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<!-- Keeps the processor from sleeping when a message is received. -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- The following two permissions are not required to use
Google Maps Android API v2, but are recommended. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name">
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="MyApiKey"/>
</application>
</manifest>
I see some com.google.android.gms. entries in the stacktrace, so I assume all google libraries are loaded correctly.
I created a separate pure native android application for testing purpose.
In this app I managed to create an activity which displays the map, this activity uses the same layout XML, the same google libraries and the same API key.
Any idea's?
You need to include third party classes on the jar file that is why fragment class is not found "Error inflating class fragment" .
After exporting your java files open the jar file with any zip tool like 7-zip, browse to com folder and copy the packages from third party jar file (opening it same way). After that you will need to recreate the ane file.

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

I have this strange behavior I cannot explain.
My layout is quite simple: An EditText:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:padding="10dp" >
<EditText
android:id="#+id/etPass"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
When I try to longPress it (to paste some text) I got an imediate Force Close and this error:
05-08 16:56:16.838: E/AndroidRuntime(12164): FATAL EXCEPTION: main
05-08 16:56:16.838: E/AndroidRuntime(12164): android.view.InflateException: Binary XML file line #17: Error inflating class <unknown>
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
05-08 16:56:16.838: E/AndroidRuntime(12164): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.Editor$ActionPopupWindow.initContentView(Editor.java:2995)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.Editor$PinnedPopupWindow.<init>(Editor.java:2280)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:2968)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:2968)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.Editor$HandleView.showActionPopupWindow(Editor.java:3189)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.Editor$InsertionHandleView.showWithActionPopup(Editor.java:3416)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.Editor$InsertionPointCursorController.showWithActionPopup(Editor.java:3652)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.Editor.performLongClick(Editor.java:870)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.TextView.performLongClick(TextView.java:7973)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.view.View$CheckForLongPress.run(View.java:17140)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.os.Handler.handleCallback(Handler.java:615)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.os.Handler.dispatchMessage(Handler.java:92)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.os.Looper.loop(Looper.java:213)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.app.ActivityThread.main(ActivityThread.java:4786)
05-08 16:56:16.838: E/AndroidRuntime(12164): at java.lang.reflect.Method.invokeNative(Native Method)
05-08 16:56:16.838: E/AndroidRuntime(12164): at java.lang.reflect.Method.invoke(Method.java:511)
05-08 16:56:16.838: E/AndroidRuntime(12164): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
05-08 16:56:16.838: E/AndroidRuntime(12164): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
05-08 16:56:16.838: E/AndroidRuntime(12164): at dalvik.system.NativeStart.main(Native Method)
05-08 16:56:16.838: E/AndroidRuntime(12164): Caused by: java.lang.reflect.InvocationTargetException
05-08 16:56:16.838: E/AndroidRuntime(12164): at java.lang.reflect.Constructor.constructNative(Native Method)
05-08 16:56:16.838: E/AndroidRuntime(12164): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
05-08 16:56:16.838: E/AndroidRuntime(12164): ... 25 more
05-08 16:56:16.838: E/AndroidRuntime(12164): Caused by: java.lang.ArrayIndexOutOfBoundsException: length=15; index=491
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.content.res.StringBlock.get(StringBlock.java:64)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.content.res.XmlBlock$Parser.getPooledString(XmlBlock.java:458)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.content.res.TypedArray.loadStringValueAt(TypedArray.java:720)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.content.res.TypedArray.getString(TypedArray.java:124)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.TextView.<init>(TextView.java:800)
05-08 16:56:16.838: E/AndroidRuntime(12164): at android.widget.TextView.<init>(TextView.java:450)
05-08 16:56:16.838: E/AndroidRuntime(12164): ... 28 more
I have really no clue what's happening, and I would be pleased to get some help!
Just to be clear, I have nothing in my Activity related to a listener on this EditText:
import android.app.Activity;
import android.os.Bundle;
public class ProActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.activity_pro);
}
}
Just remove this line from your custom style
This single line:
<item name="android:fontFamily">sans-serif-light</item>
Will make the EditText crash when long pressing it.
The Android copy/paste popup was the root cause of the error.
this link solved my issue, although the auto-complete in xml files was not working, but the code in this example is correct, i declared all in the same styles file and it worked :
https://github.com/rengwuxian/MaterialEditText/issues/162
and that's what was said in it :
Seems to be an error in styles, verify if you have
<item name="android:fontFamily"></item>
in your application theme, not in the themes view, in application theme.
The same error happened to me until i removed this line of my style.xml, if you have that line, remove them, if you need this property, you can stylize textviews and buttons with:
<style name="TextViewStyle" parent="android:Widget.TextView">
<item name="android:fontFamily">sans-serif-medium</item>
</style>
<style name="ButtonStyle" parent="android:Widget.Holo.Button">
<item name="android:fontFamily">sans-serif-medium</item>
</style>
And in your app theme, use:
<item name="android:textViewStyle">#style/TextViewStyle</item>
<item name="android:buttonStyle">#style/ButtonStyle</item>
I have also encountered this problem ;
but the cause of it is that i use ContextThemeWrapper;
here is how we get LayoutInflater from ContextThemeWrapper
#Override
public Object getSystemService(String name) {
if (LAYOUT_INFLATER_SERVICE.equals(name)) {
if (mInflater == null) {
mInflater = LayoutInflater.from(mBase).cloneInContext(this);
}
return mInflater;
}
return mBase.getSystemService(name);
}
from the code block above, we can see that it handle LayoutInflater specially, which is the source of the problem.
my solution is : override this method as follow
#Override
public Object getSystemService(String name){
return getBaseContext().getSystemService(name);
}
I face this problem when using <item name="android:fontFamily">sans-serif</item> in style.xml
It CRASH on
Samsung S4 (SC-04E) (5.0.1)
Samsung Galaxy Node 5 (5.1.1)
It NOT CRASH on
Samsung S7 Edge (SM-G935F) (7.0)
Xiaomi A2 (8.0.1)
Pixel XL (8.1.0)
Sony Xperia Z5 Au (SOV32) (6.0)
Arrow NX (F-04G) (6.0.1)
Kyocera (S2) (7.0)
At first, I think this problem will only happened on Samsung but Samsung S7 don't crash.
Then I think the API may cause this problem because current crash device have API < 6.0. However I am not sure about it because I don't have much device for testing
Summary: It will crash in some device
TO FIX THIS PROBLEM
First, remove sans-serif
Then download Roboto font from https://github.com/google/fonts/tree/master/apache/roboto then add to project following https://developer.android.com/guide/topics/ui/look-and-feel/fonts-in-xml
Why Roboto font?
You are facing this problem when using sans-serif font right?
sans-serif in Android is Roboto font (see here Android default font)
If you know some device which will crash, please edit my answer, it may help for testing.
Hope it help

android.view.inflateException Android

I have created one java class and one layout with image button. When I set content view it throws runtime exception.
Error:
02-02 17:46:39.558: E/AndroidRuntime(954): FATAL EXCEPTION: main
02-02 17:46:39.558: E/AndroidRuntime(954): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.oceans/com.oceans.LettersScreenActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
02-02 17:46:39.558: E/AndroidRuntime(954): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
02-02 17:46:39.558: E/AndroidRuntime(954): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
02-02 17:46:39.558: E/AndroidRuntime(954): at android.app.ActivityThread.access$600(ActivityThread.java:130)
02-02 17:46:39.558: E/AndroidRuntime(954): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
02-02 17:46:39.558: E/AndroidRuntime(954): at android.os.Handler.dispatchMessage(Handler.java:99)
02-02 17:46:39.558: E/AndroidRuntime(954): at android.os.Looper.loop(Looper.java:137)
02-02 17:46:39.558: E/AndroidRuntime(954): at android.app.ActivityThread.main(ActivityThread.java:4745)
02-02 17:46:39.558: E/AndroidRuntime(954): at java.lang.reflect.Method.invokeNative(Native Method)
02-02 17:46:39.558: E/AndroidRuntime(954): at java.lang.reflect.Method.invoke(Method.java:511)
02-02 17:46:39.558: E/AndroidRuntime(954): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
02-02 17:46:39.558: E/AndroidRuntime(954): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
02-02 17:46:39.558: E/AndroidRuntime(954): at dalvik.system.NativeStart.main(Native Method)
02-02 17:46:39.558: E/AndroidRuntime(954): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
02-02 17:46:39.558: E/AndroidRuntime(954): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
02-02 17:46:39.558: E/AndroidRuntime(954): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
02-02 17:46:39.558: E/AndroidRuntime(954): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
02-02 17:46:39.558: E/AndroidRuntime(954): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
02-02 17:46:39.558: E/AndroidRuntime(954): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
02-02 17:46:39.558: E/AndroidRuntime(954): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
02-02 17:46:39.558: E/AndroidRuntime(954): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
02-02 17:46:39.558: E/AndroidRuntime(954): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
Xml Layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/letters_bg" >
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="49dp"
android:src="#drawable/leftsignpost" />
</RelativeLayout>
Java Class Code :
public class LettersScreenActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.letters_screen); // error is here
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
}
So what is the problem?
Why it is throwing runtime exception ??
I've tried this code ...Its really working fine ... please check your Image and manifest file
There are no any obvious problems in the code provided, should run? At least does for me (the drawables are mine, of course).
Check if you have the referenced resources letters_bg and leftsignpost in place. These must be under res/drawable . Clean the project. Try to provide the longer stack trace.

Categories

Resources