0

Some users are getting this error.

I use a viewgroup to continuously display a banner add.

I then use child views for the program and switch back and forth between views as the user clicks a button.

I can cause a crash by switching back and forth between child views 6 to 10 times.

Here is the layout for the viewgroup:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout    
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:myapp="http://schemas.android.com/apk/res/com.company.programname"
    xmlns:app="http://schemas.android.com/apk/res/com.adwhirl"      
    android:orientation="vertical"      
    android:background="@color/darkslategrey"
    android:id="@+id/LinearLayout01"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <com.adwhirl.AdWhirlLayout          
        android:id="@+id/adwhirl_layout"
        android:gravity="center"          
        android:layout_width="fill_parent"          
        android:layout_height="52dp"
    />  
</LinearLayout>

Here is the code creating the ViewGroup:

   setContentView(R.layout.viewgrouplayout);
   llLinLay=(LinearLayout)findViewById(R.id.LinearLayout01);
   liInflater=(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);

Here is the main child layout with irrelevent pieces cut out:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
    android:id="@+id/MainLayout"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">


    <Button
        android:id="@+id/MainShowAllDesiredButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/AnotherButton"
        android:layout_toRightOf="@id/AButton"
        android:textSize="15sp"
        android:text="Show All Desired"
        android:onClick="MainDesired"
    />


    <ListView
        android:id="@+id/ItemTypeList"
        android:background="@color/aqua"
        android:cacheColorHint="@color/aqua"
        android:fastScrollEnabled="true" 
        android:layout_width="fill_parent"
        android:layout_height="160dip"
        android:layout_below="@id/SomeItem"
    />

</RelativeLayout>

Here is an example of the code creating a view:

   vAllDesired=liInflater.inflate(R.layout.alldesiredlayout,null);
   vAllDesired.setId(7);
   llLinLay.addView(vAllDesired);
   final ListView lvAllDesired = (ListView)findViewById(R.id.AllDesiredList);
   laAllDesiredAdapter = new AllDesiredListAdapter(this, alAllDesired);                    
   lvAllCoinsDesired.setAdapter(laAllDesiredAdapter);        
   ViewGroup.LayoutParams AllDesiredParams = lvAllCoinsDesired.getLayoutParams(); 
   AllDesiredParams.height = AllCoinsDesiredHeight; 
   lvAllCoinsDesired.setLayoutParams(AllDesiredParams); 
   FillAllDesiredArray();

Here is an example of the code used to switch between views:

    bReturnToMainScreen = (Button) findViewById(R.id.DesiredReturnToMainScreenButton);
    bReturnToMainScreen.setOnClickListener(new View.OnClickListener(){
       @Override
       public void onClick(View V) {
        llLinLay.removeView(vAllDesired);
        MainWindow();
       }
     });

Here is the trace from Android Developer website. The line number in the program is not always the same.

java.lang.NullPointerException
 at android.webkit.WebView.requestFocus(WebView.java:6113)
 at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1073)
 at android.view.ViewGroup.requestFocus(ViewGroup.java:1029)
 at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1073)
 at android.view.ViewGroup.requestFocus(ViewGroup.java:1029)
 at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1073)
 at android.view.ViewGroup.requestFocus(ViewGroup.java:1029)
 at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1073)
 at android.view.ViewGroup.requestFocus(ViewGroup.java:1029)
 at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1073)
 at android.view.ViewGroup.requestFocus(ViewGroup.java:1029)
 at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1073)
 at android.view.ViewGroup.requestFocus(ViewGroup.java:1032)
 at android.view.View.requestFocus(View.java:3559)
 at android.view.ViewRoot.clearChildFocus(ViewRoot.java:1586)
 at android.view.ViewGroup.clearChildFocus(ViewGroup.java:508)
 at android.view.ViewGroup.clearChildFocus(ViewGroup.java:508)
 at android.view.ViewGroup.clearChildFocus(ViewGroup.java:508)
 at android.view.ViewGroup.clearChildFocus(ViewGroup.java:508)
 at android.view.ViewGroup.removeViewInternal(ViewGroup.java:2207)
 at android.view.ViewGroup.removeViewInternal(ViewGroup.java:2181)
 at android.view.ViewGroup.removeView(ViewGroup.java:2129)
 at com.jimbobga.mycoinsus.ProgramName$8.onClick(ProgramName.java:488)
 at android.view.View.performClick(View.java:2411)
 at android.view.View$PerformClick.run(View.java:8819)
 at android.os.Handler.handleCallback(Handler.java:587)
 at android.os.Handler.dispatchMessage(Handler.java:92)
 at android.os.Looper.loop(Looper.java:123)
 at android.app.ActivityThread.main(ActivityThread.java:4627)
 at java.lang.reflect.Method.invokeNative(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:521)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
 at dalvik.system.NativeStart.main(Native Method)
Bob
  • 1
  • 1

3 Answers3

0

I'm experiencing the same issue.

Take a look at this response: Issues With Adwhirl(Admob+Inmobi+..) Eric from AdMob staff says that it's a problem with the Android framework.

Did you try to surround your OnClick() code with a: try/catch Throwable Exception?

Community
  • 1
  • 1
Lisitso
  • 495
  • 10
  • 14
0

Just curious, when you're making your calls to findViewById, are they in the OnCreate method or directly where you're inflating the row in the adapter? As it relates to your example here, the findViewById method is only guaranteed to work in the OnCreate method or where the particular row is inflated, so its possible that calling it elsewhere could cause unexpected behavior.

Matt
  • 156
  • 4
  • It is within the java file that contains the onCreate method. Some are in the method and some are in functions in the same file. Some of the functions are called from within the onCreate method and some are called by other functions in the same file. – Bob Jan 23 '12 at 11:20
  • This was found to be an error in an ad company JAR file. The jar did not release control back to the program after changing an ad. – Bob Jan 23 '12 at 23:16
0

Look at this line:

at com.jimbobga.mycoinsus.ProgramName$8.onClick(ProgramName.java:488)

If this is happening after orientation has changed and views have not been assigned then you have a problem.

JoxTraex
  • 13,423
  • 6
  • 32
  • 45
  • This is not related to the orientation. You can rotate the phone with no effect. It does appear to have a correlation to the adWhirl ads that are displayed. If a view changes at the same time as an ad, the ad does not relenquish control back to the program. – Bob Jan 23 '12 at 11:17
  • Its just a thought... however for this error you MUST tell us and show us this line number. – JoxTraex Jan 23 '12 at 18:20
  • This was found to be an error in an ad company JAR file. The jar did not release control back to the program after changing an ad. Don't use MdotM - no crashes. Use MdotM - consistant crashes. – Bob Jan 23 '12 at 23:17