I am doing a simple project using google maps. My project is running fine in my mobile. But i can not run in emulator. When i try to execute the following error is showing..
11-23 12:50:44.187: E/AndroidRuntime(3128): FATAL EXCEPTION: main
11-23 12:50:44.187: E/AndroidRuntime(3128): Process: info.android.googlemapsv2, PID: 3128
11-23 12:50:44.187: E/AndroidRuntime(3128): java.lang.RuntimeException: Unable to resume activity {info.android.googlemapsv2/info.android.slidingmenu.SlideActivity}: java.lang.NullPointerException
11-23 12:50:44.187: E/AndroidRuntime(3128): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2788)
11-23 12:50:44.187: E/AndroidRuntime(3128): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2817)
11-23 12:50:44.187: E/AndroidRuntime(3128): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250)
11-23 12:50:44.187: E/AndroidRuntime(3128): at android.app.ActivityThread.access$800(ActivityThread.java:135)
11-23 12:50:44.187: E/AndroidRuntime(3128): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
11-23 12:50:44.187: E/AndroidRuntime(3128): at android.os.Handler.dispatchMessage(Handler.java:102)
11-23 12:50:44.187: E/AndroidRuntime(3128): at android.os.Looper.loop(Looper.java:136)
11-23 12:50:44.187: E/AndroidRuntime(3128): at android.app.ActivityThread.main(ActivityThread.java:5017)
11-23 12:50:44.187: E/AndroidRuntime(3128): at java.lang.reflect.Method.invokeNative(Native Method)
11-23 12:50:44.187: E/AndroidRuntime(3128): at java.lang.reflect.Method.invoke(Method.java:515)
11-23 12:50:44.187: E/AndroidRuntime(3128): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
11-23 12:50:44.187: E/AndroidRuntime(3128): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
11-23 12:50:44.187: E/AndroidRuntime(3128): at dalvik.system.NativeStart.main(Native Method)
11-23 12:50:44.187: E/AndroidRuntime(3128): Caused by: java.lang.NullPointerException
11-23 12:50:44.187: E/AndroidRuntime(3128): at com.tracker.newmaps.MainActivityNew.GetLocaion(MainActivityNew.java:210)
11-23 12:50:44.187: E/AndroidRuntime(3128): at com.tracker.newmaps.MainActivityNew.onResume(MainActivityNew.java:300)
11-23 12:50:44.187: E/AndroidRuntime(3128): at android.app.Fragment.performResume(Fragment.java:1743)
11-23 12:50:44.187: E/AndroidRuntime(3128): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:924)
11-23 12:50:44.187: E/AndroidRuntime(3128): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
11-23 12:50:44.187: E/AndroidRuntime(3128): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1044)
11-23 12:50:44.187: E/AndroidRuntime(3128): at android.app.FragmentManagerImpl.dispatchResume(FragmentManager.java:1863)
11-23 12:50:44.187: E/AndroidRuntime(3128): at android.app.Activity.performResume(Activity.java:5320)
11-23 12:50:44.187: E/AndroidRuntime(3128): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2778)
11-23 12:50:44.187: E/AndroidRuntime(3128): ... 12 more
I am using Google APIs x86(Google Inc.) Target api, and emulator also Google APIs x86(Google Inc.)
Please let me know how to run the project in my emulator.
Maybe in the emulator you don't have Google play services installed. This link could be helpful too.
I have a problem creating an Android app that makes use of both Renderscript and native code generated with NDK.
Substantially, I use NDK tools to generate a library called sprstr_native.so. I managed to call their C++ functions through Java code without problems. Then I needed some Renderscript functionalities (in particular, ScriptIntrinsicYuvToRGB) so I've added to my Eclipse project a reference to the relative support library, renderscript-v8.jar, and this line in the project properties file:
renderscript.support.mode=true
Now the problem: Android can't recognize my sprstr_native anymore and the app crashes when calling the code:
System.loadLibrary("sprstr_native");
This is the stack:
11-23 17:46:54.450: E/AndroidRuntime(3901): FATAL EXCEPTION: main
11-23 17:46:54.450: E/AndroidRuntime(3901): java.lang.ExceptionInInitializerError
11-23 17:46:54.450: E/AndroidRuntime(3901): at java.lang.Class.newInstanceImpl(Native Method)
11-23 17:46:54.450: E/AndroidRuntime(3901): at java.lang.Class.newInstance(Class.java:1409)
11-23 17:46:54.450: E/AndroidRuntime(3901): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
11-23 17:46:54.450: E/AndroidRuntime(3901): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
11-23 17:46:54.450: E/AndroidRuntime(3901): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
11-23 17:46:54.450: E/AndroidRuntime(3901): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-23 17:46:54.450: E/AndroidRuntime(3901): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
11-23 17:46:54.450: E/AndroidRuntime(3901): at android.os.Handler.dispatchMessage(Handler.java:99)
11-23 17:46:54.450: E/AndroidRuntime(3901): at android.os.Looper.loop(Looper.java:130)
11-23 17:46:54.450: E/AndroidRuntime(3901): at android.app.ActivityThread.main(ActivityThread.java:3683)
11-23 17:46:54.450: E/AndroidRuntime(3901): at java.lang.reflect.Method.invokeNative(Native Method)
11-23 17:46:54.450: E/AndroidRuntime(3901): at java.lang.reflect.Method.invoke(Method.java:507)
11-23 17:46:54.450: E/AndroidRuntime(3901): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-23 17:46:54.450: E/AndroidRuntime(3901): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-23 17:46:54.450: E/AndroidRuntime(3901): at dalvik.system.NativeStart.main(Native Method)
11-23 17:46:54.450: E/AndroidRuntime(3901): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load sprstr_native: findLibrary returned null
11-23 17:46:54.450: E/AndroidRuntime(3901): at java.lang.Runtime.loadLibrary(Runtime.java:429)
11-23 17:46:54.450: E/AndroidRuntime(3901): at java.lang.System.loadLibrary(System.java:554)
11-23 17:46:54.450: E/AndroidRuntime(3901): at com.lag.proj.MainActivity.<clinit>(MainActivity.java:18)
11-23 17:46:54.450: E/AndroidRuntime(3901): ... 15 more
Curiously, if I delete all the references to Renderscript the native lib turns to work again!
Please don't tell me that there are incompatibilities between Renderscript and NDK code!
I've probably solved it, but not without other errors that came after (see Getting different errors for different platforms using Renderscript Support Library). By the way, the library loading phase should be solved by adding this line on the Application.mk file:
APP_ABI := all
That lets the NDK to compile the objs for all the supported architectures.
I am implementing an app in which i have to use google map and code is as follows:
<com.google.android.maps.MapView
android:id="#+id/mapview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:apiKey="0ACHOtlugQlOpv7OWSc2GYfNmJfYY1ltGNlzgEQ"
android:clickable="true"
android:enabled="true" >
</com.google.android.maps.MapView>
and i got this exception:
11-23 12:50:52.796: I/System.out(24625): android.view.InflateException: Binary XML file line #68: Error inflating class com.google.android.maps.Mapview
11-23 12:28:44.445: E/AndroidRuntime(24124): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
11-23 12:28:44.445: E/AndroidRuntime(24124): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
11-23 12:28:44.445: E/AndroidRuntime(24124): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-23 12:28:44.445: E/AndroidRuntime(24124): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
11-23 12:28:44.445: E/AndroidRuntime(24124): at android.os.Handler.dispatchMessage(Handler.java:99)
11-23 12:28:44.445: E/AndroidRuntime(24124): at android.os.Looper.loop(Looper.java:123)
11-23 12:28:44.445: E/AndroidRuntime(24124): at android.app.ActivityThread.main(ActivityThread.java:3687)
11-23 12:28:44.445: E/AndroidRuntime(24124): at java.lang.reflect.Method.invokeNative(Native Method)
11-23 12:28:44.445: E/AndroidRuntime(24124): at java.lang.reflect.Method.invoke(Method.java:507)
11-23 12:28:44.445: E/AndroidRuntime(24124): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
11-23 12:28:44.445: E/AndroidRuntime(24124): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
11-23 12:28:44.445: E/AndroidRuntime(24124): at dalvik.system.NativeStart.main(Native Method)
11-23 12:28:44.445: E/AndroidRuntime(24124): Caused by: java.lang.NullPointerException
11-23 12:28:44.445: E/AndroidRuntime(24124): at com.trigma.mcs.Outsubmap.onCreate(Outsubmap.java:23)
11-23 12:28:44.445: E/AndroidRuntime(24124): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-23 12:28:44.445: E/AndroidRuntime(24124): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
Did you specify the shared library in manifest file?
<uses-library android:name="com.google.android.maps" />
More info
This was due to mapActivity. Actully i forgot to extend mapactivity and by extending that my code worked.
I am getting a runtimeException with the following code, does anyone know why?
public class FragsApplicationActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
SuggestionFrags class
public class SuggestionFrags extends Fragment{
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
return super.onCreateView(inflater, container, savedInstanceState);
}
}
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<fragment
android:id="#+id/fragment1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
class="com.samplefragsapplication.SuggestionFrags" />
</LinearLayout>
I am getting this exception:
11-23 18:09:23.899: E/AndroidRuntime(2436): FATAL EXCEPTION: main
11-23 18:09:23.899: E/AndroidRuntime(2436): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.samplefragsapplication/com.samplefragsapplication.FragsApplicationActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
11-23 18:09:23.899: E/AndroidRuntime(2436): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
11-23 18:09:23.899: E/AndroidRuntime(2436): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-23 18:09:23.899: E/AndroidRuntime(2436): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-23 18:09:23.899: E/AndroidRuntime(2436): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-23 18:09:23.899: E/AndroidRuntime(2436): at android.os.Handler.dispatchMessage(Handler.java:99)
11-23 18:09:23.899: E/AndroidRuntime(2436): at android.os.Looper.loop(Looper.java:123)
11-23 18:09:23.899: E/AndroidRuntime(2436): at android.app.ActivityThread.main(ActivityThread.java:4627)
11-23 18:09:23.899: E/AndroidRuntime(2436): at java.lang.reflect.Method.invokeNative(Native Method)
11-23 18:09:23.899: E/AndroidRuntime(2436): at java.lang.reflect.Method.invoke(Method.java:521)
11-23 18:09:23.899: E/AndroidRuntime(2436): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-23 18:09:23.899: E/AndroidRuntime(2436): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-23 18:09:23.899: E/AndroidRuntime(2436): at dalvik.system.NativeStart.main(Native Method)
11-23 18:09:23.899: E/AndroidRuntime(2436): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
11-23 18:09:23.899: E/AndroidRuntime(2436): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
11-23 18:09:23.899: E/AndroidRuntime(2436): at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
11-23 18:09:23.899: E/AndroidRuntime(2436): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
11-23 18:09:23.899: E/AndroidRuntime(2436): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
11-23 18:09:23.899: E/AndroidRuntime(2436): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
11-23 18:09:23.899: E/AndroidRuntime(2436): at android.app.Activity.setContentView(Activity.java:1647)
11-23 18:09:23.899: E/AndroidRuntime(2436): at com.samplefragsapplication.FragsApplicationActivity.onCreate(FragsApplicationActivity.java:12)
11-23 18:09:23.899: E/AndroidRuntime(2436): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-23 18:09:23.899: E/AndroidRuntime(2436): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
11-23 18:09:23.899: E/AndroidRuntime(2436): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/data/app/com.samplefragsapplication-2.apk]
11-23 18:09:23.899: E/AndroidRuntime(2436): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
11-23 18:09:23.899: E/AndroidRuntime(2436): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
11-23 18:09:23.899: E/AndroidRuntime(2436): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
11-23 18:09:23.899: E/AndroidRuntime(2436): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
11-23 18:09:23.899: E/AndroidRuntime(2436): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:544)
11-23 18:09:23.899: E/AndroidRuntime(2436): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
11-23 18:09:23.899: E/AndroidRuntime(2436): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
If you are going to use Fragments you need to extend FragmentActivity not Activity.
To fix this issue you have to extends from FragmentActivity instead of Activity in the FragsApplicationActivity.
The proper form will be
<fragment
android:id="#+id/fragment1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:name="com.samplefragsapplication.SuggestionFrags" />
UPD: judging by the logcat output, you don't have fragments available. If you're running a pre-Honeycomb android (but >= 1.6), you can use the compatibility library. Fragments were introduced in 3.0.
The exception android.view.InflateException: Binary XML file line: #... Error inflating class fragment might happen if you manipulate with getActivity() inside your fragment before onActivityCreated() get called. In such case you receive a wrong activity reference and can't rely on that.
For instance the next pattern is wrong:
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
final View view = inflater.inflate(R.layout..., container, false);
Button button = getActivity().findViewById(R.id...);
button.setOnClickListener(...); - another problem: button is null
return view;
}
I just had the same issue, and what I found was that in my main.xml I was incorrectly referencing the fragment class.
Instead of:
<fragment android:id="#+id/frag_capt"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.company.test.applicationname.fragmentname" />
try:
<fragment android:id="#+id/frag_capt"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.company.test.DetailFrag" />
This fixed the issue for me.
Good luck.
Try this
<fragment
android:id="#+id/fragment1"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true" />
Make sure android:name="className" is the first parameter in the list
ex
<fragment
android:name="com.name.first"
android:id="#+id/"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
I had the same issue, to summarise:
Extend from FragmentActivity
Follow this structure in your layout
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:name="com.google.android.gms.maps.MapFragment"
/>
I have followed twice this basic tutorial to create a map + an overlay with the AndroidMarker (when you tap him, a popup should appear)
And I still have the same problem, when I press the marker, the application crashed on the dialog.show().
Can you tell me how to debug such problem please ?
My sources can be found here (Link is dead. The requested topic does not exist.)
11-23 12:48:51.364: WARN/WindowManager(59): Attempted to add window with non-application token WindowToken{43f3eb70 token=null}. Aborting.
11-23 12:48:51.384: DEBUG/AndroidRuntime(307): Shutting down VM
11-23 12:48:51.384: WARN/dalvikvm(307): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): FATAL EXCEPTION: main
11-23 12:48:51.454: ERROR/AndroidRuntime(307): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at android.view.ViewRoot.setView(ViewRoot.java:509)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at android.app.Dialog.show(Dialog.java:241)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at android.app.AlertDialog$Builder.show(AlertDialog.java:802)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at com.markerTest.HelloItemizedOverlay.onTap(HelloItemizedOverlay.java:45)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at com.google.android.maps.ItemizedOverlay.onTap(ItemizedOverlay.java:453)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at com.google.android.maps.OverlayBundle.onTap(OverlayBundle.java:83)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at com.google.android.maps.MapView$1.onSingleTapUp(MapView.java:347)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at com.google.android.maps.GestureDetector.onTouchEvent(GestureDetector.java:533)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at com.google.android.maps.MapView.onTouchEvent(MapView.java:647)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at android.view.View.dispatchTouchEvent(View.java:3766)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:897)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1671)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at android.app.Activity.dispatchTouchEvent(Activity.java:2086)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1655)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at android.view.ViewRoot.handleMessage(ViewRoot.java:1785)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at android.os.Handler.dispatchMessage(Handler.java:99)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at android.os.Looper.loop(Looper.java:123)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at android.app.ActivityThread.main(ActivityThread.java:4627)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at java.lang.reflect.Method.invokeNative(Native Method)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at java.lang.reflect.Method.invoke(Method.java:521)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-23 12:48:51.454: ERROR/AndroidRuntime(307): at dalvik.system.NativeStart.main(Native Method)
11-23 12:48:51.534: WARN/ActivityManager(59): Force finishing activity com.markerTest/.markerTest
thx
Swan
I have found the solution here:
http://www.mailinglistarchive.com/html/android-beginners#googlegroups.com/2010-03/msg00219.html