我刚刚在我的应用程序中实现了StartApp SDK来提供add,但它给出了如下错误。崩溃报告中显示错误。请帮助删除错误并避免崩溃
请参阅下面的崩溃报告
Exception java.lang.NullPointerException: Attempt to invoke interface methodjava.util.Iterator java.util.List.iterator()' on a null object reference
com.startapp.android.publish.j.c.a ()
com.startapp.android.publish.j.c.a ()
com.startapp.android.publish.g.c.a ()
com.startapp.android.publish.g.d.d ()
com.startapp.android.publish.g.d$1.run ()
java.lang.Thread.run (Thread.java:818)
这是我的Java文件
package sujaynambiar.textilecalculation;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.Window;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.startapp.android.publish.StartAppAd;
import com.startapp.android.publish.StartAppSDK;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;
public class ComberTotalDraftDrafting extends AppCompatActivity {
EditText inputBattTension, inputFeedAmount, inputNoil, inputBattWeight, inputSliverHank;
TextView answer;
Spinner spinner;
Button calculate, buttonFormula;
final Context context = this;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
StartAppSDK.init(this, "210963358", true);
StartAppAd.disableSplash();
setContentView(R.layout.activity_comber_total_draft_drafting);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
inputBattTension = (EditText) findViewById(R.id.inputBattTensionComberTotalDraft);
inputBattTension.addTextChangedListener(new NumberTextWatcherForThousand(inputBattTension));
inputBattWeight = (EditText) findViewById(R.id.inputBattweightComberTotalDraft);
inputBattWeight.addTextChangedListener(new NumberTextWatcherForThousand(inputBattWeight));
inputNoil = (EditText) findViewById(R.id.inputNoilBComberTotalDraft);
inputNoil.addTextChangedListener(new NumberTextWatcherForThousand(inputNoil));
inputFeedAmount = (EditText) findViewById(R.id.inputFeedAmountComberTotalDraft);
inputFeedAmount.addTextChangedListener(new NumberTextWatcherForThousand(inputFeedAmount));
inputSliverHank = (EditText) findViewById(R.id.inputSliverHankComberTotalDrfat);
inputSliverHank.addTextChangedListener(new NumberTextWatcherForThousand(inputSliverHank));
answer = (TextView) findViewById(R.id.answerComberTotalDraft);
calculate = (Button) findViewById(R.id.calculateComberTotalDraft);
spinner = (Spinner) findViewById(R.id.spinnerSelectCountUnit);
List<String> list1 = new ArrayList<String>();
list1.add("Ne");
list1.add("kTex");
ArrayAdapter<String> dataAdapter1 = new ArrayAdapter<String>(this,
R.layout.custom_simple_spinner, list1);
dataAdapter1.setDropDownViewResource(R.layout.custom_spinner_dropdown);
spinner.setAdapter(dataAdapter1);
calculate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int index = spinner.getSelectedItemPosition();
double value1 = 0;
double value2 = 0;
double value3 = 0;
double value4 = 0;
double value5 = 0;
if (inputBattTension.getText().toString().isEmpty() ||
inputFeedAmount.getText().toString().isEmpty() ||
inputNoil.getText().toString().isEmpty() || inputBattWeight.getText().toString().isEmpty()
|| inputSliverHank.getText().toString().isEmpty())
Toast.makeText(getApplicationContext(), getResources().getString(R.string.toastmessage3),
Toast.LENGTH_LONG).show();
else {
value1 = Double.parseDouble(inputBattTension.getText().toString().replaceAll(",", ""));
value2 = Double.parseDouble(inputFeedAmount.getText().toString().replaceAll(",", ""));
value3 = Double.parseDouble(inputNoil.getText().toString().replaceAll(",", ""));
value4 = Double.parseDouble(inputBattWeight.getText().toString().replaceAll(",", ""));
value5 = Double.parseDouble(inputSliverHank.getText().toString().replaceAll(",", ""));
}
if (index == 0) {
double answer1 = 0;
answer1 = (0.417 * value2 * value4 * ((100 - value1) / 100) * ((100 - value3) / 100) * value5);
NumberFormat formatter = NumberFormat.getNumberInstance();
formatter.setMinimumFractionDigits(2);
formatter.setMaximumFractionDigits(2);
answer.setText(formatter.format(answer1) + " ");
}
if (index == 1) {
double answer2 = 0;
answer2 = (((0.245 / value5) * value2 * value4 * ((100 - value1) / 100) * ((100 - value3) / 100)));
NumberFormat formatter = NumberFormat.getNumberInstance();
formatter.setMinimumFractionDigits(2);
formatter.setMaximumFractionDigits(2);
answer.setText(formatter.format(answer2) + " ");
}
}
});
buttonFormula = (Button) findViewById(R.id.formulaComberTotalDraft);
buttonFormula.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
final Dialog dialog = new Dialog(context);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.layout_formula);
TextView title = (TextView) dialog.findViewById(R.id.title);
title.setText(R.string.ComberTotalDraftCalculation);
ImageView image = (ImageView) dialog.findViewById(R.id.test_image);
image.setImageResource(R.drawable.combertotaldraftne);
ImageView image1 = (ImageView) dialog.findViewById(R.id.test_image1);
image1.setImageResource(R.drawable.combertotaldraftktex);
TextView text = (TextView) dialog.findViewById(R.id.text);
text.setText(R.string.Formula_ComberTotalDraftCalculation);
Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK);
dialogButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
});
}
@Override
public void onBackPressed() {
StartAppAd.onBackPressed(this);
super.onBackPressed();
}
}
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:background="@color/layoutbackgroundcolor">
<ScrollView 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:layout_above="@+id/startAppBanner"
android:fillViewport="true">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/layoutbackgroundcolor"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="sujaynambiar.paid.ComberTotalDraftDrafting"
tools:showIn="@layout/activity_comber_total_draft_drafting">
<View
android:id="@+id/dot"
android:layout_width="fill_parent"
android:layout_height="3dp"
android:layout_marginBottom="@dimen/separator_textview"
android:layout_marginTop="@dimen/FirstViewMarginTop"
android:background="@drawable/separator"
android:layerType="software" />
<LinearLayout
android:id="@+id/RL1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/dot"
android:layout_marginBottom="@dimen/gap_for_all"
android:orientation="horizontal"
android:weightSum="3">
<TextView
android:id="@+id/textView14"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="@dimen/padding_left"
android:layout_marginLeft="@dimen/padding_left"
android:layout_marginRight="@dimen/padding_right"
android:layout_marginStart="@dimen/padding_right"
android:layout_weight="1.25"
android:text="@string/showtext52"
android:textColor="@color/textviewtextcolor"
android:textSize="@dimen/TextViewSize" />
<EditText
android:id="@+id/inputBattTensionComberTotalDraft"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="@dimen/padding_left"
android:layout_marginLeft="@dimen/padding_left"
android:layout_marginRight="@dimen/padding_right"
android:layout_marginStart="@dimen/padding_right"
android:layout_weight="1.75"
android:ems="10"
android:gravity="center"
android:inputType="numberDecimal" />
</LinearLayout>
<View
android:id="@+id/dot1"
android:layout_width="fill_parent"
android:layout_height="3dp"
android:layout_below="@+id/RL1"
android:layout_marginBottom="@dimen/separator_textview"
android:background="@drawable/separator"
android:layerType="software" />
<LinearLayout
android:id="@+id/RL2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/dot1"
android:layout_marginBottom="@dimen/gap_for_all"
android:orientation="horizontal"
android:weightSum="3">
<TextView
android:id="@+id/textView15"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="@dimen/padding_left"
android:layout_marginLeft="@dimen/padding_left"
android:layout_marginRight="@dimen/padding_right"
android:layout_marginStart="@dimen/padding_right"
android:layout_weight="1.25"
android:text="@string/showtext51"
android:textColor="@color/textviewtextcolor"
android:textSize="@dimen/TextViewSize" />
<EditText
android:id="@+id/inputBattweightComberTotalDraft"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="@dimen/padding_left"
android:layout_marginLeft="@dimen/padding_left"
android:layout_marginRight="@dimen/padding_right"
android:layout_marginStart="@dimen/padding_right"
android:layout_weight="1.75"
android:ems="10"
android:gravity="center"
android:inputType="numberDecimal" />
</LinearLayout>
<View
android:id="@+id/dot2"
android:layout_width="fill_parent"
android:layout_height="3dp"
android:layout_below="@+id/RL2"
android:layout_marginBottom="@dimen/separator_textview"
android:background="@drawable/separator"
android:layerType="software" />
<LinearLayout
android:id="@+id/RL3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/dot2"
android:layout_marginBottom="@dimen/gap_for_all"
android:orientation="horizontal"
android:weightSum="3">
<TextView
android:id="@+id/textView16"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="@dimen/padding_left"
android:layout_marginLeft="@dimen/padding_left"
android:layout_marginRight="@dimen/padding_right"
android:layout_marginStart="@dimen/padding_right"
android:layout_weight="1.25"
android:text="@string/showtext50"
android:textColor="@color/textviewtextcolor"
android:textSize="@dimen/TextViewSize" />
<EditText
android:id="@+id/inputNoilBComberTotalDraft"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="@dimen/padding_left"
android:layout_marginLeft="@dimen/padding_left"
android:layout_marginRight="@dimen/padding_right"
android:layout_marginStart="@dimen/padding_right"
android:layout_weight="1.75"
android:ems="10"
android:gravity="center"
android:inputType="numberDecimal" />
</LinearLayout>
<View
android:id="@+id/dot5"
android:layout_width="fill_parent"
android:layout_height="3dp"
android:layout_below="@+id/RL3"
android:layout_marginBottom="@dimen/separator_button"
android:background="@drawable/separator"
android:layerType="software" />
<LinearLayout
android:id="@+id/RL4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/dot5"
android:layout_marginBottom="@dimen/gap_for_all"
android:orientation="horizontal"
android:weightSum="3">
<TextView
android:id="@+id/textView17"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="@dimen/padding_left"
android:layout_marginLeft="@dimen/padding_left"
android:layout_marginRight="@dimen/padding_right"
android:layout_marginStart="@dimen/padding_right"
android:layout_weight="1.25"
android:text="@string/showtext49"
android:textColor="@color/textviewtextcolor"
android:textSize="@dimen/TextViewSize" />
<EditText
android:id="@+id/inputFeedAmountComberTotalDraft"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="@dimen/padding_left"
android:layout_marginLeft="@dimen/padding_left"
android:layout_marginRight="@dimen/padding_right"
android:layout_marginStart="@dimen/padding_right"
android:layout_weight="1.75"
android:ems="10"
android:gravity="center"
android:inputType="numberDecimal" />
</LinearLayout>
<View
android:id="@+id/dot6"
android:layout_width="fill_parent"
android:layout_height="3dp"
android:layout_below="@+id/RL4"
android:layout_marginBottom="@dimen/separator_textview"
android:background="@drawable/separator"
android:layerType="software" />
<TextView
android:id="@+id/textView18"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/dot6"
android:layout_marginBottom="@dimen/TextView_Spinner"
android:layout_marginEnd="@dimen/padding_left"
android:layout_marginLeft="@dimen/padding_left"
android:layout_marginRight="@dimen/padding_right"
android:layout_marginStart="@dimen/padding_right"
android:text="@string/showtext43"
android:textColor="@color/textviewtextcolor"
android:textSize="@dimen/TextViewSize" />
<TextView
android:id="@+id/textView11"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/textView18"
android:layout_marginBottom="@dimen/TextView_Spinner"
android:layout_marginEnd="@dimen/padding_left"
android:layout_marginLeft="@dimen/padding_left"
android:layout_marginRight="@dimen/padding_right"
android:layout_marginStart="@dimen/padding_right"
android:text="@string/showtext30a"
android:textColor="@color/textviewtextcolor"
android:textSize="@dimen/TextViewSize" />
<LinearLayout
android:id="@+id/RL5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/textView11"
android:layout_marginBottom="@dimen/gap_for_all"
android:orientation="horizontal"
android:weightSum="3">
<Spinner
android:id="@+id/spinnerSelectCountUnit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="@dimen/padding_left"
android:layout_marginLeft="@dimen/padding_left"
android:layout_marginRight="@dimen/padding_right"
android:layout_marginStart="@dimen/padding_right"
android:layout_weight="1.25"
android:gravity="center"
android:spinnerMode="dialog" />
<EditText
android:id="@+id/inputSliverHankComberTotalDrfat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="@dimen/padding_left"
android:layout_marginLeft="@dimen/padding_left"
android:layout_marginRight="@dimen/padding_right"
android:layout_marginStart="@dimen/padding_right"
android:layout_weight="1.75"
android:ems="10"
android:gravity="center"
android:inputType="numberDecimal" />
</LinearLayout>
<View
android:id="@+id/dot7"
android:layout_width="fill_parent"
android:layout_height="3dp"
android:layout_below="@+id/RL5"
android:layout_marginBottom="@dimen/separator_button"
android:background="@drawable/separator"
android:layerType="software" />
<Button
android:id="@+id/calculateComberTotalDraft"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/dot7"
android:layout_marginBottom="@dimen/button_separator"
android:layout_marginEnd="@dimen/padding_left"
android:layout_marginLeft="@dimen/padding_left"
android:layout_marginRight="@dimen/padding_right"
android:layout_marginStart="@dimen/padding_right"
android:background="@drawable/button_background"
android:text="@string/calculate"
android:textColor="@color/buttontextcolor"
android:textSize="@dimen/ButtonText" />
<View
android:id="@+id/dot8"
android:layout_width="fill_parent"
android:layout_height="3dp"
android:layout_below="@+id/calculateComberTotalDraft"
android:layout_marginBottom="@dimen/separator_answer"
android:background="@drawable/separator"
android:layerType="software" />
<TextView
android:id="@+id/answerComberTotalDraft"
android:layout_width="match_parent"
android:layout_height="@dimen/answerViewSize"
android:layout_below="@+id/dot8"
android:layout_marginBottom="@dimen/answerview_separator"
android:layout_marginEnd="@dimen/padding_left"
android:layout_marginLeft="@dimen/padding_left"
android:layout_marginRight="@dimen/padding_right"
android:layout_marginStart="@dimen/padding_right"
android:gravity="center"
android:text="@string/answer"
android:textColor="@color/textviewtextcolor"
android:textSize="@dimen/AnswerView" />
<View
android:id="@+id/dot10"
android:layout_width="fill_parent"
android:layout_height="3dp"
android:layout_below="@+id/answerComberTotalDraft"
android:layout_marginBottom="@dimen/separator_button"
android:background="@drawable/separator"
android:layerType="software" />
<Button
android:id="@+id/formulaComberTotalDraft"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/dot10"
android:layout_marginBottom="@dimen/button_separator"
android:layout_marginEnd="@dimen/padding_left"
android:layout_marginLeft="@dimen/padding_left"
android:layout_marginRight="@dimen/padding_right"
android:layout_marginStart="@dimen/padding_right"
android:background="@drawable/button_background"
android:text="@string/formula"
android:textColor="@color/buttontextcolor"
android:textSize="@dimen/ButtonText" />
<View
android:id="@+id/dot9"
android:layout_width="fill_parent"
android:layout_height="3dp"
android:layout_below="@+id/formulaComberTotalDraft"
android:layout_marginBottom="@dimen/separator_textview"
android:background="@drawable/separator"
android:layerType="software" />
</RelativeLayout>
</ScrollView>
<com.startapp.android.publish.banner.Banner
android:id="@+id/startAppBanner"
android:layout_width="wrap_content"
android:layout_alignParentBottom="true"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"/>
</RelativeLayout>