I just started using fragments on android and im having really bad time trying to start
a map fragment (on a full screen) inside a fragment activity - I have tried e-v-e-r-y-t-h-i-n-g -
1. Myproject>Android tools>Add support library
2. Adding the support and google play services as jar \ libs
3. restarting ecipse
nothing seem to help...
the attached is my logcat output -
09-27 20:49:09.421: E/AndroidRuntime(11714): FATAL EXCEPTION: main
09-27 20:49:09.421: E/AndroidRuntime(11714): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.telofun/com.telofun.FragmentMap}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
09-27 20:49:09.421: E/AndroidRuntime(11714): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1872)
09-27 20:49:09.421: E/AndroidRuntime(11714): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1893)
09-27 20:49:09.421: E/AndroidRuntime(11714): at android.app.ActivityThread.access$1500(ActivityThread.java:135)
09-27 20:49:09.421: E/AndroidRuntime(11714): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1054)
09-27 20:49:09.421: E/AndroidRuntime(11714): at android.os.Handler.dispatchMessage(Handler.java:99)
09-27 20:49:09.421: E/AndroidRuntime(11714): at android.os.Looper.loop(Looper.java:150)
09-27 20:49:09.421: E/AndroidRuntime(11714): at android.app.ActivityThread.main(ActivityThread.java:4385)
09-27 20:49:09.421: E/AndroidRuntime(11714): at java.lang.reflect.Method.invokeNative(Native Method)
09-27 20:49:09.421: E/AndroidRuntime(11714): at java.lang.reflect.Method.invoke(Method.java:507)
09-27 20:49:09.421: E/AndroidRuntime(11714): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
09-27 20:49:09.421: E/AndroidRuntime(11714): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
09-27 20:49:09.421: E/AndroidRuntime(11714): at dalvik.system.NativeStart.main(Native Method)
09-27 20:49:09.421: E/AndroidRuntime(11714): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
09-27 20:49:09.421: E/AndroidRuntime(11714): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:587)
09-27 20:49:09.421: E/AndroidRuntime(11714): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
09-27 20:49:09.421: E/AndroidRuntime(11714): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
09-27 20:49:09.421: E/AndroidRuntime(11714): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
09-27 20:49:09.421: E/AndroidRuntime(11714): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
09-27 20:49:09.421: E/AndroidRuntime(11714): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:250)
09-27 20:49:09.421: E/AndroidRuntime(11714): at android.app.Activity.setContentView(Activity.java:1742)
09-27 20:49:09.421: E/AndroidRuntime(11714): at com.telofun.FragmentMap.onCreate(FragmentMap.java:23)
09-27 20:49:09.421: E/AndroidRuntime(11714): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072)
09-27 20:49:09.421: E/AndroidRuntime(11714): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1836)
09-27 20:49:09.421: E/AndroidRuntime(11714): ... 11 more
09-27 20:49:09.421: E/AndroidRuntime(11714): Caused by: android.support.v4.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
09-27 20:49:09.421: E/AndroidRuntime(11714): at android.support.v4.app.Fragment.instantiate(Fragment.java:409)
09-27 20:49:09.421: E/AndroidRuntime(11714): at android.support.v4.app.Fragment.instantiate(Fragment.java:377)
09-27 20:49:09.421: E/AndroidRuntime(11714): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:277)
09-27 20:49:09.421: E/AndroidRuntime(11714): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
09-27 20:49:09.421: E/AndroidRuntime(11714): ... 20 more
09-27 20:49:09.421: E/AndroidRuntime(11714): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.MapFragment in loader dalvik.system.PathClassLoader[/data/app/com.telofun-1.apk]
09-27 20:49:09.421: E/AndroidRuntime(11714): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
09-27 20:49:09.421: E/AndroidRuntime(11714): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
09-27 20:49:09.421: E/AndroidRuntime(11714): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
09-27 20:49:09.421: E/AndroidRuntime(11714): at android.support.v4.app.Fragment.instantiate(Fragment.java:399)
that is the layout -
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<fragment
android:id="#+id/map"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
class="com.google.android.gms.maps.MapFragment" />
</RelativeLayout>
And the code -
package com.telofun;
import android.app.Dialog;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.Marker;
public class FragmentMap extends FragmentActivity {
GoogleMap googleMap;
Marker marker = null;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_map);
// Getting Google Play availability status
int status = GooglePlayServicesUtil
.isGooglePlayServicesAvailable(getBaseContext());
// Showing status
if (status != ConnectionResult.SUCCESS) { // Google Play Services are
// not available
int requestCode = 10;
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this,
requestCode);
dialog.show();
} else { // Google Play Services are available
// Getting reference to the SupportMapFragment of activity_main.xml
SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
// Getting GoogleMap object from the fragment
googleMap = fm.getMap();
}
}
}
Change this
class="com.google.android.gms.maps.MapFragment"
to
class="com.google.android.gms.maps.SupportMapFragment"
Make sure you have referenced google play services library project properly.
As Raghunandan says change the MapFragment for SupportMapFragment. But I think it is not that simple. I had the same error and tried like 6 tutorials, and read all the documentation from google. And finnally I've got it running and displaying the map. This is how it works for me.
1.Remove the libraries google-play-services and android support-v4 from both your eclipse and your PC. 2.Download again it from de sdk-manager. 3.Follow the instructions [here] (https://developers.google.com/maps/documentation/android/intro#sample_code) go to Sample Code and do as it says. Check specially this Existing Android Code Into Workspace , do not import the libraries as projects, they won't work. 4.Change all your MapFragment for SupportMapFragment, don't foget to extend your Actvity to FragmentActivity (that was my fail). 5.Disable (if it is enabled) the build automatically option from your project. 6.Clean the project. 5.Enable the build automatically option.
It should work.
If it works but the maps don't show you should go to the API consolo and turn on the Google Android Maps v2 and turn off the Google Maps v2.
Hope you can fix it!
Related
I'm trying to get the sample code of Android 'Google Maps Android API v2' working. I get the project built without errors. However, when I try to run the app in Everpad device , the app crashes immediately.
here is :
- The java code
package com.dvp.android.gallery;
public class GPS extends Activity {
static final LatLng HAMBURG = new LatLng(53.558, 9.927);
static final LatLng KIEL = new LatLng(53.551, 9.993);
private GoogleMap map;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.gps);
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
Marker hamburg = map.addMarker(new MarkerOptions().position(HAMBURG)
.title("Hamburg"));
Marker kiel = map.addMarker(new MarkerOptions().position(KIEL).title("Kiel").snippet("Kiel is cool").icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_launcher)));
// Move the camera instantly to hamburg with a zoom of 15.
map.moveCamera(CameraUpdateFactory.newLatLngZoom(HAMBURG, 15));
// Zoom in, animating the camera.
map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
}
}
The Manifest:
<application android:icon="#drawable/ic_bardo" android:label="#string/app_name">
<activity android:name=".Acceuil"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Objets" android:label="Objets"> </activity>
<activity android:name=".GPS"
android:label="GPS">
</activity>
<activity android:name=".Detail" android:label="Detail"></activity>
<activity
android:name=".Galeries"
android:label="Galeries"
/>
<activity
android:name=".Evennements"
android:label="Evennements"/>
<activity
android:name=".Infos"
android:label="Infos"/>
</application>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyA0HMTTGLqlYaq6jOuS0imbjt7GmUHyK0c"/>
<uses-sdk android:minSdkVersion="11" />
<uses-permission android:name="com.dvp.android.gallery.maps.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/>
<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" />
</manifest>
The logcat output:
09-27 12:42:49.466: E/AndroidRuntime(5542): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dvp.android.gallery/com.dvp.android.gallery.GPS}: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
09-27 12:42:49.466: E/AndroidRuntime(5542): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
09-27 12:42:49.466: E/AndroidRuntime(5542): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
09-27 12:42:49.466: E/AndroidRuntime(5542): at android.app.ActivityThread.access$600(ActivityThread.java:123)
09-27 12:42:49.466: E/AndroidRuntime(5542): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
09-27 12:42:49.466: E/AndroidRuntime(5542): at android.os.Handler.dispatchMessage(Handler.java:99)
09-27 12:42:49.466: E/AndroidRuntime(5542): at android.os.Looper.loop(Looper.java:137)
09-27 12:42:49.466: E/AndroidRuntime(5542): at android.app.ActivityThread.main(ActivityThread.java:4429)
09-27 12:42:49.466: E/AndroidRuntime(5542): at java.lang.reflect.Method.invokeNative(Native Method)
09-27 12:42:49.466: E/AndroidRuntime(5542): at java.lang.reflect.Method.invoke(Method.java:511)
09-27 12:42:49.466: E/AndroidRuntime(5542): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
09-27 12:42:49.466: E/AndroidRuntime(5542): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
09-27 12:42:49.466: E/AndroidRuntime(5542): at dalvik.system.NativeStart.main(Native Method)
09-27 12:42:49.466: E/AndroidRuntime(5542): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
09-27 12:42:49.466: E/AndroidRuntime(5542): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
09-27 12:42:49.466: E/AndroidRuntime(5542): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
09-27 12:42:49.466: E/AndroidRuntime(5542): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
09-27 12:42:49.466: E/AndroidRuntime(5542): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
09-27 12:42:49.466: E/AndroidRuntime(5542): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
09-27 12:42:49.466: E/AndroidRuntime(5542): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
09-27 12:42:49.466: E/AndroidRuntime(5542): at android.app.Activity.setContentView(Activity.java:1835)
09-27 12:42:49.466: E/AndroidRuntime(5542): at com.dvp.android.gallery.GPS.onCreate(GPS.java:23)
09-27 12:42:49.466: E/AndroidRuntime(5542): at android.app.Activity.performCreate(Activity.java:4465)
09-27 12:42:49.466: E/AndroidRuntime(5542): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
09-27 12:42:49.466: E/AndroidRuntime(5542): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
09-27 12:42:49.466: E/AndroidRuntime(5542): ... 11 more
09-27 12:42:49.466: E/AndroidRuntime(5542): Caused by: java.lang.RuntimeException: API key not found. Check that is in the element of AndroidManifest.xml
09-27 12:42:49.466: E/AndroidRuntime(5542): at maps.ag.bb.a(Unknown Source)
09-27 12:42:49.466: E/AndroidRuntime(5542): at maps.ag.bb.a(Unknown Source)
09-27 12:42:49.466: E/AndroidRuntime(5542): at maps.ag.an.a(Unknown Source)
09-27 12:42:49.466: E/AndroidRuntime(5542): at maps.ag.bh.a(Unknown Source)
09-27 12:42:49.466: E/AndroidRuntime(5542): at maps.ag.bg.a(Unknown Source)
09-27 12:42:49.466: E/AndroidRuntime(5542): at bob.onTransact(SourceFile:107)
09-27 12:42:49.466: E/AndroidRuntime(5542): at android.os.Binder.transact(Binder.java:297)
09-27 12:42:49.466: E/AndroidRuntime(5542): at com.google.android.gms.maps.internal.IMapFragmentDelegate$a$a.onCreateView(Unknown Source)
09-27 12:42:49.466: E/AndroidRuntime(5542): at com.google.android.gms.maps.MapFragment$a.onCreateView(Unknown Source)
09-27 12:42:49.466: E/AndroidRuntime(5542): at com.google.android.gms.dynamic.a$4.b(Unknown Source)
09-27 12:42:49.466: E/AndroidRuntime(5542): at com.google.android.gms.dynamic.a.a(Unknown Source)
09-27 12:42:49.466: E/AndroidRuntime(5542): at com.google.android.gms.dynamic.a.onCreateView(Unknown Source)
09-27 12:42:49.466: E/AndroidRuntime(5542): at com.google.android.gms.maps.MapFragment.onCreateView(Unknown Source)
09-27 12:42:49.466: E/AndroidRuntime(5542): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:806)
09-27 12:42:49.466: E/AndroidRuntime(5542): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1010)
09-27 12:42:49.466: E/AndroidRuntime(5542): at android.app.FragmentManagerImpl.addFragment(FragmentManager.java:1108)
the XML :
<LinearLayout 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"
android:orientation="vertical"
tools:context=".GPS" >
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment" />
</LinearLayout>
Please help me . thanks
you just have to make your Activity extend FragmentActivity instead of Activity
This is because Google Map class has a fragment and for that you have to import android.support.v4. jar file... And add a map to your layout as a fragment you need to extends with FragmentActivity
I have an ActionBar implemented as well as a SearchView widget in my app. It works just fine on the Nexus 7, HTC Sensation, etc. - anywhere where the Android version is older than 3.0 I believe. But it doesn't run on the phone with the Android 2.3.5.
Is there anyway to "not display" the action bar and other unsupported stuff when the program runs on the old device?
Here is the error log I get when run in on my old device, sorry for the length, don't really understand which bit is useful:
09-27 12:15:03.008: I/dalvikvm(824): Failed resolving Lcom/example/stroke/handling/MainActivity; interface 407 'Landroid/widget/SearchView$OnQueryTextListener;'
09-27 12:15:03.008: W/dalvikvm(824): Link of class 'Lcom/example/stroke/handling/MainActivity;' failed
09-27 12:15:03.008: D/AndroidRuntime(824): Shutting down VM
09-27 12:15:03.008: W/dalvikvm(824): threadid=1: thread exiting with uncaught exception (group=0x400205a0)
09-27 12:15:03.018: E/AndroidRuntime(824): FATAL EXCEPTION: main
09-27 12:15:03.018: E/AndroidRuntime(824): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.stroke.handling/com.example.stroke.handling.MainActivity}: java.lang.ClassNotFoundException: com.example.stroke.handling.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.stroke.handling-1.apk]
09-27 12:15:03.018: E/AndroidRuntime(824): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1743)
09-27 12:15:03.018: E/AndroidRuntime(824): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1851)
09-27 12:15:03.018: E/AndroidRuntime(824): at android.app.ActivityThread.access$1500(ActivityThread.java:132)
09-27 12:15:03.018: E/AndroidRuntime(824): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038)
09-27 12:15:03.018: E/AndroidRuntime(824): at android.os.Handler.dispatchMessage(Handler.java:99)
09-27 12:15:03.018: E/AndroidRuntime(824): at android.os.Looper.loop(Looper.java:150)
09-27 12:15:03.018: E/AndroidRuntime(824): at android.app.ActivityThread.main(ActivityThread.java:4277)
09-27 12:15:03.018: E/AndroidRuntime(824): at java.lang.reflect.Method.invokeNative(Native Method)
09-27 12:15:03.018: E/AndroidRuntime(824): at java.lang.reflect.Method.invoke(Method.java:507)
09-27 12:15:03.018: E/AndroidRuntime(824): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-27 12:15:03.018: E/AndroidRuntime(824): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
09-27 12:15:03.018: E/AndroidRuntime(824): at dalvik.system.NativeStart.main(Native Method)
09-27 12:15:03.018: E/AndroidRuntime(824): Caused by: java.lang.ClassNotFoundException: com.example.stroke.handling.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.stroke.handling-1.apk]
09-27 12:15:03.018: E/AndroidRuntime(824): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
09-27 12:15:03.018: E/AndroidRuntime(824): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
09-27 12:15:03.018: E/AndroidRuntime(824): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
09-27 12:15:03.018: E/AndroidRuntime(824): at android.app.Instrumentation.newActivity(Instrumentation.java:1040)
09-27 12:15:03.018: E/AndroidRuntime(824): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1735)
09-27 12:15:03.018: E/AndroidRuntime(824): ... 11 more
P.S. I don't want to use ActionBarSherlock!
Oopsie,
Remaining backward-compatible
If you want to provide an action bar in your application and remain
compatible with versions of Android older than 3.0, you need to create
the action bar in your activity's layout (because the ActionBar class
is not available on older versions).
To help you, the Action Bar Compatibility sample app provides an API
layer and action bar layout that allows your app to use some of the
ActionBar APIs and also support older versions of Android by replacing
the traditional title bar with a custom action bar layout.
Is it the answer to my question?
Edit: that sample app is shit.
You can check current os version and run code which is supported e.g.
if(android.os.Build.VERSION.SDK_INT < 11){
// use api available only in sdk < 11
}else{
// use api available in sdk 11
}
You can use
http://actionbarsherlock.com/
and add support library to your project, then the action bar will work on 1.6 and above
This is to inform you that, you should use Action Bar Sherlock for the same. It is very awesome feature/library provided by the John Watson.
And do refer to this slide share tutorial. It will definitely help you.
Let me know if you have any further queries regarding Action Bar Sherlock.
Thanks
You just need to add android-support-v7-appcompat.jar
Then use "android.support.v7.widget.SearchView"
http://developer.android.com/reference/android/support/v7/widget/SearchView.html
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mapsandgps"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<uses-library android:name="com.google.android.maps"/>
<activity
android:name=".Maps"
android:label="#string/title_activity_maps" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
i added also android api key but when program runs i get error
09-27 21:03:48.468: E/AndroidRuntime(215): Uncaught handler: thread main exiting due to uncaught exception
09-27 21:03:48.576: E/AndroidRuntime(215): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mapsandgps/com.example.mapsandgps.Maps}: android.view.InflateException: Binary XML file line #2: Error inflating class com.google.android.maps.MapView
09-27 21:03:48.576: E/AndroidRuntime(215): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
09-27 21:03:48.576: E/AndroidRuntime(215): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
09-27 21:03:48.576: E/AndroidRuntime(215): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
09-27 21:03:48.576: E/AndroidRuntime(215): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
09-27 21:03:48.576: E/AndroidRuntime(215): at android.os.Handler.dispatchMessage(Handler.java:99)
09-27 21:03:48.576: E/AndroidRuntime(215): at android.os.Looper.loop(Looper.java:123)
09-27 21:03:48.576: E/AndroidRuntime(215): at android.app.ActivityThread.main(ActivityThread.java:4363)
09-27 21:03:48.576: E/AndroidRuntime(215): at java.lang.reflect.Method.invokeNative(Native Method)
09-27 21:03:48.576: E/AndroidRuntime(215): at java.lang.reflect.Method.invoke(Method.java:521)
09-27 21:03:48.576: E/AndroidRuntime(215): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
09-27 21:03:48.576: E/AndroidRuntime(215): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
09-27 21:03:48.576: E/AndroidRuntime(215): at dalvik.system.NativeStart.main(Native Method)
09-27 21:03:48.576: E/AndroidRuntime(215): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class com.google.android.maps.MapView
09-27 21:03:48.576: E/AndroidRuntime(215): at android.view.LayoutInflater.createView(LayoutInflater.java:513)
09-27 21:03:48.576: E/AndroidRuntime(215): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
09-27 21:03:48.576: E/AndroidRuntime(215): at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
09-27 21:03:48.576: E/AndroidRuntime(215): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
09-27 21:03:48.576: E/AndroidRuntime(215): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
09-27 21:03:48.576: E/AndroidRuntime(215): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
09-27 21:03:48.576: E/AndroidRuntime(215): at android.app.Activity.setContentView(Activity.java:1622)
09-27 21:03:48.576: E/AndroidRuntime(215): at com.example.mapsandgps.Maps.onCreate(Maps.java:24)
09-27 21:03:48.576: E/AndroidRuntime(215): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-27 21:03:48.576: E/AndroidRuntime(215): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
09-27 21:03:48.576: E/AndroidRuntime(215): ... 11 more
09-27 21:03:48.576: E/AndroidRuntime(215): Caused by: java.lang.reflect.InvocationTargetException
09-27 21:03:48.576: E/AndroidRuntime(215): at com.google.android.maps.MapView.(MapView.java:237)
09-27 21:03:48.576: E/AndroidRuntime(215): at java.lang.reflect.Constructor.constructNative(Native Method)
09-27 21:03:48.576: E/AndroidRuntime(215): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
09-27 21:03:48.576: E/AndroidRuntime(215): at android.view.LayoutInflater.createView(LayoutInflater.java:500)
09-27 21:03:48.576: E/AndroidRuntime(215): ... 20 more
09-27 21:03:48.576: E/AndroidRuntime(215): Caused by: java.lang.IllegalArgumentException: You need to specify an API Key for each MapView. See the MapView documentation for details.
09-27 21:03:48.576: E/AndroidRuntime(215): at com.google.android.maps.MapView.(MapView.java:273)
09-27 21:03:48.576: E/AndroidRuntime(215): at com.google.android.maps.MapView.(MapView.java:254)
09-27 21:03:48.576: E/AndroidRuntime(215): ... 24 more
09-27 21:03:48.786: E/dalvikvm(215): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
you are probably trying to run the application in an incorrect version of target API on your virtual machine:
Select a target version that shows "Google APIs" in the beginig of the name-
good luck.
You are missing things in your manifest:
1) Permissions required by Google Maps (in <manifest>):
<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"/>
2) Meta data, last elements of <application> (ie after activities and services):
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="your_api_key_goes_here" />
Refer to this documentation for further instruction.
I am a new android developer and currently I am trying to implement JSIP in andorid. when I add jsip api in andorid, an error show me that jsip's javax package conflicts with java's default javax package.
So I have changed all javax package to com.g5.javax.* this format. then the error goes off. but now another error came up which I attached with this message. it throws me java.lang.reflect.InvocationTargetException with javax.sip.PeerUnavailableException: stack name is missing error. I've checked and double checked the jain sip source and found that the properties key "com.g5.javax.sip.STACK_NAME"(changed by refactoring using eclipse) has the value which I 've given. but the error came up each time. another interesting information is the same jar package which I 've created works perfectly in desktop application. I've stuck with this error for 2 days.
09-27 04:58:13.819: I/System.out(564): class java.util.Properties
09-27 04:58:13.839: I/System.out(564): {com.g5.javax.sip.STACK_NAME=123}
09-27 04:58:13.869: E/com.g5(564): cannot instantiate
09-27 04:58:13.869: E/com.g5(564): com.g5.javax.sip.PeerUnavailableException: The Peer SIP Stack: gov.nist.javax.sip.SipStackImpl could not be instantiated. Ensure the Path Name has been set.
09-27 04:58:13.869: E/com.g5(564): at com.g5.javax.sip.SipFactory.createStack(SipFactory.java:332)
09-27 04:58:13.869: E/com.g5(564): at com.g5.javax.sip.SipFactory.createSipStack(SipFactory.java:154)
09-27 04:58:13.869: E/com.g5(564): at com.shootme.Shootme.init(Shootme.java:104)
09-27 04:58:13.869: E/com.g5(564): at com.shootme.Shootme.onCreate(Shootme.java:87)
09-27 04:58:13.869: E/com.g5(564): at android.app.Activity.performCreate(Activity.java:4465)
09-27 04:58:13.869: E/com.g5(564): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
09-27 04:58:13.869: E/com.g5(564): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
09-27 04:58:13.869: E/com.g5(564): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
09-27 04:58:13.869: E/com.g5(564): at android.app.ActivityThread.access$600(ActivityThread.java:123)
09-27 04:58:13.869: E/com.g5(564): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
09-27 04:58:13.869: E/com.g5(564): at android.os.Handler.dispatchMessage(Handler.java:99)
09-27 04:58:13.869: E/com.g5(564): at android.os.Looper.loop(Looper.java:137)
09-27 04:58:13.869: E/com.g5(564): at android.app.ActivityThread.main(ActivityThread.java:4424)
09-27 04:58:13.869: E/com.g5(564): at java.lang.reflect.Method.invokeNative(Native Method)
09-27 04:58:13.869: E/com.g5(564): at java.lang.reflect.Method.invoke(Method.java:511)
09-27 04:58:13.869: E/com.g5(564): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-27 04:58:13.869: E/com.g5(564): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-27 04:58:13.869: E/com.g5(564): at dalvik.system.NativeStart.main(Native Method)
09-27 04:58:13.869: E/com.g5(564): Caused by: java.lang.reflect.InvocationTargetException
09-27 04:58:13.869: E/com.g5(564): at java.lang.reflect.Constructor.constructNative(Native Method)
09-27 04:58:13.869: E/com.g5(564): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
09-27 04:58:13.869: E/com.g5(564): at com.g5.javax.sip.SipFactory.createStack(SipFactory.java:322)
09-27 04:58:13.869: E/com.g5(564): ... 17 more
09-27 04:58:13.869: E/com.g5(564): Caused by: javax.sip.PeerUnavailableException: stack name is missing
09-27 04:58:13.869: E/com.g5(564): at gov.nist.javax.sip.SipStackImpl.<init>(SipStackImpl.java:554)
I'm also having the same problem, so I tried to dig a bit deeper, as the error on the implementation of the stack isn't being reported. From this i got this error:
11-11 18:51:01.025: W/System.err(17454): javax.sip.PeerUnavailableException: stack name is missing
11-11 18:51:01.025: W/System.err(17454): at gov.nist.javax.sip.SipStackImpl.<init>(SipStackImpl.java:554)
11-11 18:51:01.025: W/System.err(17454): at not.javax.sip.SipFactory.createStack(SipFactory.java:322)
11-11 18:51:01.025: W/System.err(17454): at not.javax.sip.SipFactory.createSipStack(SipFactory.java:171)
11-11 18:51:01.025: W/System.err(17454): at org.jaintest.MainActivity.init(MainActivity.java:110)
11-11 18:51:01.025: W/System.err(17454): at org.jaintest.MainActivity.onCreate(MainActivity.java:68)
11-11 18:51:01.025: W/System.err(17454): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-11 18:51:01.025: W/System.err(17454): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
11-11 18:51:01.025: W/System.err(17454): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
11-11 18:51:01.025: W/System.err(17454): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-11 18:51:01.025: W/System.err(17454): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
11-11 18:51:01.025: W/System.err(17454): at android.os.Handler.dispatchMessage(Handler.java:99)
11-11 18:51:01.025: W/System.err(17454): at android.os.Looper.loop(Looper.java:123)
11-11 18:51:01.025: W/System.err(17454): at android.app.ActivityThread.main(ActivityThread.java:3691)
11-11 18:51:01.025: W/System.err(17454): at java.lang.reflect.Method.invokeNative(Native Method)
11-11 18:51:01.025: W/System.err(17454): at java.lang.reflect.Method.invoke(Method.java:507)
11-11 18:51:01.025: W/System.err(17454): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
11-11 18:51:01.025: W/System.err(17454): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
11-11 18:51:01.025: W/System.err(17454): at dalvik.system.NativeStart.main(Native Method)
Now heres the problem. I looked at the code for the SipStackImpl class and found these lines:
String name = configurationProperties
.getProperty("com.tlccom.javax.sip.STACK_NAME");
if (name == null)
throw new PeerUnavailableException("stack name is missing");
So it means the name isn't being picked up. So i gave the name a string value, but still got the error, which leads me to belive that the SipStackImpl is being picked up from somewhere else. Problem is I've no idea where, I've searched the whole project for that error and thats the only place it exists, so it must be coming from somewhere (even commenting out the error detection still leaves the error). Thats where I'm stuck right now, hope this helps, if you find anything extra let me know
Just finished it to work on Android 4.4.2.
The first thing I believe is to do what you did. You changed the javax name space to something else: whatever.javax.*, for example.
Then I had the same problem Martin mentioned in his answer, and I'm thankful for his words here on SO. It looks like the gov.nist name space is also present somewhere else at runtime. So what I did was: changed the gov.nist.* name space to gov.nist.whatever as well (and all the references to it, off course).
Also, you'll need to provide the property "gov.nist.whatever.javax.sip.STACK_NAME" somewhere. You can do that using:
Properties properties = new Properties();
properties.setProperty("sipper.sip.STACK_NAME", "stack");
somewhere in the app, as pointed out by Mike in this answer.
After all that I had problems with a NoClassFoundError exception with the org.apache.log4j.Logger class, even with the respective jars in my classpath. So I moved all the jars from the "asset" project directory to a new one called "libs". Reconfigured my project's classpath with the new directory scheme, and it worked like a charm (OK, no overstatements).
You need to set a name in the properties for the key javax.sip.STACK_NAME
properties.setProperty("javax.sip.STACK_NAME", "myStack");
I have the following code in an activity to send the user to a different application:
public void goBack(View v) {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName("com.example.android.lifecycle", "com.example.android.lifecycle.DialogActivity"));
startActivity(intent);
}
The manifest file for the application is:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.lifecycle"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15" />
<application android:label="#string/app_name"
android:icon="#drawable/ic_launcher">
<activity android:name=".ActivityA"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="com.example.android.lifecycle" />
</intent-filter>
</activity>
<activity android:name=".ActivityB" />
<activity android:name=".ActivityC" />
<activity android:name=".DialogActivity"
android:theme="#android:style/Theme.Dialog">
<action android:name="com.example.android.lifecycle" />
<action android:name="android.intent.action.MAIN" />
</activity>
</application>
</manifest>
However, when I click on the button which should send me to the new application, I get a message saying - The application has stopped unexpectedly. Please try again.
What am I doing wrong and how can I rectify this?
Thanks!!
09-27 14:08:42.763: E/AndroidRuntime(286): FATAL EXCEPTION: main
09-27 14:08:42.763: E/AndroidRuntime(286): java.lang.IllegalStateException: Could not execute method of the activity
09-27 14:08:42.763: E/AndroidRuntime(286): at android.view.View$1.onClick(View.java:2072)
09-27 14:08:42.763: E/AndroidRuntime(286): at android.view.View.performClick(View.java:2408)
09-27 14:08:42.763: E/AndroidRuntime(286): at android.view.View$PerformClick.run(View.java:8816)
09-27 14:08:42.763: E/AndroidRuntime(286): at android.os.Handler.handleCallback(Handler.java:587)
09-27 14:08:42.763: E/AndroidRuntime(286): at android.os.Handler.dispatchMessage(Handler.java:92)
09-27 14:08:42.763: E/AndroidRuntime(286): at android.os.Looper.loop(Looper.java:123)
09-27 14:08:42.763: E/AndroidRuntime(286): at android.app.ActivityThread.main(ActivityThread.java:4627)
09-27 14:08:42.763: E/AndroidRuntime(286): at java.lang.reflect.Method.invokeNative(Native Method)
09-27 14:08:42.763: E/AndroidRuntime(286): at java.lang.reflect.Method.invoke(Method.java:521)
09-27 14:08:42.763: E/AndroidRuntime(286): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-27 14:08:42.763: E/AndroidRuntime(286): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-27 14:08:42.763: E/AndroidRuntime(286): at dalvik.system.NativeStart.main(Native Method)
09-27 14:08:42.763: E/AndroidRuntime(286): Caused by: java.lang.reflect.InvocationTargetException
09-27 14:08:42.763: E/AndroidRuntime(286): at com.example.myfirstapp.DisplayMessageActivity.goBack(DisplayMessageActivity.java:30)
09-27 14:08:42.763: E/AndroidRuntime(286): at java.lang.reflect.Method.invokeNative(Native Method)
09-27 14:08:42.763: E/AndroidRuntime(286): at java.lang.reflect.Method.invoke(Method.java:521)
09-27 14:08:42.763: E/AndroidRuntime(286): at android.view.View$1.onClick(View.java:2067)
09-27 14:08:42.763: E/AndroidRuntime(286): ... 11 more
09-27 14:08:42.763: E/AndroidRuntime(286): Caused by: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cmp=com.example.android.lifecycle/.DialogActivity } from ProcessRecord{450fce58 286:com.example.myfirstapp/10044} (pid=286, uid=10044) requires null
09-27 14:08:42.763: E/AndroidRuntime(286): at android.os.Parcel.readException(Parcel.java:1247)
09-27 14:08:42.763: E/AndroidRuntime(286): at android.os.Parcel.readException(Parcel.java:1235)
09-27 14:08:42.763: E/AndroidRuntime(286): at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1298)
09-27 14:08:42.763: E/AndroidRuntime(286): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1373)
09-27 14:08:42.763: E/AndroidRuntime(286): at android.app.Activity.startActivityForResult(Activity.java:2817)
09-27 14:08:42.763: E/AndroidRuntime(286): at android.app.Activity.startActivity(Activity.java:2923)
09-27 14:08:42.763: E/AndroidRuntime(286): ... 15 more
Add Intent.FLAG_ACTIVITY_NEW_TASK and Intent.FLAG_FROM_BACKGROUND flags with intent if you are starting New Application from Background as:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setComponent(new ComponentName( "com.example.android.lifecycle","com.example.android.lifecycle.DialogActivity"));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setFlags(Intent.FLAG_FROM_BACKGROUND);
startActivity(intent);
I think in manifest file under activity android:name=".DialogActivity", the name should be
action android:name="com.example.android.lifecycle.DialogActivity"
Can you try?