Very strange and frustrating error.
As soon as I load my app on the emulator and try to open it, I am receieving a null pointer exception error within the on create method.
As said in the title, this code has worked perfectly for weeks.
Here is the logcat:
02-14 20:03:45.813: E/AndroidRuntime(285): FATAL EXCEPTION: main
02-14 20:03:45.813: E/AndroidRuntime(285): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.flybase2/com.example.flybase2.MainActivity}: java.lang.NullPointerException
02-14 20:03:45.813: E/AndroidRuntime(285): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
02-14 20:03:45.813: E/AndroidRuntime(285): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
02-14 20:03:45.813: E/AndroidRuntime(285): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
02-14 20:03:45.813: E/AndroidRuntime(285): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
02-14 20:03:45.813: E/AndroidRuntime(285): at android.os.Handler.dispatchMessage(Handler.java:99)
02-14 20:03:45.813: E/AndroidRuntime(285): at android.os.Looper.loop(Looper.java:123)
02-14 20:03:45.813: E/AndroidRuntime(285): at android.app.ActivityThread.main(ActivityThread.java:4627)
02-14 20:03:45.813: E/AndroidRuntime(285): at java.lang.reflect.Method.invokeNative(Native Method)
02-14 20:03:45.813: E/AndroidRuntime(285): at java.lang.reflect.Method.invoke(Method.java:521)
02-14 20:03:45.813: E/AndroidRuntime(285): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-14 20:03:45.813: E/AndroidRuntime(285): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-14 20:03:45.813: E/AndroidRuntime(285): at dalvik.system.NativeStart.main(Native Method)
02-14 20:03:45.813: E/AndroidRuntime(285): Caused by: java.lang.NullPointerException
02-14 20:03:45.813: E/AndroidRuntime(285): at com.example.flybase2.MainActivity.onCreate(MainActivity.java:33)
02-14 20:03:45.813: E/AndroidRuntime(285): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-14 20:03:45.813: E/AndroidRuntime(285): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
02-14 20:03:45.813: E/AndroidRuntime(285): ... 11 more
and here is the class:
package com.example.flybase2;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity implements OnClickListener{
Button bContacts;
Button bAppointment;
Button bShopping;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.appmenus);
bContacts = (Button) findViewById(R.id.btnCons);
bAppointment = (Button) findViewById(R.id.btnAppoint);
bShopping = (Button) findViewById(R.id.btnShop);
bContacts.setOnClickListener(this);
bAppointment.setOnClickListener(this);
bShopping.setOnClickListener(this);
}
#Override
public void onClick(View passedAppChoice) {
switch(passedAppChoice.getId()){
case (R.id.btnCons):
Intent cons = new Intent("com.example.flybase2.contacts");
startActivity(cons);
break;
case (R.id.btnAppoint):
Intent Appoint = new Intent("com.example.flybase2.appointmantMenu");
startActivity(Appoint);
break;
case (R.id.btnShop):
Intent shop = new Intent("com.example.flybase2.ShoppingList");
startActivity(shop);
break;
}
}
}
Appmenus.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" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="84dp"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imgLink"
android:layout_width="60dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="0.91"
android:src="#drawable/menulist" />
<TextView
android:id="#+id/textView1"
android:layout_width="165dp"
android:layout_height="match_parent"
android:layout_weight="0.14"
android:gravity="center"
android:text="Menu"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="40sp" />
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="#+id/btnCons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:drawableLeft="#drawable/consicon"
android:src="#drawable/consicon"
android:text="Contacts " />
<Button
android:id="#+id/btnToDo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:drawableLeft="#drawable/todo"
android:src="#drawable/todo"
android:text="'To Do' List" />
<Button
android:id="#+id/btnShop"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:drawableLeft="#drawable/shoppingmenu"
android:src="#drawable/shoppingmenu"
android:text="Shopping List" />
<Button
android:id="#+id/btnAppoint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:drawableLeft="#drawable/appointmainicon"
android:src="#drawable/appointmainicon"
android:text="Appointment List" />
</LinearLayout>
</ScrollView>
</LinearLayout>
Hopefully someone can see where I have gone wrong!.
A Few Possible Things:
Does R.layout.appmenus contain all the above buttons (check the IDs). Since R.id is an app-wide namespace, it could have been in other layouts too
The way you're starting your intents seems odd. This is not how you start explicit intents.
An Explicit Intent should be of the form:
Intent explicitIntent = new Intent(InvokingActivity.this,InvokedActivity.class);
startActivity(explicitIntent);
add this logs print in onCreate just after initializing buttons objects.
Log.d("MainActivityTAG", "bContacts ="+bContacts+ ", bAppointment="+bAppointment+", bShopping="+bShopping);
it seems one of the button object from below code is null.
bContacts = (Button) findViewById(R.id.btnCons);
bAppointment = (Button) findViewById(R.id.btnAppoint);
bShopping = (Button) findViewById(R.id.btnShop);
above log print will let you know which button instance is null, and you ll get to know if you are getting button with wrong ID or setting wrong layout which doesn’t have one of these buttons defined.
Eventually started a new project and simply copied the code over so it was very quick. It is working now. I have no idea what happened but believe it is down to some sort of corruption in my XML appmenu.xml file layout. For what ever reason I think the appointments button can no longer be 'seen' by eclipse even though it is clearly there and referenced by its ID. Many thanks to all who contributed.
Related
I currently generate a simple audio application. I would like to add a SeekBar panel to Android notification bar.
I learned from this writing, that RemoteViews does not supports SeekBar. I use NotificationCompat and RemoteViews for notification.
My code:
// add action to big remote view
// add action to small remote view
Notification notification = new NotificationCompat.Builder(WatchActivity.mActivity, ANDROID_CHANNEL_ID).
setCategory(Notification.EXTRA_MEDIA_SESSION).
setCustomBigContentView(mRemoteViewsBig).
setCustomContentView(mRemoteViewsSmall).
setContentIntent(contentIntent).
setOngoing(true).
setVisibility(NotificationCompat.VISIBILITY_PUBLIC).
setAutoCancel(true).
setOnlyAlertOnce(true).
setStyle(new NotificationCompat.DecoratedCustomViewStyle()).
setSmallIcon(R.mipmap.ic_launcher).
setSilent(true).
build();
((NotificationManager) getSystemService(NOTIFICATION_SERVICE)).notify(NOTIFICATION_ID, notification);
startForeground(NOTIFICATION_ID, notification);
XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/layout_root"
android:layout_width="match_parent"
android:layout_height="120dp" >
<SeekBar
android:id="#+id/seekBarSoundProgress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/lblWidgetCurrentMusicName"
android:layout_alignStart="#+id/lblWidgetCurrentMusicName"
android:layout_marginTop="18dp"
android:max="100"
android:min="0"
android:progress="0" />
<!-- etc xml code -->
</LinearLayout>
</RelativeLayout>
Error (logcat):
2022-07-27 23:57:56.844 19485-19485/etc_package E/AndroidRuntime: FATAL EXCEPTION: main
Process: etc_package, PID: 19485
android.app.RemoteServiceException: Bad notification(tag=null, id=46) posted from package etc_package, crashing app(uid=11301, pid=19485): Couldn't inflate contentViewsandroid.widget.RemoteViews$ActionException: android.view.InflateException: Binary XML file line #44 in etc_package:layout/notification_big: Binary XML file line #44 in etc_package:layout/notification_big: Error inflating class huawei.android.widget.SeekBar
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2540)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8668)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)
However, I have already seen some applications uses such feature:
Please kindly advice me how can I implement this feature?
I'm using 2 phones for debuging and 1 phone is showing my activity fine and the other dose the error, how can I repair it + how can I handle it for another users to not have crashes?
the crash:
07-19 19:51:33.614 18679-18679/itay.finci.org.allerwarn E/AndroidRuntime: FATAL EXCEPTION: main
Process: itay.finci.org.allerwarn, PID: 18679
java.lang.RuntimeException: Unable to start activity ComponentInfo{itay.finci.org.allerwarn/itay.finci.org.allerwarn.intro.IntroActivity}: android.view.InflateException: Binary XML file line #38: Error inflating class com.miz.introactivity.NextDoneButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2200)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1200)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5105)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #38: Error inflating class com.miz.introactivity.NextDoneButton
edit:
thanks for AndroidStudio decompiler I adding the done.xml that dose all the errors.
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="36dp"
android:height="36dp"
android:viewportHeight="48"
android:viewportWidth="48">
<group android:name="done_group">
<path
android:name="done"
android:fillColor="#android:color/white"
android:pathData="M18 32.34L9.66 24l-2.83 2.83L18 38l24-24-2.83-2.83z" />
</group>
</vector>
edit 2:
the layout xml out of the library:
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="#+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<FrameLayout
android:layout_width="match_parent"
android:paddingLeft="#dimen/title_padding_left"
android:paddingStart="#dimen/title_padding_left"
android:paddingRight="#dimen/title_padding_right"
android:paddingEnd="#dimen/title_padding_right"
android:layout_height="#dimen/navigation_height"
android:layout_gravity="bottom">
<Button
android:id="#+id/skip_button"
android:layout_gravity="center_vertical|left|start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/skip"
android:textColor="#color/skip_text_color"
style="?attr/borderlessButtonStyle"
/>
<LinearLayout
android:id="#+id/progress_layout"
android:orientation="horizontal"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<com.miz.introactivity.NextDoneButton
android:id="#+id/next_button"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_gravity="center_vertical|right|end"
android:background="#drawable/next_done_button_selector"
/>
</FrameLayout>
</merge>
its an error in your IntroActivity. InflateException: Binary XML file line #38: Error inflating class com.miz.introactivity.NextDoneButton
More than likely; this could be due to any LARGE images you are using and the device is simply out of memory to display it. Try resizing the image to make the size of it smaller
I'm trying to load a fragment in my Main Activity which will become one of my navigation tabs later. the problem is that the app crashes and says that the fragment cannot be inflated.
I found other similar questions but none of the solutions could help me
Here's my code
MainActivity.java
public class MainActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.projecttabs.MainActivity">
<fragment
android:id="#+id/fragment1"
android:name="com.example.projecttabs.FragmentAbout"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="0dp" />
</LinearLayout>
FrgagmentAbout.java
public class FragmentAbout extends Fragment {
public View OnCreateView(LayoutInflater l, ViewGroup v, Bundle savedInstanceState){
return l.inflate(R.layout.fragment_about,v,false);
}
}
fragment_about.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#000">
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="182dp"
android:text="ButtonTest" />
</RelativeLayout>
logCat
FATAL EXCEPTION: main
Process: com.example.projecttabs, PID: 1709
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.projecttabs/com.example.projecttabs.MainActivity}: android.view.InflateException: Binary XML file line #10: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
at android.app.ActivityThread.access$700(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4998)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
at android.app.Activity.setContentView(Activity.java:1928)
at com.example.projecttabs.MainActivity.onCreate(MainActivity.java:25)
at android.app.Activity.performCreate(Activity.java:5243)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
... 11 more
Caused by: java.lang.IllegalStateException: Fragment com.example.projecttabs.FragmentAbout did not create a view.
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:314)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
For what I understand, MainActivity class sets the contentView to main_activity layout, then, in main_activity.xml file, FragmentAbout class is called to replace the fragment by fragment_about layout. am I right?
please, help me!
thanks!
It should be onCreateView() with a lowercase 'o' in FragmentAbout
In the future, try using the java annotation #Override to avoid this stupid bugs
I'm having trouble opening an activity. In my first activity (activity_main), I have 3 buttons.
<LinearLayout 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"
android:stretchColumns="1">
<TableLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00FFFF"
android:id="#+id/root"
>
<TableRow android:layout_margin="0dip"
android:id="#+id/row1">
<Button android:id="#+id/button01"
android:background="#FFFFFF"
android:layout_width="fill_parent"
android:layout_weight="1"
android:hint="#string/buttonText1"
android:layout_marginTop="60dip"
android:layout_marginBottom="15dip"
android:padding="15dip" />
</TableRow>
<TableRow android:layout_margin="0dip"
android:id="#+id/row2">
<Button android:id="#+id/button02"
android:background="#FFFFFF"
android:layout_width="fill_parent"
android:layout_weight="1"
android:hint="#string/buttonText2"
android:padding="15dip" />
</TableRow>
<TableRow android:layout_margin="0dip"
android:id="#+id/row3">
<Button android:id="#+id/button03"
android:background="#FFFFFF"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_marginTop="15dip"
android:hint="#string/buttonText3"
android:onClick="browseExercises"
android:padding="15dip" />
</TableRow>
</TableLayout>
</LinearLayout>
I click on the 3rd button, and my second activity opens, which consists of two additional buttons.
<LinearLayout 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"
android:stretchColumns="1">
<TableLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00FFFF"
android:id="#+id/root"
>
<TableRow android:layout_margin="0dip"
android:id="#+id/row1">
<Button android:id="#+id/button01"
android:background="#FFFFFF"
android:layout_width="fill_parent"
android:layout_weight="1"
android:hint="#string/alphabetical"
android:layout_marginTop="60dip"
android:layout_marginBottom="15dip"
android:onClick="Alphabetical"
android:padding="15dip" />
</TableRow>
<TableRow android:layout_margin="0dip"
android:id="#+id/row2">
<Button android:id="#+id/button99999"
android:background="#FFFFFF"
android:layout_width="fill_parent"
android:layout_weight="1"
android:hint="#string/group"
android:onClick="muscleGroups"
android:padding="15dip" />
</TableRow>
</TableLayout>
</LinearLayout>
I click on either of these buttons, and I get an error telling me that "Unfortunately, Test_Project has stopped."
I already have an activity created for each of these two buttons, and everything for these two buttons are coded the exact same way as when I created my second activity, which opens just fine, and has buttons I can click on without causing any errors. I think I'm missing something fundamental here, it's like if I create too many activities, they aren't able to look back at my MainActivity.java file for the method that is supposed to open the next activity. Here is my MainActivity.java code:
package com.example.test_project;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.content.Intent;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void browseExercises(View view){
Intent intent = new Intent(this, BrowseExercises.class);
startActivity(intent);
}
public void Alphabetical(View view){
Intent intent = new Intent(this, Alphabetical.class);
startActivity(intent);
}
public void muscleGroups(View view){
Intent intent = new Intent(this, MuscleGroups.class);
startActivity(intent);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Here is my Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test_project"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.test_project.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.test_project.BrowseExercises"
android:label="#string/title_activity_browse_exercises"
>
</activity>
<activity
android:name="com.example.test_project.MuscleGroups"
android:label="#string/title_activity_muscle_groups" >
</activity>
<activity
android:name="com.example.test_project.Alphabetical"
android:label="#string/title_activity_alphabetical" >
</activity>
</application>
</manifest>
And my logcat file:
04-20 13:46:57.632: W/dalvikvm(26747): threadid=1: thread exiting with uncaught exception (group=0x40dc42a0)
04-20 13:46:57.639: E/AndroidRuntime(26747): FATAL EXCEPTION: main
04-20 13:46:57.639: E/AndroidRuntime(26747): java.lang.IllegalStateException: Could not find a method muscleGroups(View) in the activity class com.example.test_project.BrowseExercises for onClick handler on view class android.widget.Button with id 'button99999'
04-20 13:46:57.639: E/AndroidRuntime(26747): at android.view.View$1.onClick(View.java:3587)
04-20 13:46:57.639: E/AndroidRuntime(26747): at android.view.View.performClick(View.java:4106)
04-20 13:46:57.639: E/AndroidRuntime(26747): at android.view.View$PerformClick.run(View.java:17052)
04-20 13:46:57.639: E/AndroidRuntime(26747): at android.os.Handler.handleCallback(Handler.java:615)
04-20 13:46:57.639: E/AndroidRuntime(26747): at android.os.Handler.dispatchMessage(Handler.java:92)
04-20 13:46:57.639: E/AndroidRuntime(26747): at android.os.Looper.loop(Looper.java:137)
04-20 13:46:57.639: E/AndroidRuntime(26747): at android.app.ActivityThread.main(ActivityThread.java:5059)
04-20 13:46:57.639: E/AndroidRuntime(26747): at java.lang.reflect.Method.invokeNative(Native Method)
04-20 13:46:57.639: E/AndroidRuntime(26747): at java.lang.reflect.Method.invoke(Method.java:511)
04-20 13:46:57.639: E/AndroidRuntime(26747): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
04-20 13:46:57.639: E/AndroidRuntime(26747): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
04-20 13:46:57.639: E/AndroidRuntime(26747): at dalvik.system.NativeStart.main(Native Method)
04-20 13:46:57.639: E/AndroidRuntime(26747): Caused by: java.lang.NoSuchMethodException: muscleGroups [class android.view.View]
04-20 13:46:57.639: E/AndroidRuntime(26747): at java.lang.Class.getConstructorOrMethod(Class.java:460)
04-20 13:46:57.639: E/AndroidRuntime(26747): at java.lang.Class.getMethod(Class.java:915)
04-20 13:46:57.639: E/AndroidRuntime(26747): at android.view.View$1.onClick(View.java:3580)
04-20 13:46:57.639: E/AndroidRuntime(26747): ... 11 more
04-20 13:46:59.202: I/Process(26747): Sending signal. PID: 26747 SIG: 9
Probably something pretty simple I'm just not aware of yet, but any help would be appreciated!!!!
By looking at your comment I guess that you have not created JAVA files for other Activities.
For e.g. you must create BrowseExercise.java file in the directory where your main Activity lies. And then you need to define this Activity in the AndroidManifest.xml file.
An easy way to do is by just clicking +(or something like that) on left TOP corner , then Android , New Activity . Then you just have to select which type of activity you want to use .
Have you made Java files for all your activity? Like if you are opening other activity it should fulfill following requirements:
It should be mention in manifest file with proper action
There should be one java file corresponding to that activity
Layout file should be defined or you should create layout via code
Intent should be properly declared.
If still problem exists please add more code of your intent calling and java files.
I have a multi-activity app that is already on the market and is generally working fine. Just recently I have been modifying the code to process my (mopub) adverts in a different way. This seems to work fine when I run the program and play through multiple levels. The ads are appearing exactly when and where I want them. The problem comes after I quit the program and then try and start it again. My program's first activity is a "splash screen". On the second run I get the following error:
04-23 11:16:50.374: W/dalvikvm(10512): threadid=1: thread exiting with uncaught exception (group=0x40015560)
04-23 11:16:50.394: E/AndroidRuntime(10512): FATAL EXCEPTION: main
04-23 11:16:50.394: E/AndroidRuntime(10512): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mycompany.mygame/com.mycompany.mygame.Splash}: android.view.InflateException: Binary XML file line #24: Error inflating class <unknown>
04-23 11:16:50.394: E/AndroidRuntime(10512): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
04-23 11:16:50.394: E/AndroidRuntime(10512): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
04-23 11:16:50.394: E/AndroidRuntime(10512): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-23 11:16:50.394: E/AndroidRuntime(10512): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-23 11:16:50.394: E/AndroidRuntime(10512): at android.os.Handler.dispatchMessage(Handler.java:99)
04-23 11:16:50.394: E/AndroidRuntime(10512): at android.os.Looper.loop(Looper.java:123)
04-23 11:16:50.394: E/AndroidRuntime(10512): at android.app.ActivityThread.main(ActivityThread.java:3683)
Any idea what could cause this - and why it didn't complain on the first run?
EDIT:
Here's the xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center|center_horizontal|center_vertical"
android:background="#drawable/background"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Blah blah blah"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ImageView <<== THIS IS LINE 24
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/mygame_logo" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" My company name"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</LinearLayout>
EDIT: In response to a comment...
I have an application class defined as:
public class Globals extends Application
{
}
In its onCreate method I have...
allocate_and_initialise_fresh_new_mAdView();
load_mopub_banner_ad();
which are defined as...
void allocate_and_initialise_fresh_new_mAdView()
{
mAdView = new MoPubView(this);
mAdView.setAdUnitId("agltb3B1Yi1pbmNyDAsSBFNpdGUYkaoMDA");// PUB_ID_320x50
}
void load_mopub_banner_ad()
{
if (mAdView != null)
{
mAdView.loadAd();
}
debug("Completed loadAd");
}
You are initializing a View in the Application class!
This is inadvisable and may mess things up. The context of a view should be the Activity that encompasses its lifetime. That is what the os expects from you.
Just remove it from the Application class and these errors will not re-appear.