在重命名包尝试后,应用程序在手机上测试时崩溃

时间:2014-02-22 07:26:19

标签: android crash refactoring package rename

我试图为我的应用重命名/重构我的包名。它没有用,所以我删除并导入了旧的工作版本。

但是在我这样做之后,当我尝试在手机上测试时,应用程序一直在崩溃(之前工作正常)。它虽然在模拟器上工作正常。我该如何解决这个问题?

编辑:

logcat:

enter image description here

有人可以帮忙吗?我该如何解决?谢谢。

清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="sg.rp.sdma.intake3.lab05"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
    android:allowBackup="true"
    android:icon="@drawable/sqlauncher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="sg.rp.sdma.intake3.lab05.OverviewActivity"
        android:screenOrientation="portrait"
        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="sg.rp.sdma.intake3.lab05.SpellingList"
        android:label="@string/action_viewslist"
        android:screenOrientation="portrait"
        android:parentActivityName="sg.rp.sdma.intake3.lab05.OverviewActivity" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="sg.rp.sdma.intake3.lab05.OverviewActivity" />
    </activity>
    <activity
        android:name="sg.rp.sdma.intake3.lab05.EditWordActivity"
        android:label="@string/title_activity_edit_idea"
        android:screenOrientation="portrait"
        android:parentActivityName="sg.rp.sdma.intake3.lab05.SpellingList" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="sg.rp.sdma.intake3.lab05.SpellingList" />
    </activity>
    <activity
        android:name="sg.rp.sdma.intake3.lab05.SpellRecord"
        android:screenOrientation="portrait"
        android:label="@string/title_activity_record" >
    </activity>
    <activity
        android:name="sg.rp.sdma.intake3.lab05.QuizActivity"
        android:screenOrientation="portrait"
        android:label="@string/title_activity_quiz"
        android:parentActivityName="sg.rp.sdma.intake3.lab05.SpellingList" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="sg.rp.sdma.intake3.lab05.SpellingList" />
    </activity>
    <activity
        android:name="sg.rp.sdma.intake3.lab05.SpellRecordActivity"
        android:screenOrientation="portrait"
        android:label="@string/title_activity_spell_record" >
    </activity>
    <activity
        android:name="sg.rp.sdma.intake3.lab05.ScoreActivity"
        android:screenOrientation="portrait"
        android:label="@string/title_activity_score" >
    </activity>
</application>

OverViewActivity:

package sg.rp.sdma.intake3.lab05;

import java.util.Random;

import sg.rp.sdma.intake3.lab05.R;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.graphics.Color;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;

public class OverviewActivity extends Activity {

String eYo2;
int myCD;
int mySCORE;
int ideaslth;

String rantitle;
int CId;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_overview);
    Button btnNew = (Button) findViewById(R.id.buttonAdd);
    btnNew.setBackgroundResource(R.drawable.blackbtntrans);

    Button btnTest = (Button) findViewById(R.id.buttonTest);
    btnTest.setBackgroundResource(R.drawable.blackbtntrans);
    btnTest.setClickable(false);
    btnTest.setVisibility(View.INVISIBLE);



    loadSavedPreferences();

    btnNew.setOnClickListener(new OnClickListener(){
        @Override
        public void onClick(View v) {
            String title = ((EditText)
                    findViewById(R.id.editTextTitle)).getText().toString();

            if (!title.matches("")){

                Ideas i = new Ideas(OverviewActivity.this);
                //String title = ((EditText)findViewById(R.id.editTextTitle)).getText().toString();
                eYo2 = title;

                String description = ((EditText) 
                        findViewById(R.id.editTextDescription)).getText().toString();

                i.addIdea(new Idea(0, title, description, 0));
                /*Toast.makeText(getApplicationContext(), ""+ title + " successfully added",
                        Toast.LENGTH_LONG).show();*/

                //reload();

                Intent i4 = new Intent(OverviewActivity.this, 
                        SpellRecordActivity.class);

                i4.putExtra("dataN", eYo2);
                /*Toast.makeText(getApplicationContext(), ""+ eYo2 + " placed in bundle",
                        Toast.LENGTH_LONG).show();*/
                Log.d("hah es", "put extra succeeded");

                startActivityForResult(i4, 1);
            }
            else {
                Toast.makeText(getApplicationContext(), "Please type a word before adding",
                        Toast.LENGTH_LONG).show();
            }
        }
    }           
            );

    btnTest.setOnClickListener(new OnClickListener(){
        @Override
        public void onClick(View v) {

            if (ideaslth > 0) {

            Intent i0 = new Intent(OverviewActivity.this, 
                    QuizActivity.class);
            Log.d("hah id", "int declared");

            i0.putExtra("dataR", rantitle);
            Log.d("hah es2", "put extra2 succeeded");
            myCD = 9;
            mySCORE = 0;
            savePreferences("Score", mySCORE);
            savePreferences("countDown", myCD);
            startActivityForResult(i0, 1);
            }

            else {
                Toast.makeText(getApplicationContext(), "Your list is currently empty",
                        Toast.LENGTH_LONG).show();
            }

        }           
    });




    ShowExistingIdeas();
}

public void reload() { 
    Intent intent = getIntent();  
    overridePendingTransition(0, 0);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);  
    finish();  
    overridePendingTransition(0, 0); 
    startActivity(intent);
}

private void RandomTitle() {
    Idea[] ideas = new Ideas(this).getAllIdeas();
    if(ideas != null && ideas.length > 0)
    {
        for(int index = 0; index < ideas.length; index++)
        {
            Random r = new Random();
            int in1=r.nextInt(ideas.length) + 0;
            //CId = in1;
            rantitle = (ideas[in1].getTitle());
            Log.d("hah es2", "lets see" + rantitle);
        }           
    }


}



private void ShowExistingIdeas() {
    Idea[] ideas = new Ideas(this).getAllIdeas();
    ideaslth = ideas.length;
    if(ideas != null && ideas.length > 0)
    {
        for(int index = 0; index < ideas.length; index++)
        {

            Button ideaButton = new Button(this);
            ideaButton.setText(ideas[index].getTitle());
            ideaButton.setTextColor(getResources().getColor(R.color.orange));
            ideaButton.setBackgroundResource(R.drawable.wordbtn);
            final int id = ideas[index].getId();
            ideaButton.setTag(id);      
            RandomTitle();
            ideaButton.setOnClickListener(new OnClickListener(){
                @Override
                public void onClick(View v) {
                    Intent i = new Intent(OverviewActivity.this, 
                            EditWordActivity.class);
                    i.putExtra("id", id);
                    startActivityForResult(i, 0);
                }           
            });

            ((LinearLayout) findViewById(R.id.LinearLayout2)).
            addView(ideaButton);

        }
    }
}

@Override
protected void onActivityResult( int aRequestCode, int aResultCode, Intent aData) { 
    reload();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.overview, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
    case R.id.slist:
        Intent il = new Intent(OverviewActivity.this, 
                SpellingList.class);
        startActivityForResult(il,1);
        break;
    case R.id.etest:
        if (ideaslth > 0) {

            Intent i0 = new Intent(OverviewActivity.this, 
                    QuizActivity.class);
            Log.d("hah id", "int declared");

            i0.putExtra("dataR", rantitle);
            Log.d("hah es2", "put extra2 succeeded");
            myCD = 9;
            mySCORE = 0;
            savePreferences("Score", mySCORE);
            savePreferences("countDown", myCD);
            startActivityForResult(i0, 1);
            }

            else {
                Toast.makeText(getApplicationContext(), "Your list is currently empty",
                        Toast.LENGTH_LONG).show();
            }

        break;

    case R.id.dict:

        String url = "http://www.dictionary.com";
        Intent idict = new Intent(Intent.ACTION_VIEW);
        idict.setData(Uri.parse(url));

        if (AppStatus.getInstance(this).isOnline(this)) {

            startActivity(idict);

        } else {

            Toast.makeText(this,"Please connect to the internet",8000).show();

        }


        break;

    default:
        return super.onOptionsItemSelected(item);
    }

    return true;
}



private void loadSavedPreferences(){
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    Integer countdown = sharedPreferences.getInt("countDown", 9);
    myCD = countdown;
    Integer score = sharedPreferences.getInt("Score", 0);
    mySCORE = score;

}

private void savePreferences(String key, int value) {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    Editor editor = sharedPreferences.edit();
    editor.putInt(key, value);
    editor.commit();
}

}

0 个答案:

没有答案