Crash when using Google Play Game Services (Unity3d in Android) - android

I have a problem. I am developing a game in Unity3d which uses the official Facebook SDK and NerdGPG for Google Play Game Services. However, there is an annoying bug:
WHen I want to see the Achievements or Leaderboards, it opnes the UI, but AFTER I CLOSE the UI, then the game crashes. The Logcat tells the following:
03-05 00:09:54.325: E/AndroidRuntime(10810): Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=9002, result=0, data=null} to activity {com.radioactivewasp.flyingwasp/com.facebook.unity.FBUnityPlayerActivity}: java.lang.NullPointerException
03-05 00:09:54.325: E/AndroidRuntime(10810): at android.app.ActivityThread.deliverResults(ActivityThread.java:3182)
03-05 00:09:54.325: E/AndroidRuntime(10810): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3225)
03-05 00:09:54.325: E/AndroidRuntime(10810): at android.app.ActivityThread.access$1100(ActivityThread.java:140)
03-05 00:09:54.325: E/AndroidRuntime(10810): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1275)
03-05 00:09:54.325: E/AndroidRuntime(10810): at android.os.Handler.dispatchMessage(Handler.java:99)
03-05 00:09:54.325: E/AndroidRuntime(10810): at android.os.Looper.loop(Looper.java:137)
03-05 00:09:54.325: E/AndroidRuntime(10810): at android.app.ActivityThread.main(ActivityThread.java:4898)
03-05 00:09:54.325: E/AndroidRuntime(10810): at java.lang.reflect.Method.invokeNative(Native Method)
03-05 00:09:54.325: E/AndroidRuntime(10810): at java.lang.reflect.Method.invoke(Method.java:511)
03-05 00:09:54.325: E/AndroidRuntime(10810): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
03-05 00:09:54.325: E/AndroidRuntime(10810): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
03-05 00:09:54.325: E/AndroidRuntime(10810): at dalvik.system.NativeStart.main(Native Method)
03-05 00:09:54.325: E/AndroidRuntime(10810): Caused by: java.lang.NullPointerException
03-05 00:09:54.325: E/AndroidRuntime(10810): at com.facebook.unity.FBUnityPlayerActivity.onActivityResult(FBUnityPlayerActivity.java:15)
03-05 00:09:54.325: E/AndroidRuntime(10810): at android.app.Activity.dispatchActivityResult(Activity.java:5390)
03-05 00:09:54.325: E/AndroidRuntime(10810): at android.app.ActivityThread.deliverResults(ActivityThread.java:3178)
Anybody know what could be the solution?

It looks like your Facebook plugin Activity doesn't know how to handle the onActivityResult() callback when you use the RC_UNUSED(9002) requestID.So I imagine you would want to modify your Facebook Player activity such that the NerdGPG plugin handles the callback.

Related

My application won't run on an emulator but it will run on my phone

I am trying test my application on an emulator but it will not work. However, it works fine on my phone. I have a Samsung Galaxy S2 with version 4.0.3. How do I create an emulator that will work with this?
These are the errors and here it is in pastebin http://pastebin.com/PR65kGxg:
03-05 15:03:16.777: W/Trace(856): Unexpected value from nativeGetEnabledTags: 0
03-05 15:03:16.967: W/Trace(856): Unexpected value from nativeGetEnabledTags: 0
03-05 15:03:16.967: W/Trace(856): Unexpected value from nativeGetEnabledTags: 0
03-05 15:03:17.387: W/GooglePlayServicesUtil(856): Google Play services out of date. Requires 2012100 but found 1015
03-05 15:03:17.427: W/GooglePlayServicesUtil(856): Google Play services out of date. Requires 2012100 but found 1015
03-05 15:03:17.467: W/GooglePlayServicesUtil(856): Google Play services out of date. Requires 2012100 but found 1015
03-05 15:03:17.497: W/GooglePlayServicesUtil(856): Google Play services out of date. Requires 2012100 but found 1015
03-05 15:03:17.527: W/GooglePlayServicesUtil(856): Google Play services out of date. Requires 2012100 but found 1015
03-05 15:03:17.887: W/GooglePlayServicesUtil(856): Google Play services out of date. Requires 2012100 but found 1015
03-05 15:03:17.887: D/AndroidRuntime(856): Shutting down VM
03-05 15:03:17.897: W/dalvikvm(856): threadid=1: thread exiting with uncaught exception (group=0x40a70930)
03-05 15:03:17.917: E/AndroidRuntime(856): FATAL EXCEPTION: main
03-05 15:03:17.917: E/AndroidRuntime(856): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.neatspots/com.example.neatspots.MainActivity}: java.lang.NullPointerException
03-05 15:03:17.917: E/AndroidRuntime(856): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
03-05 15:03:17.917: E/AndroidRuntime(856): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
03-05 15:03:17.917: E/AndroidRuntime(856): at android.app.ActivityThread.access$600(ActivityThread.java:141)
03-05 15:03:17.917: E/AndroidRuntime(856): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
03-05 15:03:17.917: E/AndroidRuntime(856): at android.os.Handler.dispatchMessage(Handler.java:99)
03-05 15:03:17.917: E/AndroidRuntime(856): at android.os.Looper.loop(Looper.java:137)
03-05 15:03:17.917: E/AndroidRuntime(856): at android.app.ActivityThread.main(ActivityThread.java:5039)
03-05 15:03:17.917: E/AndroidRuntime(856): at java.lang.reflect.Method.invokeNative(Native Method)
03-05 15:03:17.917: E/AndroidRuntime(856): at java.lang.reflect.Method.invoke(Method.java:511)
03-05 15:03:17.917: E/AndroidRuntime(856): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-05 15:03:17.917: E/AndroidRuntime(856): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-05 15:03:17.917: E/AndroidRuntime(856): at dalvik.system.NativeStart.main(Native Method)
03-05 15:03:17.917: E/AndroidRuntime(856): Caused by: java.lang.NullPointerException
03-05 15:03:17.917: E/AndroidRuntime(856): at com.example.neatspots.MainActivity.setMapDefaults(MainActivity.java:89)
03-05 15:03:17.917: E/AndroidRuntime(856): at com.example.neatspots.MainActivity.onCreate(MainActivity.java:73)
03-05 15:03:17.917: E/AndroidRuntime(856): at android.app.Activity.performCreate(Activity.java:5104)
03-05 15:03:17.917: E/AndroidRuntime(856): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
03-05 15:03:17.917: E/AndroidRuntime(856): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
03-05 15:03:17.917: E/AndroidRuntime(856): ... 11 more
03-05 15:03:18.187: D/dalvikvm(856): GC_CONCURRENT freed 244K, 13% free 2530K/2892K, paused 8ms+71ms, total 260ms
03-05 15:03:37.127: I/Process(856): Sending signal. PID: 856 SIG: 9
This is line 89:
public void setMapDefaults()
{
map.setMapType(GoogleMap.MAP_TYPE_NORMAL); //line 89
map.setMyLocationEnabled(true);
}
Create a new virtual device and in target select Google API level 17 and it will work.
Your app uses maps API so check if emulator has Google APIs 4.0 target, not a simple Android 4.0
Ok. I had a read of the SO guidelines of duplicates and deemed this question different enough to this question in order to merit an answer which states "this could be the same problem as this question" type answer/comment thing. Any moderators out feel free to tidy this up.
Basically- Jonathan's code is fine despite the NPE. It's likely the emulator-Google V2 Play Service compatibility issue.

error when retrieving a record from the data base?

I'm trying to retrieve a name stred in SQLite table, despite the database has 11 or more records, when I try to retrieve any name from the stored records, The App. Crashs.
Java code:
OnClickListener btn_NavaigateListsner = new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (!btn_Save.isEnabled()) {
int c = mpoh.getCurrentRowNumber();
Toast.makeText(getBaseContext(), ""+mpoh.getMP_Name(0), Toast.LENGTH_SHORT).show();
Bundle bundle = new Bundle();
//bundle.putString("name", mpoh.getMP_Name(c));
//bundle.putDouble("lat", mpoh.getMP_Lat(c));
//bundle.putDouble("lng", mpoh.getMP_Lng(c));
//bundle.putString("date", mpoh.getMP_Date(c));
//bundle.putString("time", mpoh.getMP_Time(c));
intent01 = new Intent(MPData.this, MPInfo.class);
intent01.putExtras(bundle);
startActivity(intent01);
}// End of If
}
};
Method that retrieves the stored name:
public String getMP_Name(long id) {
SQLiteDatabase db = this.getReadableDatabase();
SQLiteCursor c = (SQLiteCursor) db.rawQuery("SELECT name FROM MPData WHERE "+
BaseColumns._ID+" = "+
Long.toString(id) +" AND name IS NOT NULL ", null);
c.moveToFirst();
String r = c.getString(0);
c.close();
db.close();
return r;
}
some of LogCat's output:
03-05 12:16:48.288: E/AndroidRuntime(973): FATAL EXCEPTION: main
03-05 12:16:48.288: E/AndroidRuntime(973): android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
03-05 12:16:48.288: E/AndroidRuntime(973): at android.database.AbstractCursor.checkPosition(AbstractCursor.java:580)
03-05 12:16:48.288: E/AndroidRuntime(973): at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:214)
03-05 12:16:48.288: E/AndroidRuntime(973): at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:41)
03-05 12:16:48.288: E/AndroidRuntime(973): at com.androidbook.MP.MP_DB.getMP_Name(MP_DB.java:45)
03-05 12:16:48.288: E/AndroidRuntime(973): at com.androidbook.MP.MPData$1.onClick(MPData.java:57)
03-05 12:16:48.288: E/AndroidRuntime(973): at android.view.View.performClick(View.java:2485)
03-05 12:16:48.288: E/AndroidRuntime(973): at android.view.View$PerformClick.run(View.java:9080)
03-05 12:16:48.288: E/AndroidRuntime(973): at android.os.Handler.handleCallback(Handler.java:587)
03-05 12:16:48.288: E/AndroidRuntime(973): at android.os.Handler.dispatchMessage(Handler.java:92)
03-05 12:16:48.288: E/AndroidRuntime(973): at android.os.Looper.loop(Looper.java:130)
03-05 12:16:48.288: E/AndroidRuntime(973): at android.app.ActivityThread.main(ActivityThread.java:3683)
03-05 12:16:48.288: E/AndroidRuntime(973): at java.lang.reflect.Method.invokeNative(Native Method)
03-05 12:16:48.288: E/AndroidRuntime(973): at java.lang.reflect.Method.invoke(Method.java:507)
03-05 12:16:48.288: E/AndroidRuntime(973): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-05 12:16:48.288: E/AndroidRuntime(973): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-05 12:16:48.288: E/AndroidRuntime(973): at dalvik.system.NativeStart.main(Native Method)
03-05 12:32:19.897: E/AndroidRuntime(1022): FATAL EXCEPTION: main
03-05 12:32:19.897: E/AndroidRuntime(1022): android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
03-05 12:32:19.897: E/AndroidRuntime(1022): at android.database.AbstractCursor.checkPosition(AbstractCursor.java:580)
03-05 12:32:19.897: E/AndroidRuntime(1022): at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:214)
03-05 12:32:19.897: E/AndroidRuntime(1022): at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:41)
03-05 12:32:19.897: E/AndroidRuntime(1022): at com.androidbook.MP.MP_DB.getMP_Name(MP_DB.java:45)
03-05 12:32:19.897: E/AndroidRuntime(1022): at com.androidbook.MP.MPData$1.onClick(MPData.java:57)
03-05 12:32:19.897: E/AndroidRuntime(1022): at android.view.View.performClick(View.java:2485)
03-05 12:32:19.897: E/AndroidRuntime(1022): at android.view.View$PerformClick.run(View.java:9080)
03-05 12:32:19.897: E/AndroidRuntime(1022): at android.os.Handler.handleCallback(Handler.java:587)
03-05 12:32:19.897: E/AndroidRuntime(1022): at android.os.Handler.dispatchMessage(Handler.java:92)
03-05 12:32:19.897: E/AndroidRuntime(1022): at android.os.Looper.loop(Looper.java:130)
03-05 12:32:19.897: E/AndroidRuntime(1022): at android.app.ActivityThread.main(ActivityThread.java:3683)
03-05 12:32:19.897: E/AndroidRuntime(1022): at java.lang.reflect.Method.invokeNative(Native Method)
03-05 12:32:19.897: E/AndroidRuntime(1022): at java.lang.reflect.Method.invoke(Method.java:507)
03-05 12:32:19.897: E/AndroidRuntime(1022): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-05 12:32:19.897: E/AndroidRuntime(1022): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-05 12:32:19.897: E/AndroidRuntime(1022): at dalvik.system.NativeStart.main(Native Method)
03-05 12:39:24.627: E/AndroidRuntime(1093): FATAL EXCEPTION: main
03-05 12:39:24.627: E/AndroidRuntime(1093): android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.database.AbstractCursor.checkPosition(AbstractCursor.java:580)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:214)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:41)
03-05 12:39:24.627: E/AndroidRuntime(1093): at com.androidbook.MP.MP_DB.getMP_Name(MP_DB.java:45)
03-05 12:39:24.627: E/AndroidRuntime(1093): at com.androidbook.MP.MPData$1.onClick(MPData.java:57)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.view.View.performClick(View.java:2485)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.view.View.onKeyUp(View.java:4257)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.widget.TextView.onKeyUp(TextView.java:4587)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.view.KeyEvent.dispatch(KeyEvent.java:1280)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.view.View.dispatchKeyEvent(View.java:3855)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:789)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:789)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:789)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:789)
03-05 12:39:24.627: E/AndroidRuntime(1093): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1687)
03-05 12:39:24.627: E/AndroidRuntime(1093): at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1120)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.app.Activity.dispatchKeyEvent(Activity.java:2073)
03-05 12:39:24.627: E/AndroidRuntime(1093): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1663)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2560)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2535)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.view.ViewRoot.handleMessage(ViewRoot.java:1867)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.os.Handler.dispatchMessage(Handler.java:99)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.os.Looper.loop(Looper.java:130)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.app.ActivityThread.main(ActivityThread.java:3683)
03-05 12:39:24.627: E/AndroidRuntime(1093): at java.lang.reflect.Method.invokeNative(Native Method)
03-05 12:39:24.627: E/AndroidRuntime(1093): at java.lang.reflect.Method.invoke(Method.java:507)
03-05 12:39:24.627: E/AndroidRuntime(1093): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-05 12:39:24.627: E/AndroidRuntime(1093): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-05 12:39:24.627: E/AndroidRuntime(1093): at dalvik.system.NativeStart.main(Native Method)
The code looks fine to me. Are you 100% sure you have an entry in your DB with an _id corresponding to 0?
If you call getMP_Name with an invalid _id then the exception will get raised as you posted it.
You should check for this case as follows:
if (c.getCount()==0) return "";
// rest of code
But I wouldn't do it like this anyway because your current implementation of getMP_XXX is very inefficient because you hit the database for each field and each row. You should minimise your number of queries and then iterate over the resulting cursor.
Look at the following line :
String r = c.getString(0);
You are not safe checking your cursor and just assuming a result was recieved.
Check you SQL query and add a safe check for making sure your cursor has retrieved results.

Android App ForceCloses on Starting of a new activity

I am new to android development and I have been having issues with Force Close on new Android Activity Pages.
My Structure is like this:
Main Page -> Menu Page (Works Fine) -> New Game Screen(force closes)
Call to the Activity:
public void btnNewGame_Click(View view)
{
Intent i = new Intent(this, NewGameScreen.class);
startActivityForResult(i, ACTIVITY_CREATE);
}
Manifest
<activity android:name=".NewGameScreen"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ExpandableListView
android:id="#+id/eLVGameList"
android:layout_width="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight=".75"
android:background="#null" android:layout_height="0dip">
</ExpandableListView>
</LinearLayout>
NewGameScreenActivity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.loadgame);
ExpandableListView epView = (ExpandableListView) findViewById(R.id.eLVGameList);
ExpandableListAdapter mAdapter = new GameListAdapter();
epView.setAdapter(mAdapter);
Errors:
03-05 20:16:57.375: E/AndroidRuntime(887): FATAL EXCEPTION: main
03-05 20:16:57.375: E/AndroidRuntime(887): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.helloandroid/com.example.helloandroid.NewGameScreen}: java.lang.RuntimeException: Your content must have a ExpandableListView whose id attribute is 'android.R.id.list'
03-05 20:16:57.375: E/AndroidRuntime(887): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
03-05 20:16:57.375: E/AndroidRuntime(887): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
03-05 20:16:57.375: E/AndroidRuntime(887): at android.app.ActivityThread.access$600(ActivityThread.java:123)
03-05 20:16:57.375: E/AndroidRuntime(887): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
03-05 20:16:57.375: E/AndroidRuntime(887): at android.os.Handler.dispatchMessage(Handler.java:99)
03-05 20:16:57.375: E/AndroidRuntime(887): at android.os.Looper.loop(Looper.java:137)
03-05 20:16:57.375: E/AndroidRuntime(887): at android.app.ActivityThread.main(ActivityThread.java:4424)
03-05 20:16:57.375: E/AndroidRuntime(887): at java.lang.reflect.Method.invokeNative(Native Method)
03-05 20:16:57.375: E/AndroidRuntime(887): at java.lang.reflect.Method.invoke(Method.java:511)
03-05 20:16:57.375: E/AndroidRuntime(887): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-05 20:16:57.375: E/AndroidRuntime(887): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-05 20:16:57.375: E/AndroidRuntime(887): at dalvik.system.NativeStart.main(Native Method)
03-05 20:16:57.375: E/AndroidRuntime(887): Caused by: java.lang.RuntimeException: Your content must have a ExpandableListView whose id attribute is 'android.R.id.list'
03-05 20:16:57.375: E/AndroidRuntime(887): at android.app.ExpandableListActivity.onContentChanged(ExpandableListActivity.java:222)
03-05 20:16:57.375: E/AndroidRuntime(887): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:254)
03-05 20:16:57.375: E/AndroidRuntime(887): at android.app.Activity.setContentView(Activity.java:1835)
03-05 20:16:57.375: E/AndroidRuntime(887): at com.example.helloandroid.NewGameScreen.onCreate(NewGameScreen.java:22)
03-05 20:16:57.375: E/AndroidRuntime(887): at android.app.Activity.performCreate(Activity.java:4465)
03-05 20:16:57.375: E/AndroidRuntime(887): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
03-05 20:16:57.375: E/AndroidRuntime(887): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
03-05 20:16:57.375: E/AndroidRuntime(887): ... 11 more
Change your ExpandableListView id with this
android:id="#android:id/list"
and if your class extends Activity then change it to
public class className extends ListActivity
and you can get your ExpandableListView by calling the method
ExpandableListView listView = getListView();
The answer is very simple, you just forgot to insert the NewGameScreen Activity's Entry in the AndroidManiFest.xml Write down following line in your AndroidManifest.xml file before the tag.
<activity android:name=".NewGameScreen"></activity>
And also important thing that your NewGameScreen class must extends Activity
You need to give the id of your ListView as android:id="#android:id/list" , if you are extending LIstActivity. Then you can get your ListView handler from getLIstView();
If you are extending Activity, then you can give any other id to your ListView and get it using findViewbyId()
From the LOgCat trace, it looks like you are using ListActivity.

Application built for API 8 does not work with API 7 - what goes wrong?

Hey guys
I simply want to downgrade my api level 8 to 7 so that i can run the
application both on 2.2 and 2.1 devices.
The application is running perfectly fine on 2.2 and is having problem
working on 2.1
I have done changes in manifest.xml and project -> properties
My application basically uses sax parser , facebook sdk , twitter
connect
This is the log cat:
03-05 12:32:13.553: WARN/dalvikvm(232): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
03-05 12:32:13.563: ERROR/AndroidRuntime(232): Uncaught handler: thread main exiting due to uncaught exception
03-05 12:32:13.623: ERROR/AndroidRuntime(232): java.lang.NullPointerException
03-05 12:32:13.623: ERROR/AndroidRuntime(232): at com.test.activity.MyActivity$FetchTopMusic.onPostExecute(MusicScreen.java:161)
03-05 12:32:13.623: ERROR/AndroidRuntime(232): at com.test.activity.MyActivity$FetchTopMusic.onPostExecute(MusicScreen.java:1)
03-05 12:32:13.623: ERROR/AndroidRuntime(232): at android.os.AsyncTask.finish(AsyncTask.java:417)
03-05 12:32:13.623: ERROR/AndroidRuntime(232): at android.os.AsyncTask.access$300(AsyncTask.java:127)
03-05 12:32:13.623: ERROR/AndroidRuntime(232): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
03-05 12:32:13.623: ERROR/AndroidRuntime(232): at android.os.Handler.dispatchMessage(Handler.java:99)
03-05 12:32:13.623: ERROR/AndroidRuntime(232): at android.os.Looper.loop(Looper.java:123)
03-05 12:32:13.623: ERROR/AndroidRuntime(232): at android.app.ActivityThread.main(ActivityThread.java:4363)
03-05 12:32:13.623: ERROR/AndroidRuntime(232): at java.lang.reflect.Method.invokeNative(Native Method)
03-05 12:32:13.623: ERROR/AndroidRuntime(232): at java.lang.reflect.Method.invoke(Method.java:521)
03-05 12:32:13.623: ERROR/AndroidRuntime(232): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
03-05 12:32:13.623: ERROR/AndroidRuntime(232): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
03-05 12:32:13.623: ERROR/AndroidRuntime(232): at dalvik.system.NativeStart.main(Native Method)
And i get this message after the splash screen.
Music Screen has async task which is calling various classes in various packages for parsing the xml content.
Is this a problem in xml parser??
The line 161 is :-
for (int i = 0; i < tracks.size(); i++)
Where tracks is an arrayList and all this code is working fine in 2.2
Have you checked in the default properties and set the target to 7? Then check whether it is possible or not.
Let me know...

android Mediaplayer can not work in emulator

I'm begginer in android Programming
My Question is...
I wanted to play backgroud Music.
So I read a code like this
public class Welcome extends Activity {
/** Called when the activity is first created. */
MediaPlayer player;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
player=MediaPlayer.create(Welcome.this, R.raw.song);
player.start();
But this code doesn't work in emulator. Error occured...
My Logcat is here..
03-05 15:36:36.588: ERROR/AndroidRuntime(954): FATAL EXCEPTION: main
03-05 15:36:36.588: ERROR/AndroidRuntime(954): java.lang.RuntimeException: Unable to start activity ComponentInfo{younkyung.app.lord_of_spelling/younkyung.app.lord_of_spelling.Welcome}: java.lang.NullPointerException
03-05 15:36:36.588: ERROR/AndroidRuntime(954): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-05 15:36:36.588: ERROR/AndroidRuntime(954): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-05 15:36:36.588: ERROR/AndroidRuntime(954): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-05 15:36:36.588: ERROR/AndroidRuntime(954): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-05 15:36:36.588: ERROR/AndroidRuntime(954): at android.os.Handler.dispatchMessage(Handler.java:99)
03-05 15:36:36.588: ERROR/AndroidRuntime(954): at android.os.Looper.loop(Looper.java:123)
03-05 15:36:36.588: ERROR/AndroidRuntime(954): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-05 15:36:36.588: ERROR/AndroidRuntime(954): at java.lang.reflect.Method.invokeNative(Native Method)
03-05 15:36:36.588: ERROR/AndroidRuntime(954): at java.lang.reflect.Method.invoke(Method.java:521)
03-05 15:36:36.588: ERROR/AndroidRuntime(954): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-05 15:36:36.588: ERROR/AndroidRuntime(954): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-05 15:36:36.588: ERROR/AndroidRuntime(954): at dalvik.system.NativeStart.main(Native Method)
03-05 15:36:36.588: ERROR/AndroidRuntime(954): Caused by: java.lang.NullPointerException
03-05 15:36:36.588: ERROR/AndroidRuntime(954): at younkyung.app.lord_of_spelling.Welcome.onCreate(Welcome.java:25)
03-05 15:36:36.588: ERROR/AndroidRuntime(954): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-05 15:36:36.588: ERROR/AndroidRuntime(954): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-05 15:36:36.588: ERROR/AndroidRuntime(954): ... 11 more
I cannot understand what's wrong...
Please Help..! ...
You need to use one of the supported file formats. WMA is not one of them.

Categories

Resources