I am currently creating an Android app and am trying to solve this problem. Whenever I compile my code and port it to the emulator, it first loads with these errors:
05-22 00:12:54.753: W/dalvikvm(1631): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
05-22 00:12:54.783: E/AndroidRuntime(1631): FATAL EXCEPTION: main
05-22 00:12:54.783: E/AndroidRuntime(1631): java.lang.RuntimeException: Unable to instantiate application android.app.Application: java.lang.NullPointerException
05-22 00:12:54.783: E/AndroidRuntime(1631): at android.app.LoadedApk.makeApplication(LoadedApk.java:482)
05-22 00:12:54.783: E/AndroidRuntime(1631): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3938)
05-22 00:12:54.783: E/AndroidRuntime(1631): at android.app.ActivityThread.access$1300(ActivityThread.java:123)
05-22 00:12:54.783: E/AndroidRuntime(1631): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1185)
05-22 00:12:54.783: E/AndroidRuntime(1631): at android.os.Handler.dispatchMessage(Handler.java:99)
05-22 00:12:54.783: E/AndroidRuntime(1631): at android.os.Looper.loop(Looper.java:137)
05-22 00:12:54.783: E/AndroidRuntime(1631): at android.app.ActivityThread.main(ActivityThread.java:4424)
05-22 00:12:54.783: E/AndroidRuntime(1631): at java.lang.reflect.Method.invokeNative(Native Method)
05-22 00:12:54.783: E/AndroidRuntime(1631): at java.lang.reflect.Method.invoke(Method.java:511)
05-22 00:12:54.783: E/AndroidRuntime(1631): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-22 00:12:54.783: E/AndroidRuntime(1631): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-22 00:12:54.783: E/AndroidRuntime(1631): at dalvik.system.NativeStart.main(Native Method)
05-22 00:12:54.783: E/AndroidRuntime(1631): Caused by: java.lang.NullPointerException
05-22 00:12:54.783: E/AndroidRuntime(1631): at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:362)
05-22 00:12:54.783: E/AndroidRuntime(1631): at android.app.LoadedApk.getClassLoader(LoadedApk.java:305)
05-22 00:12:54.783: E/AndroidRuntime(1631): at android.app.LoadedApk.makeApplication(LoadedApk.java:474)
05-22 00:12:54.783: E/AndroidRuntime(1631): ... 11 more
Then it pushes me out of the application with a force shutdown, but it automatically recovers after automatically and works fine. If I close the application and kill it, it will not close anyone. Just when it is initially loaded on the emulator. I was wondering what would be the reason for this. Here are the messages that appear after downloading a second time:
05-22 00:13:07.113: D/dalvikvm(1664): GC_FOR_ALLOC freed 38K, 3% free 9110K/9347K, paused 61ms
05-22 00:13:07.165: I/dalvikvm-heap(1664): Grow heap (frag case) to 12.525MB for 3732496-byte allocation
05-22 00:13:07.263: D/dalvikvm(1664): GC_CONCURRENT freed 1K, 2% free 12754K/12999K, paused 5ms+5ms
05-22 00:13:07.543: D/dalvikvm(1664): GC_FOR_ALLOC freed <1K, 2% free 12755K/12999K, paused 37ms
05-22 00:13:07.573: I/dalvikvm-heap(1664): Grow heap (frag case) to 14.502MB for 2073616-byte allocation
05-22 00:13:07.753: D/dalvikvm(1664): GC_CONCURRENT freed <1K, 2% free 14780K/15047K, paused 5ms+5ms
05-22 00:13:08.033: D/gralloc_goldfish(1664): Emulator without GPU emulation detected.
I will supply you with any encoding you need, but unfortunately I do not know where this error is. I have many files inside my program, so I would prefer not to publish them all, if at all possible.
, , , ( ?) , , ,
splash.java
package com.food;
import com.food.odu.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class Splash extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Thread timer = new Thread(){
public void run(){
try{
sleep(5000);
} catch(InterruptedException e){
e.printStackTrace();
}finally{
Intent openStartingPoint = new Intent("com.rhodes.jacob.COM.FOOD.ODUACTIVITY");
startActivity(openStartingPoint);
}
}
};
timer.start();
}
@Override
protected void onPause() {
super.onPause();
finish();
}
}
oduActivity.java( , )
package com.food;
import com.food.odu.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class oduActivity extends Activity {
Button Cafe1201, Legends, Rogers, Faculty;
TextView display;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button Cafe1201 = (Button)findViewById(R.id.cafe1201);
Button Legends = (Button)findViewById(R.id.legends);
Button Rogers = (Button)findViewById(R.id.rogers);
Button Faculty = (Button)findViewById(R.id.fac_n_staff);
Cafe1201.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent whichCafe = new Intent(oduActivity.this,cafe1201.class);
startActivity(whichCafe);
}
});
Legends.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent whichCafe = new Intent(oduActivity.this,legends.class);
startActivity(whichCafe);
}
});
Rogers.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent whichCafe = new Intent(oduActivity.this,rogers.class);
startActivity(whichCafe);
}
});
Faculty.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent whichCafe = new Intent(oduActivity.this,faculty.class);
startActivity(whichCafe);
}
});
}
@Override
public boolean onCreateOptionsMenu(android.view.Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater blowUp = getMenuInflater();
blowUp.inflate(R.menu.menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()){
case R.id.main_page:
Intent whichOption = new Intent(oduActivity.this,oduActivity.class);
startActivity(whichOption);
break;
case R.id.other:
whichOption = new Intent(oduActivity.this,menu.class);
startActivity(whichOption);
break;
case R.id.aboutUs:
whichOption = new Intent(oduActivity.this,aboutUs.class);
startActivity(whichOption);
break;
case R.id.legal:
whichOption = new Intent(oduActivity.this,legal.class);
startActivity(whichOption);
break;
}
return false;
}
}