I try to use OSMdroid in one of my applictions, but i got this:
running on hardware device Android 4.0.3 (CM9)
log from logcat:
06-25 16:56:07.389: E/AndroidRuntime(17760): java.lang.RuntimeException: Unable to start activity ComponentInfo{app.OSMMapViewActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class org.osmdroid.views.MapView
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2079)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2104)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.app.ActivityThread.access$600(ActivityThread.java:132)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1157)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.os.Handler.dispatchMessage(Handler.java:99)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.os.Looper.loop(Looper.java:137)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.app.ActivityThread.main(ActivityThread.java:4575)
06-25 16:56:07.389: E/AndroidRuntime(17760): at java.lang.reflect.Method.invokeNative(Native Method)
06-25 16:56:07.389: E/AndroidRuntime(17760): at java.lang.reflect.Method.invoke(Method.java:511)
06-25 16:56:07.389: E/AndroidRuntime(17760): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
06-25 16:56:07.389: E/AndroidRuntime(17760): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
06-25 16:56:07.389: E/AndroidRuntime(17760): at dalvik.system.NativeStart.main(Native Method)
06-25 16:56:07.389: E/AndroidRuntime(17760): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class org.osmdroid.views.MapView
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
06-25 16:56:07.389: E/AndroidRuntime(17760): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.app.Activity.setContentView(Activity.java:1835)
06-25 16:56:07.389: E/AndroidRuntime(17760): at app.OSMMapViewActivity.onCreate(OSMMapViewActivity.java:16)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.app.Activity.performCreate(Activity.java:4465)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2033)
06-25 16:56:07.389: E/AndroidRuntime(17760): ... 11 more
06-25 16:56:07.389: E/AndroidRuntime(17760): Caused by: java.lang.ClassNotFoundException: org.osmdroid.views.MapView
06-25 16:56:07.389: E/AndroidRuntime(17760): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
06-25 16:56:07.389: E/AndroidRuntime(17760): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-25 16:56:07.389: E/AndroidRuntime(17760): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.view.LayoutInflater.createView(LayoutInflater.java:552)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
06-25 16:56:07.389: E/AndroidRuntime(17760): ... 21 more
i hope this will help you more.
mapscreen.xml
<?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:orientation="vertical" >
<org.osmdroid.views.MapView
android:id="#+id/mapview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true" />
</LinearLayout>
this is my activity:
import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapController;
import org.osmdroid.views.MapView;
import android.app.Activity;
import android.os.Bundle;
public class OSMMapViewActivity extends Activity{
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mapscreen);
MapView mMapView = (MapView) findViewById(R.id.mapview);
mMapView.setTileSource(TileSourceFactory.MAPNIK);
mMapView.setBuiltInZoomControls(true);
MapController mMapController = mMapView.getController();
mMapController.setZoom(13);
GeoPoint gPt = new GeoPoint(51500000, -150000);
//Centre map near to Hyde Park Corner, London
mMapController.setCenter(gPt);
}
}
i'm using OSMDroid 3.0.8 and slf4j-1.5.8 and eclipse.
EDIT:
I commented out the setContentView() and the other code. I think the problem is something eith the layout files...
EDIT1:
The Problem is solved... :)
copy osmdroid and the other jars from libs/osmdroid
to libs/ ^_^
Thanks for help anyway!!!!
Thx for helping
Have you added the proper permissions in your Android Manifest file?
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Missing either of these, although ACCESS_FINE_LOCATION could be replaced by ACCESS_COARSE_LOCATION, will usually cause any type of MapView to fail.
The problem is that eclipse need a restart, to load external libraries correct.
Thanks for all your help!!!
I had the same problem.
I solved it by:
cd into the libs folder of your project.
ls .
Notice, there is only one of the required libs. The osmdroid-android-4.0.jar is absent.
Copy it from where you downloaded and saved it from, into this folder.
Run the application now. I should work.
Note: I had already added it to the project path by selecting the project->properties->Java Built path->Libraries.
The required libs are:
slf4j-android-1.5.8.jar
osmdroid-android-4.0.jar
Related
I am trying to run Google maps API v2 on emulator. It says "unfortunately app has stoped" Here is my manifest.xml code. There is a huge number of errors. In the first line it gives error to define android.allowBackup which I have done on application tag.Please help me solve them.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<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"/>
<uses-permissionandroid:name="com.myapp.providers.gsf.permission.
READ_GSERVICES"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data android:name="com.google.android.gms.version" android:value="4030500" />
<!-- <meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" /> -->
<activity
android:name="com.myapp.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="My key"/>
</application>
</manifest>
----------------------------------------------------------------------------------------------
MainActivity.java
package myapp;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
public class MainActivity extends FragmentActivity {
private GoogleMap map;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SupportMapFragment mapFrag = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
map = mapFrag.getMap();
map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
}
}
------------------------------------------------------------------------------------
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.SupportMapFragment"/>
-----------------------------------------------------------------
Logcat
E/Trace(690): error opening trace file: No such file or directory (2)
E/AndroidRuntime(690): FATAL EXCEPTION: main
E/AndroidRuntime(690): java.lang.RuntimeException:
Unable to start activity
ComponentInfo{myapp/myapp.MainActivity}:android.view.InflateException: Binary XML file line #2:
Error inflating class fragment
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
android.app.ActivityThread.access$600(ActivityThread.java:130)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:137)
android.app.ActivityThread.main(ActivityThread.java:4745)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:511)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
dalvik.system.NativeStart.main(Native Method)
09-01 15:06:56.709: E/AndroidRuntime(690): Caused by: android.view.InflateException: Binary XML
file line #2: Error inflating class fragment
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
android.view.LayoutInflater.inflate(LayoutInflater.java:466)
android.view.LayoutInflater.inflate(LayoutInflater.java:396)
android.view.LayoutInflater.inflate(LayoutInflater.java:352)
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
android.app.Activity.setContentView(Activity.java:1867)
android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.
java:110)
android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
myapp.MainActivity.onCreate(MainActivity.java:14)
android.app.Activity.performCreate(Activity.java:5008)
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
AndroidRuntime(690): ... 11 more
AndroidRuntime(690): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's
AndroidManifest.xml does not have the right value. Expected 5089000 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" />
com.google.android.gms.common.GooglePlayServicesUtil.A(Unknown Source)
com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable
(Unknown Source)
com.google.android.gms.maps.internal.u.I(Unknown Source)
com.google.android.gms.maps.internal.u.H(Unknown Source)
com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
com.google.android.gms.maps.MapFragment$b.jz(Unknown Source)
com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
com.google.android.gms.dynamic.a.a(Unknown Source)
com.google.android.gms.dynamic.a.onInflate(Unknown Source)
com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
android.app.Activity.onCreateView(Activity.java:4663)
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
09-01 15:06:56.709: E/AndroidRuntime(690): ... 23 more
09-01 15:07:53.868: E/Trace(734): error opening trace file: No such file or directory (2)
09-01 15:07:54.479: E/AndroidRuntime(734): FATAL EXCEPTION: main
09-01 15:07:54.479: E/AndroidRuntime(734): java.lang.RuntimeException:
Unable to start activity ComponentInfo{myapp/myapp.MainActivity}
android.view.InflateException: Binary XML file line #2: Error inflating class fragment
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
android.app.ActivityThread.access$600(ActivityThread.java:130)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:137)
android.app.ActivityThread.main(ActivityThread.java:4745)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:511)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
dalvik.system.NativeStart.main(Native Method)
09-01 15:07:54.479: E/AndroidRuntime(734): Caused by:
android.view.InflateException: Binary XML file line #2: Error inflating class fragment
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
android.view.LayoutInflater.inflate(LayoutInflater.java:466)
android.view.LayoutInflater.inflate(LayoutInflater.java:396)
android.view.LayoutInflater.inflate(LayoutInflater.java:352)
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
android.app.Activity.setContentView(Activity.java:1867)
android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
android.support.v7.app.ActionBarActivityDelegateICS.
setContentView(ActionBarActivityDelegateICS.java:110)
android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
myapp.MainActivity.onCreate(MainActivity.java:14)
android.app.Activity.performCreate(Activity.java:5008)
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
E/AndroidRuntime(734): ... 11 more
E/AndroidRuntime(734): Caused by: java.lang.IllegalStateException: The meta-data tag in your
app's AndroidManifest.xml does not have the right value. Expected 5089000 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" />
com.google.android.gms.common.GooglePlayServicesUtil.A(Unknown Source)
com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable
(Unknown Source)
com.google.android.gms.maps.internal.u.I(Unknown Source)
com.google.android.gms.maps.internal.u.H(Unknown Source)
com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
com.google.android.gms.maps.MapFragment$b.jz(Unknown Source)
com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
com.google.android.gms.dynamic.a.a(Unknown Source)
com.google.android.gms.dynamic.a.onInflate(Unknown Source)
com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
android.app.Activity.onCreateView(Activity.java:4663)
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
09-01 15:07:54.479: E/AndroidRuntime(734): ... 23 more
error opening trace file: No such file or directory (2)
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{myapp/myapp.MainActivity}:
android.view.InflateException: Binary XML file line #2: Error inflating class fragment
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
android.app.ActivityThread.access$600(ActivityThread.java:130)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:137)
android.app.ActivityThread.main(ActivityThread.java:4745)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:511)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
dalvik.system.NativeStart.main(Native Method)
09-01 15:12:22.938: E/AndroidRuntime(811): Caused by: android.view.InflateException: Binary XML
file line #2: Error inflating class fragment
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
android.view.LayoutInflater.inflate(LayoutInflater.java:466)
android.view.LayoutInflater.inflate(LayoutInflater.java:396)
android.view.LayoutInflater.inflate(LayoutInflater.java:352)
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
android.app.Activity.setContentView(Activity.java:1867)
android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
android.support.v7.app.ActionBarActivityDelegateICS.setContentView
(ActionBarActivityDelegateICS.java:110)
android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
myapp.MainActivity.onCreate(MainActivity.java:14)
android.app.Activity.performCreate(Activity.java:5008)
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
09-01 15:12:22.938: E/AndroidRuntime(811): ... 11 more
09-01 15:12:22.938: E/AndroidRuntime(811): Caused by: java.lang.IllegalStateException: The meta-
data tag in your app's AndroidManifest.xml does not have the right value. Expected 5089000
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" />
com.google.android.gms.common.GooglePlayServicesUtil.A(Unknown Source)
com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable
(Unknown Source)
com.google.android.gms.maps.internal.u.I(Unknown Source)
com.google.android.gms.maps.internal.u.H(Unknown Source)
com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
com.google.android.gms.maps.MapFragment$b.jz(Unknown Source)
com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
com.google.android.gms.dynamic.a.a(Unknown Source)
com.google.android.gms.dynamic.a.onInflate(Unknown Source)
com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
android.app.Activity.onCreateView(Activity.java:4663)
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
09-01 15:19:34.508: E/Trace(826): error opening trace file: No such file or directory (2)
09-01 15:19:35.118: E/AndroidRuntime(826): FATAL EXCEPTION: main
09-01 15:19:35.118: E/AndroidRuntime(826): java.lang.RuntimeException:
Unable to start activity ComponentInfo{myapp/myapp.MainActivity}: android.view.InflateException:
Binary XML file line #2: Error inflating class fragment
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
android.app.ActivityThread.access$600(ActivityThread.java:130)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:137)
android.app.ActivityThread.main(ActivityThread.java:4745)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:511)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
dalvik.system.NativeStart.main(Native Method)
09-01 15:19:35.118: E/AndroidRuntime(826): Caused by: android.view.InflateException: Binary XML
file line #2: Error inflating class fragment
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
android.view.LayoutInflater.inflate(LayoutInflater.java:466)
android.view.LayoutInflater.inflate(LayoutInflater.java:396)
android.view.LayoutInflater.inflate(LayoutInflater.java:352)
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
android.app.Activity.setContentView(Activity.java:1867)
android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
android.support.v7.app.ActionBarActivityDelegateICS.setContentView
(ActionBarActivityDelegateICS.java:110)
android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
myapp.MainActivity.onCreate(MainActivity.java:14)
android.app.Activity.performCreate(Activity.java:5008)
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
09-01 15:19:35.118: E/AndroidRuntime(826): ... 11 more
09-01 15:19:35.118: E/AndroidRuntime(826): Caused by: java.lang.IllegalStateException:
The meta- data tag in your app's AndroidManifest.xml does not
have the right value. Expected 5089000 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" />
com.google.android.gms.common.GooglePlayServicesUtil.A(Unknown Source)
com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailabl
(Unknown Source)
com.google.android.gms.maps.internal.u.I(Unknown Source)
com.google.android.gms.maps.internal.u.H(Unknown Source)
com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
com.google.android.gms.maps.MapFragment$b.jz(Unknown Source)
com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
com.google.android.gms.dynamic.a.a(Unknown Source)
com.google.android.gms.dynamic.a.onInflate(Unknown Source)
com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
android.app.Activity.onCreateView(Activity.java:4663)
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
09-01 15:27:57.068: E/Trace(865): error opening trace file: No such file or directory (2)
09-01 15:27:57.748: E/AndroidRuntime(865): FATAL EXCEPTION: main
09-01 15:27:57.748: E/AndroidRuntime(865): java.lang.RuntimeException:
Unable to start activity ComponentInfo{myapp/myapp.MainActivity}:
android.view.InflateException: Binary XML file line #2: Error inflating class fragment
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
android.app.ActivityThread.access$600(ActivityThread.java:130)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:137)
android.app.ActivityThread.main(ActivityThread.java:4745)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:511)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
dalvik.system.NativeStart.main(Native Method)
09-01 15:27:57.748: E/AndroidRuntime(865): Caused by: android.view.InflateException: Binary XML
file line #2: Error inflating class fragment
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
android.view.LayoutInflater.inflate(LayoutInflater.java:466)
android.view.LayoutInflater.inflate(LayoutInflater.java:396)
android.view.LayoutInflater.inflate(LayoutInflater.java:352)
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
android.app.Activity.setContentView(Activity.java:1867)
android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
android.support.v7.app.ActionBarActivityDelegateICS.setContentView
(ActionBarActivityDelegateICS.java:110)
android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
myapp.MainActivity.onCreate(MainActivity.java:14)
android.app.Activity.performCreate(Activity.java:5008)
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
09-01 15:27:57.748: E/AndroidRuntime(865): ... 11 more
09-01 15:27:57.748: E/AndroidRuntime(865): Caused by: java.lang.IllegalStateException:
The meta- data tag in your app's AndroidManifest.xml does not have the right value.
Expected 5089000 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" />
com.google.android.gms.common.GooglePlayServicesUtil.A(Unknown Source)
com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable
(Unknown Source)
com.google.android.gms.maps.internal.u.I(Unknown Source)
com.google.android.gms.maps.internal.u.H(Unknown Source)
com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
com.google.android.gms.maps.MapFragment$b.jz(Unknown Source)
com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
com.google.android.gms.dynamic.a.a(Unknown Source)
com.google.android.gms.dynamic.a.onInflate(Unknown Source)
com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
android.app.Activity.onCreateView(Activity.java:4663)
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
09-01 15:27:57.748: E/AndroidRuntime(865): ... 23 more
mmmh... Change
<meta-data android:name="com.google.android.gms.version" android:value="4030500" />
to
<meta-data android:name="com.google.android.gms.version" android:value="5089000" />
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<permission
android:name="com.myapp.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.myapp.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.myapp."Your activity name""
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="Your map key" />
</application>
</manifest>
Add the below permission to your Manifest.xml
<permission android:name="com.myapp.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
and replaca the below line:
<uses-permissionandroid:name="com.myapp.providers.gsf.permission.
READ_GSERVICES"/>
via
<uses-permission android:name="com.myapp.providers.gsf.permission.
READ_GSERVICES"/>
This question already has answers here:
After Google Play Service update to version 13 I got an error
(8 answers)
Closed 8 years ago.
Hello i am traying to follow this tutorial
http://androidresearch.wordpress.com/2013/09/29/google-maps-api-v2-android-tutorial/
and i downloaded the source code but i cant get it run
this my debug logcat when i run the applicatino on the adv
01-07 19:12:44.086: I/dalvikvm(630): threadid=3: reacting to signal 3
01-07 19:12:44.106: I/dalvikvm(630): Wrote stack traces to '/data/anr/traces.txt'
01-07 19:12:51.036: I/Process(630): Sending signal. PID: 630 SIG: 9
01-07 19:15:28.196: I/dalvikvm(678): threadid=3: reacting to signal 3
01-07 19:15:28.296: I/dalvikvm(678): Wrote stack traces to '/data/anr/traces.txt'
01-07 19:15:28.466: D/AndroidRuntime(678): Shutting down VM
01-07 19:15:28.466: W/dalvikvm(678): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
01-07 19:15:28.486: E/AndroidRuntime(678): FATAL EXCEPTION: main
01-07 19:15:28.486: E/AndroidRuntime(678): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mapsv2/com.example.mapsv2.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
01-07 19:15:28.486: E/AndroidRuntime(678): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.app.ActivityThread.access$600(ActivityThread.java:123)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.os.Handler.dispatchMessage(Handler.java:99)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.os.Looper.loop(Looper.java:137)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.app.ActivityThread.main(ActivityThread.java:4424)
01-07 19:15:28.486: E/AndroidRuntime(678): at java.lang.reflect.Method.invokeNative(Native Method)
01-07 19:15:28.486: E/AndroidRuntime(678): at java.lang.reflect.Method.invoke(Method.java:511)
01-07 19:15:28.486: E/AndroidRuntime(678): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-07 19:15:28.486: E/AndroidRuntime(678): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-07 19:15:28.486: E/AndroidRuntime(678): at dalvik.system.NativeStart.main(Native Method)
01-07 19:15:28.486: E/AndroidRuntime(678): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
01-07 19:15:28.486: E/AndroidRuntime(678): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
01-07 19:15:28.486: E/AndroidRuntime(678): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.app.Activity.setContentView(Activity.java:1835)
01-07 19:15:28.486: E/AndroidRuntime(678): at com.example.mapsv2.MainActivity.onCreate(MainActivity.java:13)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.app.Activity.performCreate(Activity.java:4465)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
01-07 19:15:28.486: E/AndroidRuntime(678): ... 11 more
01-07 19:15:28.486: E/AndroidRuntime(678): 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" />
01-07 19:15:28.486: E/AndroidRuntime(678): at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
01-07 19:15:28.486: E/AndroidRuntime(678): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
01-07 19:15:28.486: E/AndroidRuntime(678): at com.google.android.gms.maps.internal.q.v(Unknown Source)
01-07 19:15:28.486: E/AndroidRuntime(678): at com.google.android.gms.maps.internal.q.u(Unknown Source)
01-07 19:15:28.486: E/AndroidRuntime(678): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
01-07 19:15:28.486: E/AndroidRuntime(678): at com.google.android.gms.maps.SupportMapFragment$b.cE(Unknown Source)
01-07 19:15:28.486: E/AndroidRuntime(678): at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
01-07 19:15:28.486: E/AndroidRuntime(678): at com.google.android.gms.dynamic.a.a(Unknown Source)
01-07 19:15:28.486: E/AndroidRuntime(678): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
01-07 19:15:28.486: E/AndroidRuntime(678): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:284)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
01-07 19:15:28.486: E/AndroidRuntime(678): ... 20 more
01-07 19:15:28.706: I/dalvikvm(678): threadid=3: reacting to signal 3
01-07 19:15:28.726: I/dalvikvm(678): Wrote stack traces to '/data/anr/traces.txt'
01-07 19:15:29.106: I/dalvikvm(678): threadid=3: reacting to signal 3
01-07 19:15:29.126: I/dalvikvm(678): Wrote stack traces to '/data/anr/traces.txt'
01-07 19:15:36.495: I/Process(678): Sending signal. PID: 678 SIG: 9
and the xml code is here
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mapsv2"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="android.permission.INTERNET" />
<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" />
<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" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyCyR3kVxyrriZlavRfsly-lBYo8Pl4VMkM" />
<activity
android:name="com.example.mapsv2.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>
</application>
</manifest>
It's good habit to read error message first:
E/AndroidRuntime(678): 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 element:
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
so add this to your manifest.
I am trying to integrate the Youtube API into my project. To do so,
I have copied the the necessary jar files from the sdk folder to my project
Added it to my project build path.
I have also obtained a key from google, and added it to the Developer.java file, and it is used at the time of calling the intialize() function.
The program shows no error at build time. However, when it shows the follwing log when I try to initialize. Please help:
06-25 18:26:15.813: E/AndroidRuntime(6197): FATAL EXCEPTION: main
06-25 18:26:15.813: E/AndroidRuntime(6197): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.deltapath.frSIP/hk.d100.VideoPlayer}: java.lang.IllegalArgumentException: callingAppVersion cannot be null or empty
06-25 18:26:15.813: E/AndroidRuntime(6197): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
06-25 18:26:15.813: E/AndroidRuntime(6197): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
06-25 18:26:15.813: E/AndroidRuntime(6197): at android.app.ActivityThread.access$600(ActivityThread.java:141)
06-25 18:26:15.813: E/AndroidRuntime(6197): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
06-25 18:26:15.813: E/AndroidRuntime(6197): at android.os.Handler.dispatchMessage(Handler.java:99)
06-25 18:26:15.813: E/AndroidRuntime(6197): at android.os.Looper.loop(Looper.java:137)
06-25 18:26:15.813: E/AndroidRuntime(6197): at android.app.ActivityThread.main(ActivityThread.java:5041)
06-25 18:26:15.813: E/AndroidRuntime(6197): at java.lang.reflect.Method.invokeNative(Native Method)
06-25 18:26:15.813: E/AndroidRuntime(6197): at java.lang.reflect.Method.invoke(Method.java:511)
06-25 18:26:15.813: E/AndroidRuntime(6197): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-25 18:26:15.813: E/AndroidRuntime(6197): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-25 18:26:15.813: E/AndroidRuntime(6197): at dalvik.system.NativeStart.main(Native Method)
06-25 18:26:15.813: E/AndroidRuntime(6197): Caused by: java.lang.IllegalArgumentException: callingAppVersion cannot be null or empty
06-25 18:26:15.813: E/AndroidRuntime(6197): at com.google.android.youtube.player.internal.ac.a(Unknown Source)
06-25 18:26:15.813: E/AndroidRuntime(6197): at com.google.android.youtube.player.internal.o.<init>(Unknown Source)
06-25 18:26:15.813: E/AndroidRuntime(6197): at com.google.android.youtube.player.internal.ad.a(Unknown Source)
06-25 18:26:15.813: E/AndroidRuntime(6197): at com.google.android.youtube.player.YouTubePlayerView.a(Unknown Source)
06-25 18:26:15.813: E/AndroidRuntime(6197): at com.google.android.youtube.player.YouTubeBaseActivity$a.a(Unknown Source)
06-25 18:26:15.813: E/AndroidRuntime(6197): at com.google.android.youtube.player.YouTubePlayerView.initialize(Unknown Source)
06-25 18:26:15.813: E/AndroidRuntime(6197): at hk.d100.VideoPlayer.onCreate(VideoPlayer.java:42)
06-25 18:26:15.813: E/AndroidRuntime(6197): at android.app.Activity.performCreate(Activity.java:5104)
06-25 18:26:15.813: E/AndroidRuntime(6197): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
06-25 18:26:15.813: E/AndroidRuntime(6197): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
06-25 18:26:15.813: E/AndroidRuntime(6197): ... 11 more
If possible, please include your use of the YouTube API (rather than only the stack trace) so others can help you out.
I have a project that uses the GoogleMaps API, and the support library for Fragments. I have a working map in one activity already, so I know that the API and library are all set up right. I am trying to add a map in a fragment as part of a new activity.
The activity extends an android.support.v4.app.FragmentActivity, and the xml file contains:
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="250dp"
android:name="com.google.android.gms.maps.SupportMapFragment" />
But when I run I get the error:
01-20 11:58:31.535: ERROR/AndroidRuntime(5389): FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:279)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
at android.app.Activity.setContentView(Activity.java:1835)
at com.yedidyak.gpsalarm.AddAlarm.onCreate(AddAlarm.java:19)
at android.app.Activity.performCreate(Activity.java:4465)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
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:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
All the information I can find about this error is about not having the google-play-lib properly installed both as a jar and an imported module, but I have that done - and a working map in another activity.
Any ideas?
You have to reference google play services library instead of adding jar and map_attrs.xml (and other files, like strings.xml) to your project.
If you do, you also might have deleted res/values/map_attrs.xml by accident.
I'm using ActionBarSherlock and customized style for it:
<?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">
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="center"
android:textColor="#color/grey"
android:id="#+id/bar_title"
style="#style/Text.Medium">
</TextView>
</LinearLayout>
View mActionBarView = getLayoutInflater().inflate(R.layout.action_bar_custom, null);
getSupportActionBar().setCustomView(mActionBarView);
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_SHOW_HOME);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
In my activity I am overriding setTitle method:
#Override
public void setTitle(CharSequence title) {
TextView txt = (TextView) findViewById(R.id.bar_title);
txt.setText(title);
}
But when in fragment I call getActivity().setTitle(), variable txt in overrided setTitle equals to null.
What's the problem?
Log:
09-06 18:18:21.807: ERROR/AndroidRuntime(953): FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.alwx.reader/com.alwx.reader.activity.BookActivity}: android.view.InflateException: Binary XML file line #10: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
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: android.view.InflateException: Binary XML file line #10: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
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 android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
at com.actionbarsherlock.internal.ActionBarSherlockNative.setContentView(ActionBarSherlockNative.java:119)
at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SherlockFragmentActivity.java:251)
at com.alwx.reader.activity.BookActivity.onCreate(BookActivity.java:19)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
... 11 more
Caused by: java.lang.NullPointerException
at com.alwx.reader.activity.BookActivity.setTitle(BookActivity.java:28)
at com.alwx.reader.fragment.BookFragment.onCreateView(BookFragment.java:52)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:846)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1061)
at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1160)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
... 22 more
//this will work
TextView txt = (TextView)mActionBarView. findViewById(R.id.bar_title);
txt.setText(title);
//there is no default style as Text.Medium. you are created change it
style="#android:style/TextAppearance.Medium"