I have an app in which I have
public class mainactivity extends Activity implements View.OnClickListener
{
...
and I declare it in that manifest. Everything compiles and runs perfectly. Then I change the class as follows:
public class mainactivity extends Activity implements View.OnClickListener , MoPubInterstitialListener
{
...
+ extra code to do with "mopub"
this new code compiles, but now, as soon as my splash screen activity shuts down and hands over to mainactivity, I see
03-08 10:47:40.380: I/dalvikvm(9013): Failed resolving Lcom/mycompany/myapp/mainactivity; interface 1127 'Lcom/mopub/mobileads/MoPubInterstitial$MoPubInterstitialListener;'
03-08 10:47:40.380: W/dalvikvm(9013): Link of class 'Lcom/mycompany/myapp/mainactivity;' failed
03-08 10:47:40.380: D/AndroidRuntime(9013): Shutting down VM
03-08 10:47:40.380: W/dalvikvm(9013): threadid=1: thread exiting with uncaught exception (group=0x40c7e1f8)
03-08 10:47:40.385: E/AndroidRuntime(9013): FATAL EXCEPTION: main
03-08 10:47:40.385: E/AndroidRuntime(9013): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.mycompany.myapp/com.mycompany.myapp.mainactivity}: java.lang.ClassNotFoundException: com.mycompany.myapp.mainactivity
03-08 10:47:40.385: E/AndroidRuntime(9013): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1891)
03-08 10:47:40.385: E/AndroidRuntime(9013): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
03-08 10:47:40.385: E/AndroidRuntime(9013): at android.app.ActivityThread.access$600(ActivityThread.java:127)
03-08 10:47:40.385: E/AndroidRuntime(9013): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
03-08 10:47:40.385: E/AndroidRuntime(9013): at android.os.Handler.dispatchMessage(Handler.java:99)
03-08 10:47:40.385: E/AndroidRuntime(9013): at android.os.Looper.loop(Looper.java:137)
03-08 10:47:40.385: E/AndroidRuntime(9013): at android.app.ActivityThread.main(ActivityThread.java:4511)
03-08 10:47:40.385: E/AndroidRuntime(9013): at java.lang.reflect.Method.invokeNative(Native Method)
03-08 10:47:40.385: E/AndroidRuntime(9013): at java.lang.reflect.Method.invoke(Method.java:511)
03-08 10:47:40.385: E/AndroidRuntime(9013): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
03-08 10:47:40.385: E/AndroidRuntime(9013): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
03-08 10:47:40.385: E/AndroidRuntime(9013): at dalvik.system.NativeStart.main(Native Method)
03-08 10:47:40.385: E/AndroidRuntime(9013): Caused by: java.lang.ClassNotFoundException: com.mycompany.myapp.mainactivity
03-08 10:47:40.385: E/AndroidRuntime(9013): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
03-08 10:47:40.385: E/AndroidRuntime(9013): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
03-08 10:47:40.385: E/AndroidRuntime(9013): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
03-08 10:47:40.385: E/AndroidRuntime(9013): at android.app.Instrumentation.newActivity(Instrumentation.java:1026)
03-08 10:47:40.385: E/AndroidRuntime(9013): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1882)
03-08 10:47:40.385: E/AndroidRuntime(9013): ... 11 more
I'm at a loss as to how to proceed. If I try the debugger it appears that not even the first line of mainactivity.OnCreate() is executed.
EDIT: I have the following included in my manifest:
<activity android:name="com.mopub.mobileads.MoPubActivity"
android:configChanges="keyboardHidden|orientation"/>
Classpath
If this ring a bell, then read on.
Diagnosis:
It means the compiler find these classes during compile-time but this class is not found in your classpath during runtime
Medicine:
I've had this before and am not perfectly sure of the steps but let me put you in the right direcction.
If you're using ADT and eclipse, check your .classpath in your project.
check the build order in project->build properties
check if your jar is included in the build path
isLibraryProject
If the ComponentInfo is part of a library project, then it's a CardinalSin (seriously!) to include it in your build path manually. You are supposed to just add is a library project in project properties->android tab.
Did you define the MoPub activity in your Manifest?
<activity android:name="com.mopub.mobileads.MoPubActivity"
android:configChanges="keyboardHidden|orientation"/>
Go have a look at this link. It should solve your problem.
I had a similar issue and I checked on the android-support-v4.jar checkbox under Java Build Path - Order and Export.
Related
In 4.0.3 if i am using a base theme in my manifest, it appears to Android is trying to resolve my onClick methods of my menu's in the android.view.ContextThemeWrapper class. It resolves fine in 4.03+. I can take out the style in the manifest and everything works and gets resolved. How can I get the onClick methods to resolve correctly while using a theme?
I'm inflating the menu in the onCreateOptionsMenue() method and that's where the exception is getting thrown.
android.view.InflateException: Couldn't resolve menu item onClick
handler createNewDoc in class android.view.ContextThemeWrapper
at android.view.MenuInflater$InflatedOnMenuItemClickListener.(MenuInflater.java:202)
at android.view.MenuInflater$MenuState.setItem(MenuInflater.java:402)
at android.view.MenuInflater$MenuState.addItem(MenuInflater.java:436)
at android.view.MenuInflater.parseMenu(MenuInflater.java:173)
at android.view.MenuInflater.inflate(MenuInflater.java:95)
at com.c2crm.c2crm.ListActivity.onCreateOptionsMenu(ListActivity.java:326)
at android.app.Activity.onCreatePanelMenu(Activity.java:2444)
at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:388)
at com.android.internal.policy.impl.PhoneWindow.invalidatePanelMenu(PhoneWindow.java:739)
at com.android.internal.policy.impl.PhoneWindow$1.run(PhoneWindow.java:2833)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
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)
Caused by: java.lang.NoSuchMethodException: createNewDoc [interface android.view.MenuItem]
at java.lang.Class.getConstructorOrMethod(Class.java:460)
at java.lang.Class.getMethod(Class.java:915)
at android.view.MenuInflater$InflatedOnMenuItemClickListener.(MenuInflater.java:200)
When I run my app in landscape mode it has no issues nor does it have any issues in portrait mode until i try to add an item to one of my lists while still in portrait mode, where of which my app crashes.
any ideas on how to fix this??
here is the error I am getting as feedback in logcat....
03-08 13:30:50.201: D/AndroidRuntime(554): Shutting down VM
03-08 13:30:50.201: W/dalvikvm(554): threadid=1: thread exiting with uncaught exception (group=0x40014760)
03-08 13:30:50.229: E/AndroidRuntime(554): FATAL EXCEPTION: main
03-08 13:30:50.229: E/AndroidRuntime(554): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ATG.C3FactSystemTabbed/com.ATG.EditActivities.AmenitiesEditActivity}: java.lang.NullPointerException
03-08 13:30:50.229: E/AndroidRuntime(554): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1748)
03-08 13:30:50.229: E/AndroidRuntime(554): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1764)
03-08 13:30:50.229: E/AndroidRuntime(554): at android.app.ActivityThread.access$1500(ActivityThread.java:122)
03-08 13:30:50.229: E/AndroidRuntime(554): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1002)
03-08 13:30:50.229: E/AndroidRuntime(554): at android.os.Handler.dispatchMessage(Handler.java:99)
03-08 13:30:50.229: E/AndroidRuntime(554): at android.os.Looper.loop(Looper.java:132)
03-08 13:30:50.229: E/AndroidRuntime(554): at android.app.ActivityThread.main(ActivityThread.java:4025)
03-08 13:30:50.229: E/AndroidRuntime(554): at java.lang.reflect.Method.invokeNative(Native Method)
03-08 13:30:50.229: E/AndroidRuntime(554): at java.lang.reflect.Method.invoke(Method.java:491)
03-08 13:30:50.229: E/AndroidRuntime(554): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
03-08 13:30:50.229: E/AndroidRuntime(554): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
03-08 13:30:50.229: E/AndroidRuntime(554): at dalvik.system.NativeStart.main(Native Method)
03-08 13:30:50.229: E/AndroidRuntime(554): Caused by: java.lang.NullPointerException
03-08 13:30:50.229: E/AndroidRuntime(554): at com.ATG.EditActivities.AmenitiesEditActivity.registerButtonListenersAndSetDefaultText(AmenitiesEditActivity.java:68)
03-08 13:30:50.229: E/AndroidRuntime(554): at com.ATG.EditActivities.AmenitiesEditActivity.onCreate(AmenitiesEditActivity.java:61)
03-08 13:30:50.229: E/AndroidRuntime(554): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
03-08 13:30:50.229: E/AndroidRuntime(554): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1712)
03-08 13:30:50.229: E/AndroidRuntime(554): ... 11 more
this is the line that throws the exception
btnSave.setOnClickListener(new View.OnClickListener(){ <-------
#Override
public void onClick(View v){
. . . . .
}
});
this is only thrown when I am in portrait mode, it never gets thrown unless i change the orientation before trying to add something to the list. And if i already have the view open to add something no matter how i change the orientation it won't force close.
okay so i checked the files again i had different names for the buttons i was referencing in different xml files. In other words in landscape i was calling the button btnSave and in the other i was calling it btnAmenitiesSave. Problem solved thanks everyone!!!!!!
btnSave is set to null in portrait.
It means :
btnSave is not assigned ( no btnSave = findViewById(....) )
or the id the_id specified in btnSave = findViewById(R.id.the_id) does not exist in the portait layout
i have a created android project and within it i have created two package
--net.website.custom_listview
--main_activity_customview.java
--other files .....
--net.website.dashboard
--main_activity_dashboard.java
--other files .....
in my AndroidManifest.xml file
<activity
android:name="net.website.dashboard.main_activity_dashboard"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
so when i run the android app i am getting the following errors..
here is my logCat:
03-08 22:02:03.941: E/AndroidRuntime(691): FATAL EXCEPTION: main
03-08 22:02:03.941: E/AndroidRuntime(691): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.website/net.website.dashboard.Main_Activity_Dashboard}: android.view.InflateException: Binary XML file line #1: Error inflating class net.website.dashboard
03-08 22:02:03.941: E/AndroidRuntime(691): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
03-08 22:02:03.941: E/AndroidRuntime(691): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
03-08 22:02:03.941: E/AndroidRuntime(691): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-08 22:02:03.941: E/AndroidRuntime(691): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
03-08 22:02:03.941: E/AndroidRuntime(691): at android.os.Handler.dispatchMessage(Handler.java:99)
03-08 22:02:03.941: E/AndroidRuntime(691): at android.os.Looper.loop(Looper.java:123)
03-08 22:02:03.941: E/AndroidRuntime(691): at android.app.ActivityThread.main(ActivityThread.java:3683)
03-08 22:02:03.941: E/AndroidRuntime(691): at java.lang.reflect.Method.invokeNative(Native Method)
03-08 22:02:03.941: E/AndroidRuntime(691): at java.lang.reflect.Method.invoke(Method.java:507)
03-08 22:02:03.941: E/AndroidRuntime(691): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-08 22:02:03.941: E/AndroidRuntime(691): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-08 22:02:03.941: E/AndroidRuntime(691): at dalvik.system.NativeStart.main(Native Method)
03-08 22:02:03.941: E/AndroidRuntime(691): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class net.website.dashboard
03-08 22:02:03.941: E/AndroidRuntime(691): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
03-08 22:02:03.941: E/AndroidRuntime(691): at android.view.LayoutInflater.parseInclude(LayoutInflater.java:684)
03-08 22:02:03.941: E/AndroidRuntime(691): at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
03-08 22:02:03.941: E/AndroidRuntime(691): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
03-08 22:02:03.941: E/AndroidRuntime(691): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
03-08 22:02:03.941: E/AndroidRuntime(691): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
03-08 22:02:03.941: E/AndroidRuntime(691): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
03-08 22:02:03.941: E/AndroidRuntime(691): at android.app.Activity.setContentView(Activity.java:1657)
03-08 22:02:03.941: E/AndroidRuntime(691): at net.website.dashboard.Main_Activity_Dashboard.onCreate(Main_Activity_Dashboard.java:16)
03-08 22:02:03.941: E/AndroidRuntime(691): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-08 22:02:03.941: E/AndroidRuntime(691): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
03-08 22:02:03.941: E/AndroidRuntime(691): ... 11 more
03-08 22:02:03.941: E/AndroidRuntime(691): Caused by: java.lang.ClassNotFoundException: net.website.dashboard in loader dalvik.system.PathClassLoader[/data/app/net.website-2.apk]
03-08 22:02:03.941: E/AndroidRuntime(691): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
03-08 22:02:03.941: E/AndroidRuntime(691): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
03-08 22:02:03.941: E/AndroidRuntime(691): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
03-08 22:02:03.941: E/AndroidRuntime(691): at android.view.LayoutInflater.createView(LayoutInflater.java:471)
03-08 22:02:03.941: E/AndroidRuntime(691): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
The problem is in your layout XML file. You're referencing the class "net.website.dashboard" but it doesn't exist.
You have to change the name for your packege and then after you have to check this.and also check your xml file
By default Bluetooth is not enabled in Android. But when I go to Setting > Wireless & network and I click on Bluetooth Settings I get the following error:
04-04 11:42:22.492:
WARN/dalvikvm(747): threadid=1: thread
exiting with uncaught exception
(group=0x40014760) FATAL EXCEPTION:
main android.view.InflateException:
Binary XML file line #29: Error
inflating class
java.lang.reflect.Constructor
at android.preference.GenericInflater.createItem(GenericInflater.java:397)
at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:430)
at android.preference.GenericInflater.rInflate(GenericInflater.java:481)
at android.preference.GenericInflater.inflate(GenericInflater.java:326)
at android.preference.GenericInflater.inflate(GenericInflater.java:263)
at android.preference.
PreferenceManager.inflateFromResource(PreferenceManager.java:269)
at android.preference.PreferenceFragment.addPreferencesFromResource(PreferenceFragment.java:271)
at com.android.settings.bluetooth.BluetoothSettings.addPreferencesForActivity(BluetoothSettings.java:53)
at com.android.settings.bluetooth.DeviceListPreferenceFragment.onActivityCreated(DeviceListPreferenceFragment.java:93)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:749)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:921)
at android.app.BackStackRecord.run(BackStackRecord.java:578)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1221)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:375)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:126)
at android.app.ActivityThread.main(ActivityThread.java:3997)
at java.lang.reflect.Method.invokeNative(Native
Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
at dalvik.system.NativeStart.main(Native
Method) Caused by:
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native
Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.preference.GenericInflater.createItem(GenericInflater.java:383)
... 22 more Caused by: java.lang.NullPointerException
at com.android.settings.bluetooth.BluetoothNamePreference.setSummaryToName(BluetoothNamePreference.java:101)
at com.android.settings.bluetooth.BluetoothNamePreference.(BluetoothNamePreference.java:66)
... 25 more
What I'm missing?
Thanks.
You cant setup bluetooth on ANdroid AVD. Please check this link for emulator limitations:
http://developer.android.com/guide/developing/devices/emulator.html
I have an application that calls the android phone's default camera to take photo the following is my code.
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, TAKE_PICTURE);
and in the onActivityResult method I am doing the following
if ((requestCode == TAKE_PICTURE) && (resultCode == Activity.RESULT_OK)) {
Uri photoPath = intent.getData();
// do something with the uri here
}
The above code works fine on htc Tatto and Sony ericsson's x10 running 1.6 but in on htc G1 running 1.6 the above code causes the following exception
03-08 18:54:25.906: ERROR/AndroidRuntime(4344): Uncaught handler: thread main exiting due to uncaught exception
03-08 18:54:25.966: ERROR/AndroidRuntime(4344): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { act=inline-data (has extras) }} to activity removed
java.lang.NullPointerException
03-08 18:54:25.966: ERROR/AndroidRuntime(4344): at android.app.ActivityThread.deliverResults(ActivityThread.java:3224)
03-08 18:54:25.966: ERROR/AndroidRuntime(4344): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3266)
03-08 18:54:25.966: ERROR/AndroidRuntime(4344): at android.app.ActivityThread.access$2600(ActivityThread.java:116)
03-08 18:54:25.966: ERROR/AndroidRuntime(4344): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1823)
03-08 18:54:25.966: ERROR/AndroidRuntime(4344): at android.os.Handler.dispatchMessage(Handler.java:99)
03-08 18:54:25.966: ERROR/AndroidRuntime(4344): at android.os.Looper.loop(Looper.java:123)
03-08 18:54:25.966: ERROR/AndroidRuntime(4344): at android.app.ActivityThread.main(ActivityThread.java:4203)
03-08 18:54:25.966: ERROR/AndroidRuntime(4344): at java.lang.reflect.Method.invokeNative(Native Method)
03-08 18:54:25.966: ERROR/AndroidRuntime(4344): at java.lang.reflect.Method.invoke(Method.java:521)
03-08 18:54:25.966: ERROR/AndroidRuntime(4344): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
03-08 18:54:25.966: ERROR/AndroidRuntime(4344): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
03-08 18:54:25.966: ERROR/AndroidRuntime(4344): at dalvik.system.NativeStart.main(Native Method)
03-08 18:54:25.966: ERROR/AndroidRuntime(4344): Caused by: java.lang.NullPointerException
03-08 18:54:25.966: ERROR/AndroidRuntime(4344): at removed
03-08 18:54:25.966: ERROR/AndroidRuntime(4344): at android.app.Activity.dispatchActivityResult(Activity.java:3624)
03-08 18:54:25.966: ERROR/AndroidRuntime(4344): at android.app.ActivityThread.deliverResults(ActivityThread.java:3220)
03-08 18:54:25.966: ERROR/AndroidRuntime(4344): ... 11 more
I have removed the app's package name from the exception
Any insights into how to solve this problem. Thank you.
onActivityResult:
Try to use: Bitmap thumbnail = (Bitmap) data.getExtras().get("data");
It is probably related to this question and to this bug in android.