Retrieving data from database - android

I am trying to retrieve specific data like custom ads, username, date etc from database. so followed the code from this Need a simple tutorial for android/webservice work?. I'm going wrong some where can any one help as i am new to android.Getting following errors
11-13 21:57:14.720: E/AndroidRuntime(399): FATAL EXCEPTION: main
11-13 21:57:14.720: E/AndroidRuntime(399): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.response/com.response.FetchList}: java.lang.ClassCastException: com.response.FetchList
11-13 21:57:14.720: E/AndroidRuntime(399): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
11-13 21:57:14.720: E/AndroidRuntime(399): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-13 21:57:14.720: E/AndroidRuntime(399): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-13 21:57:14.720: E/AndroidRuntime(399): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-13 21:57:14.720: E/AndroidRuntime(399): at android.os.Handler.dispatchMessage(Handler.java:99)
11-13 21:57:14.720: E/AndroidRuntime(399): at android.os.Looper.loop(Looper.java:123)
11-13 21:57:14.720: E/AndroidRuntime(399): at android.app.ActivityThread.main(ActivityThread.java:4627)
11-13 21:57:14.720: E/AndroidRuntime(399): at java.lang.reflect.Method.invokeNative(Native Method)
11-13 21:57:14.720: E/AndroidRuntime(399): at java.lang.reflect.Method.invoke(Method.java:521)
11-13 21:57:14.720: E/AndroidRuntime(399): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-13 21:57:14.720: E/AndroidRuntime(399): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-13 21:57:14.720: E/AndroidRuntime(399): at dalvik.system.NativeStart.main(Native Method)
11-13 21:57:14.720: E/AndroidRuntime(399): Caused by: java.lang.ClassCastException: com.response.FetchList
11-13 21:57:14.720: E/AndroidRuntime(399): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
11-13 21:57:14.720: E/AndroidRuntime(399): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
Edit-
Manifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.response"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".Response"
android:label="#string/title_activity_response" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="android.support.v4.app.FragmentActivity" />
</activity>
<activity
android:name=".XMLParser"
android:label="#string/title_activity_response" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".FetchList"
android:label="#string/title_activity_response" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

If you've taken the code from that link exactly as-is, then you could be running into that error at the line,
public class FetchList extends asyncTask<Void,Void,Byte>{
doinbackground{
Which would actually be
public class FetchList extends asyncTask<Void, Void, Byte> {
#Override
protected Byte doInBackground (Void... voids){
...
}
}
EDIT: From the code in your comment,
public class FetchList extends AsyncTask<Void,Void,Byte>{
#Override
protected Byte doInBackground1(Void... arg0){
// this was explained in first step
Response res = new Response("url");
String response = res.getResponse();
XMLParser xml = new XMLParser(response);
ArrayList<XMLParser> itemList = xml.getItemList();
return xml.parse();
}
}
In this case let me know what the Logcat output is.

Related

Errors in a testing android project

I'm trying to run this code (android app):
manifest file:
<<<<<<< Original
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testamish"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".Results"
android:label="#string/title_activity_results" >
</activity>
<activity
android:name=".SpinnerDemo"
android:label="#string/title_activity_spinner_demo" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
=======
<manifest xmlns:android="http://schemas.android.com/apk/res/android" >
<application>
<activity android:name="com.example.testamish.MainActivity"
android:label="#string/title_activity_main"
>
</activity>
</application>
</manifest>
>>>>>>> Added
However, when trying to launch this on a virtual device, I get those errors and I don't get why (code has no errors/warnings):
10-17 17:07:22.685: E/Trace(819): error opening trace file: No such file or directory (2)
10-17 17:07:23.430: D/AndroidRuntime(819): Shutting down VM
10-17 17:07:23.430: W/dalvikvm(819): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
10-17 17:07:23.445: E/AndroidRuntime(819): FATAL EXCEPTION: main
10-17 17:07:23.445: E/AndroidRuntime(819): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.testamish/com.example.testamish.MainActivity}: java.lang.ClassNotFoundException: com.example.testamish.MainActivity
10-17 17:07:23.445: E/AndroidRuntime(819): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
10-17 17:07:23.445: E/AndroidRuntime(819): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
10-17 17:07:23.445: E/AndroidRuntime(819): at android.app.ActivityThread.access$600(ActivityThread.java:130)
10-17 17:07:23.445: E/AndroidRuntime(819): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
10-17 17:07:23.445: E/AndroidRuntime(819): at android.os.Handler.dispatchMessage(Handler.java:99)
10-17 17:07:23.445: E/AndroidRuntime(819): at android.os.Looper.loop(Looper.java:137)
10-17 17:07:23.445: E/AndroidRuntime(819): at android.app.ActivityThread.main(ActivityThread.java:4745)
10-17 17:07:23.445: E/AndroidRuntime(819): at java.lang.reflect.Method.invokeNative(Native Method)
10-17 17:07:23.445: E/AndroidRuntime(819): at java.lang.reflect.Method.invoke(Method.java:511)
10-17 17:07:23.445: E/AndroidRuntime(819): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
10-17 17:07:23.445: E/AndroidRuntime(819): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
10-17 17:07:23.445: E/AndroidRuntime(819): at dalvik.system.NativeStart.main(Native Method)
10-17 17:07:23.445: E/AndroidRuntime(819): Caused by: java.lang.ClassNotFoundException: com.example.testamish.MainActivity
10-17 17:07:23.445: E/AndroidRuntime(819): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
10-17 17:07:23.445: E/AndroidRuntime(819): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
10-17 17:07:23.445: E/AndroidRuntime(819): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
10-17 17:07:23.445: E/AndroidRuntime(819): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
10-17 17:07:23.445: E/AndroidRuntime(819): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
10-17 17:07:23.445: E/AndroidRuntime(819): ... 11 more
Thanks for your help!
Solution
Remove this from you Manifest (from the original one!):
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
And add this four line to the Activity, you want to start on launch:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Details
In Android, the data&actions between activities is driven by Intents. When you want to launch an app, it's kind an action between the Launcher app, and your app. It's also an Intent, when you start the Gallery, to choose an image for Facebook, or to start the Twitter app, to share something.
You can define in the Manifest.xml, for each Activity of your app, to which Intents to catch. You defined a MainActivity in your Manifest, and set to catch the android.intent.action.MAIN and android.intent.category.LAUNCHER intents. These two Intents responds, to start the app from the Launcher.
So the emulator was finding for your MainActivity, 'cause it read from you Manifest, to start that. But cannot found it, so throw an exception.

Google Map api v2 application stop working

I am trying to run Google maps API v2 on emulator. It says "unfortunately app has stoped" Here is my manifest.xml code. There is a huge number of errors. In the first line it gives error to define android.allowBackup which I have done on application tag.Please help me solve them.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permissionandroid:name="com.myapp.providers.gsf.permission.
READ_GSERVICES"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data android:name="com.google.android.gms.version" android:value="4030500" />
<!-- <meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" /> -->
<activity
android:name="com.myapp.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="My key"/>
</application>
</manifest>
----------------------------------------------------------------------------------------------
MainActivity.java
package myapp;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
public class MainActivity extends FragmentActivity {
private GoogleMap map;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SupportMapFragment mapFrag = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
map = mapFrag.getMap();
map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
}
}
------------------------------------------------------------------------------------
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.SupportMapFragment"/>
-----------------------------------------------------------------
Logcat
E/Trace(690): error opening trace file: No such file or directory (2)
E/AndroidRuntime(690): FATAL EXCEPTION: main
E/AndroidRuntime(690): java.lang.RuntimeException:
Unable to start activity
ComponentInfo{myapp/myapp.MainActivity}:android.view.InflateException: Binary XML file line #2:
Error inflating class fragment
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
android.app.ActivityThread.access$600(ActivityThread.java:130)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:137)
android.app.ActivityThread.main(ActivityThread.java:4745)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:511)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
dalvik.system.NativeStart.main(Native Method)
09-01 15:06:56.709: E/AndroidRuntime(690): Caused by: android.view.InflateException: Binary XML
file line #2: Error inflating class fragment
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
android.view.LayoutInflater.inflate(LayoutInflater.java:466)
android.view.LayoutInflater.inflate(LayoutInflater.java:396)
android.view.LayoutInflater.inflate(LayoutInflater.java:352)
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
android.app.Activity.setContentView(Activity.java:1867)
android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.
java:110)
android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
myapp.MainActivity.onCreate(MainActivity.java:14)
android.app.Activity.performCreate(Activity.java:5008)
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
AndroidRuntime(690): ... 11 more
AndroidRuntime(690): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's
AndroidManifest.xml does not have the right value. Expected 5089000 but found 0.
You must have the following declaration within the <application> element:
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
com.google.android.gms.common.GooglePlayServicesUtil.A(Unknown Source)
com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable
(Unknown Source)
com.google.android.gms.maps.internal.u.I(Unknown Source)
com.google.android.gms.maps.internal.u.H(Unknown Source)
com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
com.google.android.gms.maps.MapFragment$b.jz(Unknown Source)
com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
com.google.android.gms.dynamic.a.a(Unknown Source)
com.google.android.gms.dynamic.a.onInflate(Unknown Source)
com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
android.app.Activity.onCreateView(Activity.java:4663)
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
09-01 15:06:56.709: E/AndroidRuntime(690): ... 23 more
09-01 15:07:53.868: E/Trace(734): error opening trace file: No such file or directory (2)
09-01 15:07:54.479: E/AndroidRuntime(734): FATAL EXCEPTION: main
09-01 15:07:54.479: E/AndroidRuntime(734): java.lang.RuntimeException:
Unable to start activity ComponentInfo{myapp/myapp.MainActivity}
android.view.InflateException: Binary XML file line #2: Error inflating class fragment
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
android.app.ActivityThread.access$600(ActivityThread.java:130)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:137)
android.app.ActivityThread.main(ActivityThread.java:4745)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:511)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
dalvik.system.NativeStart.main(Native Method)
09-01 15:07:54.479: E/AndroidRuntime(734): Caused by:
android.view.InflateException: Binary XML file line #2: Error inflating class fragment
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
android.view.LayoutInflater.inflate(LayoutInflater.java:466)
android.view.LayoutInflater.inflate(LayoutInflater.java:396)
android.view.LayoutInflater.inflate(LayoutInflater.java:352)
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
android.app.Activity.setContentView(Activity.java:1867)
android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
android.support.v7.app.ActionBarActivityDelegateICS.
setContentView(ActionBarActivityDelegateICS.java:110)
android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
myapp.MainActivity.onCreate(MainActivity.java:14)
android.app.Activity.performCreate(Activity.java:5008)
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
E/AndroidRuntime(734): ... 11 more
E/AndroidRuntime(734): Caused by: java.lang.IllegalStateException: The meta-data tag in your
app's AndroidManifest.xml does not have the right value. Expected 5089000 but found 0.
You must have the following declaration within the <application> element:
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
com.google.android.gms.common.GooglePlayServicesUtil.A(Unknown Source)
com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable
(Unknown Source)
com.google.android.gms.maps.internal.u.I(Unknown Source)
com.google.android.gms.maps.internal.u.H(Unknown Source)
com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
com.google.android.gms.maps.MapFragment$b.jz(Unknown Source)
com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
com.google.android.gms.dynamic.a.a(Unknown Source)
com.google.android.gms.dynamic.a.onInflate(Unknown Source)
com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
android.app.Activity.onCreateView(Activity.java:4663)
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
09-01 15:07:54.479: E/AndroidRuntime(734): ... 23 more
error opening trace file: No such file or directory (2)
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{myapp/myapp.MainActivity}:
android.view.InflateException: Binary XML file line #2: Error inflating class fragment
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
android.app.ActivityThread.access$600(ActivityThread.java:130)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:137)
android.app.ActivityThread.main(ActivityThread.java:4745)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:511)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
dalvik.system.NativeStart.main(Native Method)
09-01 15:12:22.938: E/AndroidRuntime(811): Caused by: android.view.InflateException: Binary XML
file line #2: Error inflating class fragment
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
android.view.LayoutInflater.inflate(LayoutInflater.java:466)
android.view.LayoutInflater.inflate(LayoutInflater.java:396)
android.view.LayoutInflater.inflate(LayoutInflater.java:352)
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
android.app.Activity.setContentView(Activity.java:1867)
android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
android.support.v7.app.ActionBarActivityDelegateICS.setContentView
(ActionBarActivityDelegateICS.java:110)
android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
myapp.MainActivity.onCreate(MainActivity.java:14)
android.app.Activity.performCreate(Activity.java:5008)
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
09-01 15:12:22.938: E/AndroidRuntime(811): ... 11 more
09-01 15:12:22.938: E/AndroidRuntime(811): Caused by: java.lang.IllegalStateException: The meta-
data tag in your app's AndroidManifest.xml does not have the right value. Expected 5089000
but found 0. You must have the following declaration within the <application> element:
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
com.google.android.gms.common.GooglePlayServicesUtil.A(Unknown Source)
com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable
(Unknown Source)
com.google.android.gms.maps.internal.u.I(Unknown Source)
com.google.android.gms.maps.internal.u.H(Unknown Source)
com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
com.google.android.gms.maps.MapFragment$b.jz(Unknown Source)
com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
com.google.android.gms.dynamic.a.a(Unknown Source)
com.google.android.gms.dynamic.a.onInflate(Unknown Source)
com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
android.app.Activity.onCreateView(Activity.java:4663)
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
09-01 15:19:34.508: E/Trace(826): error opening trace file: No such file or directory (2)
09-01 15:19:35.118: E/AndroidRuntime(826): FATAL EXCEPTION: main
09-01 15:19:35.118: E/AndroidRuntime(826): java.lang.RuntimeException:
Unable to start activity ComponentInfo{myapp/myapp.MainActivity}: android.view.InflateException:
Binary XML file line #2: Error inflating class fragment
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
android.app.ActivityThread.access$600(ActivityThread.java:130)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:137)
android.app.ActivityThread.main(ActivityThread.java:4745)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:511)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
dalvik.system.NativeStart.main(Native Method)
09-01 15:19:35.118: E/AndroidRuntime(826): Caused by: android.view.InflateException: Binary XML
file line #2: Error inflating class fragment
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
android.view.LayoutInflater.inflate(LayoutInflater.java:466)
android.view.LayoutInflater.inflate(LayoutInflater.java:396)
android.view.LayoutInflater.inflate(LayoutInflater.java:352)
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
android.app.Activity.setContentView(Activity.java:1867)
android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
android.support.v7.app.ActionBarActivityDelegateICS.setContentView
(ActionBarActivityDelegateICS.java:110)
android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
myapp.MainActivity.onCreate(MainActivity.java:14)
android.app.Activity.performCreate(Activity.java:5008)
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
09-01 15:19:35.118: E/AndroidRuntime(826): ... 11 more
09-01 15:19:35.118: E/AndroidRuntime(826): Caused by: java.lang.IllegalStateException:
The meta- data tag in your app's AndroidManifest.xml does not
have the right value. Expected 5089000 but found 0. You must have the following declaration
within the <application> element:
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
com.google.android.gms.common.GooglePlayServicesUtil.A(Unknown Source)
com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailabl
(Unknown Source)
com.google.android.gms.maps.internal.u.I(Unknown Source)
com.google.android.gms.maps.internal.u.H(Unknown Source)
com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
com.google.android.gms.maps.MapFragment$b.jz(Unknown Source)
com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
com.google.android.gms.dynamic.a.a(Unknown Source)
com.google.android.gms.dynamic.a.onInflate(Unknown Source)
com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
android.app.Activity.onCreateView(Activity.java:4663)
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
09-01 15:27:57.068: E/Trace(865): error opening trace file: No such file or directory (2)
09-01 15:27:57.748: E/AndroidRuntime(865): FATAL EXCEPTION: main
09-01 15:27:57.748: E/AndroidRuntime(865): java.lang.RuntimeException:
Unable to start activity ComponentInfo{myapp/myapp.MainActivity}:
android.view.InflateException: Binary XML file line #2: Error inflating class fragment
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
android.app.ActivityThread.access$600(ActivityThread.java:130)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:137)
android.app.ActivityThread.main(ActivityThread.java:4745)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:511)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
dalvik.system.NativeStart.main(Native Method)
09-01 15:27:57.748: E/AndroidRuntime(865): Caused by: android.view.InflateException: Binary XML
file line #2: Error inflating class fragment
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
android.view.LayoutInflater.inflate(LayoutInflater.java:466)
android.view.LayoutInflater.inflate(LayoutInflater.java:396)
android.view.LayoutInflater.inflate(LayoutInflater.java:352)
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
android.app.Activity.setContentView(Activity.java:1867)
android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
android.support.v7.app.ActionBarActivityDelegateICS.setContentView
(ActionBarActivityDelegateICS.java:110)
android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
myapp.MainActivity.onCreate(MainActivity.java:14)
android.app.Activity.performCreate(Activity.java:5008)
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
09-01 15:27:57.748: E/AndroidRuntime(865): ... 11 more
09-01 15:27:57.748: E/AndroidRuntime(865): Caused by: java.lang.IllegalStateException:
The meta- data tag in your app's AndroidManifest.xml does not have the right value.
Expected 5089000 but found 0. You must have the following declaration within the
<application> element: <meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
com.google.android.gms.common.GooglePlayServicesUtil.A(Unknown Source)
com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable
(Unknown Source)
com.google.android.gms.maps.internal.u.I(Unknown Source)
com.google.android.gms.maps.internal.u.H(Unknown Source)
com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
com.google.android.gms.maps.MapFragment$b.jz(Unknown Source)
com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
com.google.android.gms.dynamic.a.a(Unknown Source)
com.google.android.gms.dynamic.a.onInflate(Unknown Source)
com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
android.app.Activity.onCreateView(Activity.java:4663)
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
09-01 15:27:57.748: E/AndroidRuntime(865): ... 23 more
mmmh... Change
<meta-data android:name="com.google.android.gms.version" android:value="4030500" />
to
<meta-data android:name="com.google.android.gms.version" android:value="5089000" />
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<permission
android:name="com.myapp.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.myapp.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.myapp."Your activity name""
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="Your map key" />
</application>
</manifest>
Add the below permission to your Manifest.xml
<permission android:name="com.myapp.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
and replaca the below line:
<uses-permissionandroid:name="com.myapp.providers.gsf.permission.
READ_GSERVICES"/>
via
<uses-permission android:name="com.myapp.providers.gsf.permission.
READ_GSERVICES"/>

android connect to php and my sql

i am using eclipse for android application development.
i want to connect my android application to mysql database.
i search code from http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/
and Log says
11-13 01:08:49.439: E/AndroidRuntime(1037): FATAL EXCEPTION: main
11-13 01:08:49.439: E/AndroidRuntime(1037): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.bhaapapp3/com.bhaapapp3.AllProductsActivity}; have you declared this activity in your AndroidManifest.xml?
11-13 01:08:49.439: E/AndroidRuntime(1037): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1628)
11-13 01:08:49.439: E/AndroidRuntime(1037): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1424)
11-13 01:08:49.439: E/AndroidRuntime(1037): at android.app.Activity.startActivityForResult(Activity.java:3390)
11-13 01:08:49.439: E/AndroidRuntime(1037): at android.app.Activity.startActivityForResult(Activity.java:3351)
11-13 01:08:49.439: E/AndroidRuntime(1037): at android.app.Activity.startActivity(Activity.java:3587)
11-13 01:08:49.439: E/AndroidRuntime(1037): at android.app.Activity.startActivity(Activity.java:3555)
11-13 01:08:49.439: E/AndroidRuntime(1037): at com.bhaapapp3.MainActivity$1.onClick(MainActivity.java:34)
11-13 01:08:49.439: E/AndroidRuntime(1037): at android.view.View.performClick(View.java:4240)
11-13 01:08:49.439: E/AndroidRuntime(1037): at android.view.View$PerformClick.run(View.java:17721)
11-13 01:08:49.439: E/AndroidRuntime(1037): at android.os.Handler.handleCallback(Handler.java:730)
11-13 01:08:49.439: E/AndroidRuntime(1037): at android.os.Handler.dispatchMessage(Handler.java:92)
11-13 01:08:49.439: E/AndroidRuntime(1037): at android.os.Looper.loop(Looper.java:137)
11-13 01:08:49.439: E/AndroidRuntime(1037): at android.app.ActivityThread.main(ActivityThread.java:5103)
11-13 01:08:49.439: E/AndroidRuntime(1037): at java.lang.reflect.Method.invokeNative(Native Method)
11-13 01:08:49.439: E/AndroidRuntime(1037): at java.lang.reflect.Method.invoke(Method.java:525)
11-13 01:08:49.439: E/AndroidRuntime(1037): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
11-13 01:08:49.439: E/AndroidRuntime(1037): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-13 01:08:49.439: E/AndroidRuntime(1037): at dalvik.system.NativeStart.main(Native Method)
11-13 01:08:52.879: I/Process(1037): Sending signal. PID: 1037 SIG: 9
plz help me
and menifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bhaapapp3"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.bhaapapp3.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- All Product Activity -->
<activity
android:name=".AllProductsActivity"
android:label="All Products" >
</activity>
<!-- Add Product Activity -->
<activity
android:name=".NewProductActivity"
android:label="Add New Product" >
</activity>
<!-- Edit Product Activity -->
<activity
android:name=".EditProductActivity"
android:label="Edit Product" >
</activity>
</activity>
</application>
</manifest>
Assuming, you do not have permissions set from your LogCat error description, here is my contents for my AndroidMainfest.xml file that has access to the internet:
<manifest xlmns:android...>
...
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest>
Other than that, you should be fine to download a file from the internet.
And if still this will not work for you, then i suggest you to view given Videos there by Ravi Tamada at AndroidHive.info

Android app does not start in emulator or device

I have finally finished my app and everything was working fine. I went back to add in the admob stuff and now it will not start in the emulator. it says it successfully installed the app on the emulator but it does not launch and the icon is not visible to try to manually run. I think the manifest is where my error is but I am unsure.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.androidsleepmachine.gamble"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.WAKE_LOCK" >
</uses-permission>
<uses-permission android:name="android.permission.Internet" >
</uses-permission>
<uses-permission android:name="android.permission.Write_EXTERNAL_STORAGE" >
</uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" >
</uses-permission>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation"
></activity>
<activity
android:name=".Splash"
android:label="#string/app_name"
android:theme="#android:style/Theme.Dialog" >
<intent-filter>
<action android:name="com.AndroidSleepMachine.gamble.SPLASH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.AndroidSleepMachine.gamble.HOME"
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=".About"
android:label="#string/app_name"
android:theme="#android:style/Theme.Dialog" >
<intent-filter>
<action android:name="com.AndroidSleepMachine.gamble.ABOUT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="com.androidsleepmachine.gamble.Ship" />
<activity android:name="com.androidsleepmachine.gamble.OceanThunder" />
<activity android:name="com.androidsleepmachine.gamble.Ocean" />
<activity android:name="com.androidsleepmachine.gamble.Forest" />
<activity android:name="com.androidsleepmachine.gamble.Rain" />
<activity android:name="com.androidsleepmachine.gamble.Thunderbirds" />
<activity android:name="com.androidsleepmachine.gamble.Meditation" />
<activity android:name="com.androidsleepmachine.gamble.Focus" />
<activity android:name="com.androidsleepmachine.gamble.Pain" />
</application>
</manifest>
logcat files
09-23 13:17:47.582: E/AndroidRuntime(1563): FATAL EXCEPTION: main
09-23 13:17:47.582: E/AndroidRuntime(1563): java.lang.RuntimeException: Unable to
instantiate activity
ComponentInfo{com.androidsleepmachine.gamble/com.AndroidSleepMachine.gamble.HOME}:
java.lang.ClassNotFoundException: com.AndroidSleepMachine.gamble.HOME
09-23 13:17:47.582: E/AndroidRuntime(1563): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
android.app.ActivityThread.access$600(ActivityThread.java:130)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
android.os.Handler.dispatchMessage(Handler.java:99)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
android.os.Looper.loop(Looper.java:137)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
android.app.ActivityThread.main(ActivityThread.java:4745)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
java.lang.reflect.Method.invokeNative(Native Method)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
java.lang.reflect.Method.invoke(Method.java:511)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
dalvik.system.NativeStart.main(Native Method)
09-23 13:17:47.582: E/AndroidRuntime(1563): Caused by:
java.lang.ClassNotFoundException: com.AndroidSleepMachine.gamble.HOME
09-23 13:17:47.582: E/AndroidRuntime(1563): at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
java.lang.ClassLoader.loadClass(ClassLoader.java:501)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
java.lang.ClassLoader.loadClass(ClassLoader.java:461)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
android.app.Instrumentation.newActivity(Instrumentation.java:1053)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
It looks like your main activity name is incorrect. Java is case sensitive and your application package name is
package="com.androidsleepmachine.gamble"
while your main activity class name is
com.AndroidSleepMachine.gamble.HOME
The ClassNotFoundException is being thrown because your Activity class name is incorrect in the manifest and isn't being found by the class loader.
It cannot find a class called:
com.AndroidSleepMachine.gamble.HOME
Why is "AndroidSleepMachine" using capital letters?
Why not just use:
android:name=".HOME"
...if your class is indeed called HOME.java? Case-sensitivity may be causing your issue.
com.AndroidSleepMachine.gamble.HOME is not the same as com.androidsleepmachine.gamble.HOME

Android - exception launching project on start after copying a lot of code over from another project

am getting this exception:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{business.premium/business.premium.Problemio}:
java.lang.ClassNotFoundException: business.premium.Problemio
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: business.premium.Problemio
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
... 11 more
java.lang.ClassNotFoundException: business.premium.Problemio
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
it says that class is not there, but it IS there. I tried to configure things in my project's build path, but not too sure what to tweak there.
And here is how I start my Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="business.premium"
android:versionCode="1"
android:versionName="1.0" >
<supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true"/>
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15"/>
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/CustomTheme"
android:name="MyApplication"
android:debuggable="true">
<activity
android:name=".Problemio"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Any thoughts on how to solve this, or what to look into? Thanks!
Its because you specified the "android:name" attribute in the application node in the manifest file.
Do not use the android:name attribute!
It, misleadingly, does not have anything to do with the name of your app and is actually the name of an extra class to load before loading your application. That's why you are getting the ClassNotFoundException.
Remove it and it should work:
<application
android:icon="#drawable/icon"
android:label="#string/app_name"
android:description="#string/help_text" >
This answer is taken from: java.lang.ClassNotFoundException on working app

Categories

Resources