0

I am trying to integrate parse notification code which is working well into my existing android project....but it shows errors.... Heres my code MainActivity.java

public class MainActivity extends Activity implements OnClickListener{

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ParseAnalytics.trackAppOpenedInBackground(getIntent());
    PushService.setDefaultPushCallback(this, MainActivity.class);
    ParseInstallation.getCurrentInstallation().saveInBackground();

    Button ib=(Button) findViewById(R.id.about);
    Button ib1=(Button) findViewById(R.id.sponsors);
    Button ib2=(Button) findViewById(R.id.events);
    Button ib3=(Button) findViewById(R.id.gallery);
    Button ib4=(Button) findViewById(R.id.faq);
    Button ib5=(Button) findViewById(R.id.contact);
    Typeface f=Typeface.createFromAsset(getAssets(), "RECOGNITION.ttf");
    ib.setTypeface(f);
    ib1.setTypeface(f);
    ib2.setTypeface(f);
    ib3.setTypeface(f);
    ib4.setTypeface(f);
    ib5.setTypeface(f);
    ib.setOnClickListener(this);
    ib1.setOnClickListener(this);
    ib2.setOnClickListener(this);
    ib3.setOnClickListener(this);
    ib4.setOnClickListener(this);
    ib5.setOnClickListener(this);
}

@Override
public void onClick(View arg0) {
    // TODO Auto-generated method stub
    switch(arg0.getId())
    {
    case R.id.about:
        Intent i=new Intent("com.svu.rhapsody.ABOUT");
        startActivity(i);

        break;
    case R.id.sponsors:


        break;
    case R.id.events:
        Intent j=new Intent("com.svu.rhapsody.EVENTS");
        startActivity(j);

        break;
    case R.id.gallery:
        Intent k=new Intent("com.svu.rhapsody.GALLERY");
        startActivity(k);

        break;
    case R.id.faq:
        Intent p=new Intent("com.svu.rhapsody.FAQ");
        startActivity(p);
        break;
    case R.id.contact:

        break;
    }

}

ParseApplication.java

public class ParseApplication extends Application{

@Override
public void onCreate() {
    // TODO Auto-generated method stub
    super.onCreate();
    Parse.initialize(this, APP, SECRET);

    ParseUser.enableAutomaticUser();
    ParseACL defaultACL = new ParseACL();
    defaultACL.setPublicReadAccess(true);
    ParseACL.setDefaultACL(defaultACL, true);


    ParseInstallation.getCurrentInstallation().saveInBackground();
}

Receiver.java

public class Receiver extends ParsePushBroadcastReceiver{

@Override
protected void onPushOpen(Context arg0, Intent arg1) {
    // TODO Auto-generated method stub
    super.onPushOpen(arg0, arg1);
    Intent i = new Intent(arg0,MainActivity.class);
    i.putExtras(arg1.getExtras());
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    arg0.startActivity(i);
}

AndroidManifest.xml

<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="11" />
 <uses-permission android:name="android.permission.INTERNET"/>
 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
 <uses-permission android:name="android.permission.VIBRATE" />
 <uses-permission android:name="android.permission.WAKE_LOCK"/>
 <uses-permission android:name="android.permission.GET_ACCOUNTS" />
 <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
 <permission android:protectionLevel="signature"
 android:name="com.example.parse.permission.C2D_MESSAGE" />
 <uses-permission android:name="com.example.parse.permission.C2D_MESSAGE" />

<application
    android:allowBackup="true"
    android:name="com.svu.rhapsody.ParseApplication"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" 
    >
    <activity
        android:name="com.svu.rhapsody.Back"
        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.svu.rhapsody.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.svu.rhapsody.MAINACTIVITY" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.svu.rhapsody.About"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.svu.rhapsody.ABOUT" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.svu.rhapsody.Events"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.svu.rhapsody.EVENTS" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.svu.rhapsody.Gallery"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.svu.rhapsody.GALLERY" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.svu.rhapsody.Faq"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.svu.rhapsody.FAQ" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.svu.rhapsody.Register"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.svu.rhapsody.REGISTER" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.svu.rhapsody.Sing"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.svu.rhapsody.SING" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity><activity
        android:name="com.svu.rhapsody.Treasure"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.svu.rhapsody.TREASURE" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.svu.rhapsody.Email"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.svu.rhapsody.EMAIL" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <service android:name="com.parse.PushService" />
    <receiver android:name="com.parse.ParseBroadcastReceiver" >
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
            <action android:name="android.intent.action.USER_PRESENT" />
        </intent-filter>
    </receiver>

    <receiver 
        android:name="com.svu.rhapsody.Receiver"
        android:exported="false"  >
        <intent-filter>
            <action android:name="com.parse.push.intent.RECEIVE" />
            <action android:name="com.parse.push.intent.DELETE" />
            <action android:name="com.parse.push.intent.OPEN" />
        </intent-filter>
    </receiver>


</application>

</manifest>

Logcat Details :

04-26 02:08:51.595: I/dalvikvm(877): Could not find method    com.parse.Parse.initialize, referenced from method   com.svu.rhapsody.ParseApplication.onCreate

04-26 02:08:51.595: W/dalvikvm(877): VFY: unable to resolve static method 40: Lcom/parse/Parse;.initialize (Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)V 04-26 02:08:51.595: D/dalvikvm(877): VFY: replacing opcode 0x71 at 0x0008 04-26 02:08:51.633: D/AndroidRuntime(877): Shutting down VM 04-26 02:08:51.635: W/dalvikvm(877): threadid=1: thread exiting with uncaught exception (group=0x40014760) 04-26 02:08:51.685: E/AndroidRuntime(877): FATAL EXCEPTION: main 04-26 02:08:51.685: E/AndroidRuntime(877): java.lang.NoClassDefFoundError: com.parse.Parse 04-26 02:08:51.685: E/AndroidRuntime(877): at com.svu.rhapsody.ParseApplication.onCreate(ParseApplication.java:16) 04-26 02:08:51.685: E/AndroidRuntime(877): at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:968) 04-26 02:08:51.685: E/AndroidRuntime(877): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3580) 04-26 02:08:51.685: E/AndroidRuntime(877): at android.app.ActivityThread.access$2200(ActivityThread.java:123) 04-26 02:08:51.685: E/AndroidRuntime(877): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1031) 04-26 02:08:51.685: E/AndroidRuntime(877): at android.os.Handler.dispatchMessage(Handler.java:99) 04-26 02:08:51.685: E/AndroidRuntime(877): at android.os.Looper.loop(Looper.java:126) 04-26 02:08:51.685: E/AndroidRuntime(877): at android.app.ActivityThread.main(ActivityThread.java:3997) 04-26 02:08:51.685: E/AndroidRuntime(877): at java.lang.reflect.Method.invokeNative(Native Method) 04-26 02:08:51.685: E/AndroidRuntime(877): at java.lang.reflect.Method.invoke(Method.java:491) 04-26 02:08:51.685: E/AndroidRuntime(877): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841) 04-26 02:08:51.685: E/AndroidRuntime(877): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599) 04-26 02:08:51.685: E/AndroidRuntime(877): at dalvik.system.NativeStart.main(Native Method) 04-26 02:13:51.835: I/Process(877): Sending signal. PID: 877 SIG: 9

async
  • 1,537
  • 11
  • 28
Sai Kumar
  • 9
  • 4

1 Answers1

0

In your logs you can find that you got java.lang.NoClassDefFoundError. You can check this answer, hope it'll help

Community
  • 1
  • 1
Oleg Osipenko
  • 2,409
  • 1
  • 20
  • 28