Open Web Browser from App - Always Crashes - android

I'm trying to open a web browser from my app using:
Intent browser = new Intent(Intent.ACTION_VIEW, Uri.parse("http://developer.android.com/"));
startActivity(browser);
But the app just crashes:
08-07 17:18:29.912: E/AndroidRuntime(751): FATAL EXCEPTION: main
08-07 17:18:29.912: E/AndroidRuntime(751): java.lang.NullPointerException
08-07 17:18:29.912: E/AndroidRuntime(751): at android.app.Activity.startActivityForResult(Activity.java:3131)
08-07 17:18:29.912: E/AndroidRuntime(751): at android.app.Activity.startActivity(Activity.java:3237)
08-07 17:18:29.912: E/AndroidRuntime(751): at com.Co.DrumKit$9.onClick(DrumKit.java:658)
08-07 17:18:29.912: E/AndroidRuntime(751): at android.view.View.performClick(View.java:3110)
08-07 17:18:29.912: E/AndroidRuntime(751): at android.view.View$PerformClick.run(View.java:11934)
08-07 17:18:29.912: E/AndroidRuntime(751): at android.os.Handler.handleCallback(Handler.java:587)
08-07 17:18:29.912: E/AndroidRuntime(751): at android.os.Handler.dispatchMessage(Handler.java:92)
08-07 17:18:29.912: E/AndroidRuntime(751): at android.os.Looper.loop(Looper.java:132)
08-07 17:18:29.912: E/AndroidRuntime(751): at android.app.ActivityThread.main(ActivityThread.java:4123)
08-07 17:18:29.912: E/AndroidRuntime(751): at java.lang.reflect.Method.invokeNative(Native Method)
08-07 17:18:29.912: E/AndroidRuntime(751): at java.lang.reflect.Method.invoke(Method.java:491)
08-07 17:18:29.912: E/AndroidRuntime(751): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
08-07 17:18:29.912: E/AndroidRuntime(751): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
08-07 17:18:29.912: E/AndroidRuntime(751): at dalvik.system.NativeStart.main(Native Method)

Related

App crashes when instantiating HelpStackSDK

We tried integrating HelpStack by following steps given on GitHub, but we kept getting the following errors:
04-03 13:54:22.054 4638-4638/com.playerline.android E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.playerline.android/com.tenmiles.helpstack.activities.HomeActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1967)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
at android.app.ActivityThread.access$600(ActivityThread.java:127)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4448)
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)
Caused by: java.lang.NullPointerException
at com.tenmiles.helpstack.activities.HSActivityParent.onCreate(HSActivityParent.java:48)
at com.tenmiles.helpstack.activities.HomeActivity.onCreate(HomeActivity.java:46)
at android.app.Activity.performCreate(Activity.java:4465)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
at android.app.ActivityThread.access$600(ActivityThread.java:127)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4448)
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)
I'm guessing it has something to do with the App Theme, which in our case is is Theme.AppCompat.NoActionBar.

"onClick" in AutocompleteTextView causes an error

I have an autocompletetextview. I want a method to run "onClick". Here is my XML:
<AutoCompleteTextView
android:id="#+id/GivenByBox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="setupMiranda"
android:gravity="left"
/>
When this is run, I get errors. It doesn't matter what onClick is set to, it will always cause an error. If I remove the android:onclick line everything works fine, but that is not what I want.
Here is an excerpt from logCat:
08-07 13:56:36.040: E/AndroidRuntime(32735): FATAL EXCEPTION: main
08-07 13:56:36.040: E/AndroidRuntime(32735): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.itsmr.dre_android_clean/com.itsmr.dre_android_clean.MainActivity}: android.view.InflateException: Binary XML file line #46: Error inflating class <unknown>
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.app.ActivityThread.access$700(ActivityThread.java:140)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.os.Handler.dispatchMessage(Handler.java:99)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.os.Looper.loop(Looper.java:137)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.app.ActivityThread.main(ActivityThread.java:4921)
08-07 13:56:36.040: E/AndroidRuntime(32735): at java.lang.reflect.Method.invokeNative(Native Method)
08-07 13:56:36.040: E/AndroidRuntime(32735): at java.lang.reflect.Method.invoke(Method.java:511)
08-07 13:56:36.040: E/AndroidRuntime(32735): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
08-07 13:56:36.040: E/AndroidRuntime(32735): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
08-07 13:56:36.040: E/AndroidRuntime(32735): at dalvik.system.NativeStart.main(Native Method)
08-07 13:56:36.040: E/AndroidRuntime(32735): Caused by: android.view.InflateException: Binary XML file line #46: Error inflating class <unknown>
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
08-07 13:56:36.040: E/AndroidRuntime(32735): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
08-07 13:56:36.040: E/AndroidRuntime(32735): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:316)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.app.Activity.setContentView(Activity.java:1924)
08-07 13:56:36.040: E/AndroidRuntime(32735): at com.itsmr.dre_android_clean.MainActivity.onCreate(MainActivity.java:81)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.app.Activity.performCreate(Activity.java:5188)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
08-07 13:56:36.040: E/AndroidRuntime(32735): ... 11 more
08-07 13:56:36.040: E/AndroidRuntime(32735): Caused by: java.lang.reflect.InvocationTargetException
08-07 13:56:36.040: E/AndroidRuntime(32735): at java.lang.reflect.Constructor.constructNative(Native Method)
08-07 13:56:36.040: E/AndroidRuntime(32735): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
08-07 13:56:36.040: E/AndroidRuntime(32735): ... 26 more
08-07 13:56:36.040: E/AndroidRuntime(32735): Caused by: java.lang.NullPointerException
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.widget.AutoCompleteTextView$PassThroughClickListener.access$302(AutoCompleteTextView.java:1226)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.widget.AutoCompleteTextView.setOnClickListener(AutoCompleteTextView.java:200)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.view.View.<init>(View.java:3678)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.widget.TextView.<init>(TextView.java:574)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.widget.EditText.<init>(EditText.java:76)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.widget.AutoCompleteTextView.<init>(AutoCompleteTextView.java:137)
08-07 13:56:36.040: E/AndroidRuntime(32735): at android.widget.AutoCompleteTextView.<init>(AutoCompleteTextView.java:133)
08-07 13:56:36.040: E/AndroidRuntime(32735): ... 29 more
I get this error no matter what function is set onClick. Even a function with an empty body causes this error.
What is causing this error?

Exception "inflating class fragment"

Getting run time exception as "inflating class fragment" when I tried to add Google map in my android application. I go through all the previous comments similar to which I have posted. But I couldn't solve it.
Log file is attached here
08-07 05:30:41.587: E/AndroidRuntime(2574): FATAL EXCEPTION: main
08-07 05:30:41.587: E/AndroidRuntime(2574): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.newapp/com.example.newapp.NewApp}: android.view.InflateException: Binary XML file line #17: Error inflating class fragment
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.app.ActivityThread.access$600(ActivityThread.java:141)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.os.Handler.dispatchMessage(Handler.java:99)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.os.Looper.loop(Looper.java:137)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.app.ActivityThread.main(ActivityThread.java:5103)
08-07 05:30:41.587: E/AndroidRuntime(2574): at java.lang.reflect.Method.invokeNative(Native Method)
08-07 05:30:41.587: E/AndroidRuntime(2574): at java.lang.reflect.Method.invoke(Method.java:525)
08-07 05:30:41.587: E/AndroidRuntime(2574): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
08-07 05:30:41.587: E/AndroidRuntime(2574): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-07 05:30:41.587: E/AndroidRuntime(2574): at dalvik.system.NativeStart.main(Native Method)
08-07 05:30:41.587: E/AndroidRuntime(2574): Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class fragment
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
08-07 05:30:41.587: E/AndroidRuntime(2574): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.app.Activity.setContentView(Activity.java:1895)
08-07 05:30:41.587: E/AndroidRuntime(2574): at com.example.newapp.NewApp.onCreate(NewApp.java:12)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.app.Activity.performCreate(Activity.java:5133)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
08-07 05:30:41.587: E/AndroidRuntime(2574): ... 11 more
08-07 05:30:41.587: E/AndroidRuntime(2574): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.SupportMapFragment: make sure class name exists, is public, and has an empty constructor that is public
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.support.v4.app.Fragment.instantiate(Fragment.java:409)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.support.v4.app.Fragment.instantiate(Fragment.java:377)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:277)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
08-07 05:30:41.587: E/AndroidRuntime(2574): ... 21 more
08-07 05:30:41.587: E/AndroidRuntime(2574): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.SupportMapFragment" on path: DexPathList[[zip file "/data/app/com.example.newapp-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.newapp-1, /vendor/lib, /system/lib]]
08-07 05:30:41.587: E/AndroidRuntime(2574): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
08-07 05:30:41.587: E/AndroidRuntime(2574): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
08-07 05:30:41.587: E/AndroidRuntime(2574): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
08-07 05:30:41.587: E/AndroidRuntime(2574): at android.support.v4.app.Fragment.instantiate(Fragment.java:399)
08-07 05:30:41.587: E/AndroidRuntime(2574): ... 24 more
08-07 05:30:47.677: I/Process(2574): Sending signal. PID: 2574 SIG: 9
08-07 05:30:53.767: D/AndroidRuntime(2650): Shutting down VM
08-07 05:30:53.767: W/dalvikvm(2650): threadid=1: thread exiting with uncaught exception (group=0x414c4700)
08-07 05:30:53.857: E/AndroidRuntime(2650): FATAL EXCEPTION: main
08-07 05:30:53.857: E/AndroidRuntime(2650): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.newapp/com.example.newapp.NewApp}: android.view.InflateException: Binary XML file line #17: Error inflating class fragment
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.app.ActivityThread.access$600(ActivityThread.java:141)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.os.Handler.dispatchMessage(Handler.java:99)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.os.Looper.loop(Looper.java:137)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.app.ActivityThread.main(ActivityThread.java:5103)
08-07 05:30:53.857: E/AndroidRuntime(2650): at java.lang.reflect.Method.invokeNative(Native Method)
08-07 05:30:53.857: E/AndroidRuntime(2650): at java.lang.reflect.Method.invoke(Method.java:525)
08-07 05:30:53.857: E/AndroidRuntime(2650): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
08-07 05:30:53.857: E/AndroidRuntime(2650): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-07 05:30:53.857: E/AndroidRuntime(2650): at dalvik.system.NativeStart.main(Native Method)
08-07 05:30:53.857: E/AndroidRuntime(2650): Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class fragment
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
08-07 05:30:53.857: E/AndroidRuntime(2650): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.app.Activity.setContentView(Activity.java:1895)
08-07 05:30:53.857: E/AndroidRuntime(2650): at com.example.newapp.NewApp.onCreate(NewApp.java:12)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.app.Activity.performCreate(Activity.java:5133)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
08-07 05:30:53.857: E/AndroidRuntime(2650): ... 11 more
08-07 05:30:53.857: E/AndroidRuntime(2650): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.SupportMapFragment: make sure class name exists, is public, and has an empty constructor that is public
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.support.v4.app.Fragment.instantiate(Fragment.java:409)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.support.v4.app.Fragment.instantiate(Fragment.java:377)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:277)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
08-07 05:30:53.857: E/AndroidRuntime(2650): ... 21 more
08-07 05:30:53.857: E/AndroidRuntime(2650): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.SupportMapFragment" on path: DexPathList[[zip file "/data/app/com.example.newapp-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.newapp-1, /vendor/lib, /system/lib]]
08-07 05:30:53.857: E/AndroidRuntime(2650): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
08-07 05:30:53.857: E/AndroidRuntime(2650): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
08-07 05:30:53.857: E/AndroidRuntime(2650): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
08-07 05:30:53.857: E/AndroidRuntime(2650): at android.support.v4.app.Fragment.instantiate(Fragment.java:399)
08-07 05:30:53.857: E/AndroidRuntime(2650): ... 24 more
08-07 05:30:56.837: I/Process(2650): Sending signal. PID: 2650 SIG: 9
manifest.xml file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.newapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="********************************" />
<permission
android:name="com.venky.maps.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.newapp.maps.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" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.newapp.NewApp"
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>
and the java file NewApp.java
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
public class NewApp extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_app);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.new_app, menu);
return true;
}
}
activity_new_app.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".NewApp" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Please help me to solve this problem.
One visible mistake
https://developers.google.com/maps/documentation/android/start
Your meta tag must be a child of application tag in manifest
<meta-data // should be inside application tag.
android:name="com.google.android.maps.v2.API_KEY"
android:value="********************************" />
Change this
<permission
android:name="com.venky.maps.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
to
<permission
android:name="com.example.newapp.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />

Launching intent of certain android apps causes IllegalStateException

There seems to be two problems that I am having trouble with. The first case is when I launch the clock app and works perfectly, this seems to be the case when I launch most apps.
The second case is when I try to launch an activity such as the Phone activity. When I go to get the Intent, getLaunchIntentForPackage(app.pname) returns null. Is there a different way to get the Intent of the phone activity so that I can launch it in this case?
The third case is when I go to launch an activity such as the Camera activity. It seems that I have to have the Camera activity already within my androidManifest.xml file to launch it but is there another way to go around this? My app has the capibility to launch any app from its UI so I cannot add every single activity an android device has into my manifest file beforehand. Thank you!
Java:
Intent launchApp = getPackageManager().getLaunchIntentForPackage(app.pname);
System.out.println(Intent of " + appName + ": + " " +launchApp);
if(launchApp!=null){
System.out.println("Permission granted to launch " + appName);
startActivity( launchApp );
}
else{
System.out.println("Permission not granted to launch " + appName);
}
Logcat:
08-07 09:38:57.031: I/System.out(1056): Intent of Clock: Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.htc.android.worldclock/.WorldClockTabControl }
08-07 09:38:57.041: I/System.out(1056): Permission granted to launch Clock
08-07 09:38:59.783: I/System.out(1056): Intent of Phone: null
08-07 09:38:59.783: I/System.out(1056): Permission not granted to launch Phone
08-07 09:39:10.564: I/System.out(1056): Intent of Camera: Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.android.camera/com.android.internal.app.ResolverActivity }
08-07 09:39:10.574: I/System.out(1056): Permission granted to launch Camera
08-07 09:39:10.574: D/AndroidRuntime(1056): Shutting down VM
08-07 09:39:10.574: W/dalvikvm(1056): threadid=1: thread exiting with uncaught exception (group=0x4001d5a0)
08-07 09:39:10.614: E/AndroidRuntime(1056): FATAL EXCEPTION: main
08-07 09:39:10.614: E/AndroidRuntime(1056): java.lang.IllegalStateException: Could not execute method of the activity
08-07 09:39:10.614: E/AndroidRuntime(1056): at android.view.View$1.onClick(View.java:2191)
08-07 09:39:10.614: E/AndroidRuntime(1056): at android.view.View.performClick(View.java:2532)
08-07 09:39:10.614: E/AndroidRuntime(1056): at android.view.View$PerformClick.run(View.java:9293)
08-07 09:39:10.614: E/AndroidRuntime(1056): at android.os.Handler.handleCallback(Handler.java:587)
08-07 09:39:10.614: E/AndroidRuntime(1056): at android.os.Handler.dispatchMessage(Handler.java:92)
08-07 09:39:10.614: E/AndroidRuntime(1056): at android.os.Looper.loop(Looper.java:150)
08-07 09:39:10.614: E/AndroidRuntime(1056): at android.app.ActivityThread.main(ActivityThread.java:4306)
08-07 09:39:10.614: E/AndroidRuntime(1056): at java.lang.reflect.Method.invokeNative(Native Method)
08-07 09:39:10.614: E/AndroidRuntime(1056): at java.lang.reflect.Method.invoke(Method.java:507)
08-07 09:39:10.614: E/AndroidRuntime(1056): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-07 09:39:10.614: E/AndroidRuntime(1056): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-07 09:39:10.614: E/AndroidRuntime(1056): at dalvik.system.NativeStart.main(Native Method)
08-07 09:39:10.614: E/AndroidRuntime(1056): Caused by: java.lang.reflect.InvocationTargetException
08-07 09:39:10.614: E/AndroidRuntime(1056): at java.lang.reflect.Method.invokeNative(Native Method)
08-07 09:39:10.614: E/AndroidRuntime(1056): at java.lang.reflect.Method.invoke(Method.java:507)
08-07 09:39:10.614: E/AndroidRuntime(1056): at android.view.View$1.onClick(View.java:2186)
08-07 09:39:10.614: E/AndroidRuntime(1056): ... 11 more
08-07 09:39:10.614: E/AndroidRuntime(1056): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.camera/com.android.internal.app.ResolverActivity}; have you declared this activity in your AndroidManifest.xml?
08-07 09:39:10.614: E/AndroidRuntime(1056): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1565)
08-07 09:39:10.614: E/AndroidRuntime(1056): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1539)
08-07 09:39:10.614: E/AndroidRuntime(1056): at android.app.Activity.startActivityForResult(Activity.java:2919)
08-07 09:39:10.614: E/AndroidRuntime(1056): at android.app.Activity.startActivity(Activity.java:3025)
08-07 09:39:10.614: E/AndroidRuntime(1056): at com.worklight.androidnativeapp.AndroidNativeApp.appClicked(AndroidNativeApp.java:284)
08-07 09:39:10.614: E/AndroidRuntime(1056): ... 14 more
How to launch the camera
How to launch the dialer
to launch a specific app you need to know the package name and the class name
try{
Intent i = new Intent();
i.setClassName("com.example.app", "com.example.app.MainActivity");
i.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(e);
}catch(ActivityNotFoundException e){
e.printStackTrace();
}

NoClassDefFoundError in Cocos2D sample

I am getting the same problem this question, but the solution didn't work for me. I've included my JAR in build path. What wrong am I doing?
I am using the same example.
Here's the crash log:
07-08 04:04:33.440: E/AndroidRuntime(751): FATAL EXCEPTION: main
07-08 04:04:33.440: E/AndroidRuntime(751): java.lang.NoClassDefFoundError: org.cocos2d.opengl.CCGLSurfaceView
07-08 04:04:33.440: E/AndroidRuntime(751): at a.b.Cocos2DGameActivity.onCreate(Cocos2DGameActivity.java:22)
07-08 04:04:33.440: E/AndroidRuntime(751): at android.app.Activity.performCreate(Activity.java:4465)
07-08 04:04:33.440: E/AndroidRuntime(751): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
07-08 04:04:33.440: E/AndroidRuntime(751): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
07-08 04:04:33.440: E/AndroidRuntime(751): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
07-08 04:04:33.440: E/AndroidRuntime(751): at android.app.ActivityThread.access$600(ActivityThread.java:123)
07-08 04:04:33.440: E/AndroidRuntime(751): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
07-08 04:04:33.440: E/AndroidRuntime(751): at android.os.Handler.dispatchMessage(Handler.java:99)
07-08 04:04:33.440: E/AndroidRuntime(751): at android.os.Looper.loop(Looper.java:137)
07-08 04:04:33.440: E/AndroidRuntime(751): at android.app.ActivityThread.main(ActivityThread.java:4424)
07-08 04:04:33.440: E/AndroidRuntime(751): at java.lang.reflect.Method.invokeNative(Native Method)
07-08 04:04:33.440: E/AndroidRuntime(751): at java.lang.reflect.Method.invoke(Method.java:511)
07-08 04:04:33.440: E/AndroidRuntime(751): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
07-08 04:04:33.440: E/AndroidRuntime(751): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
07-08 04:04:33.440: E/AndroidRuntime(751): at dalvik.system.NativeStart.main(Native Method)
I recomend you to change libraries to cocos2d-x, because cocos2d for android won't be updated anymore.
Cocos2d-x works in C++, and uses JNI (Java native interface) to work. Here is all the info you will need to start using it.
I guess the problem was in the JAR file. Fortunately the project is open source, so I added the source file and it stopped giving me error. There's a source code available on that tutorial which also uses the source files, instead of the JAR.
I get the same problem. And I copy the source code to src instead of including the jar.
And you must change the project's jre version to 1.6

Categories

Resources