In eclipse there are no red errors, but when I try to run application it say unfortunately button has stopped.
LogCat
11-09 10:13:33.134: D/AndroidRuntime(1007): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
11-09 10:13:33.144: D/AndroidRuntime(1007): CheckJNI is ON
11-09 10:13:33.184: D/dalvikvm(1007): Trying to load lib libjavacore.so 0x0
11-09 10:13:33.204: D/dalvikvm(1007): Added shared lib libjavacore.so 0x0
11-09 10:13:33.264: D/dalvikvm(1007): Trying to load lib libnativehelper.so 0x0
11-09 10:13:33.264: D/dalvikvm(1007): Added shared lib libnativehelper.so 0x0
11-09 10:13:34.124: D/AndroidRuntime(1007): Calling main entry com.android.commands.pm.Pm
11-09 10:13:34.184: D/AndroidRuntime(1007): Shutting down VM
11-09 10:13:34.204: D/dalvikvm(1007): GC_CONCURRENT freed 101K, 78% free 466K/2048K, paused 1ms+1ms, total 15ms
11-09 10:13:34.204: D/dalvikvm(1007): Debugger has detached; object registry had 1 entries
11-09 10:13:34.815: D/AndroidRuntime(1020): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
11-09 10:13:34.815: D/AndroidRuntime(1020): CheckJNI is ON
11-09 10:13:34.884: D/dalvikvm(1020): Trying to load lib libjavacore.so 0x0
11-09 10:13:34.904: D/dalvikvm(1020): Added shared lib libjavacore.so 0x0
11-09 10:13:34.964: D/dalvikvm(1020): Trying to load lib libnativehelper.so 0x0
11-09 10:13:34.964: D/dalvikvm(1020): Added shared lib libnativehelper.so 0x0
11-09 10:13:36.064: D/AndroidRuntime(1020): Calling main entry com.android.commands.am.Am
11-09 10:13:36.134: I/ActivityManager(151): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.bogdanskoric.button/.MainActivity u=0} from pid 1020
11-09 10:13:36.144: W/WindowManager(151): Failure taking screenshot for (246x410) to layer 21005
11-09 10:13:36.194: D/dalvikvm(1030): Not late-enabling CheckJNI (already on)
11-09 10:13:36.204: D/AndroidRuntime(1020): Shutting down VM
11-09 10:13:36.224: I/AndroidRuntime(1020): NOTE: attach of thread 'Binder_3' failed
11-09 10:13:36.244: D/dalvikvm(1020): GC_CONCURRENT freed 102K, 77% free 489K/2048K, paused 6ms+1ms, total 29ms
11-09 10:13:36.254: I/ActivityManager(151): Start proc com.bogdanskoric.button for activity com.bogdanskoric.button/.MainActivity: pid=1030 uid=10046 gids={1028}
11-09 10:13:36.254: D/jdwp(1020): Got wake-up signal, bailing out of select
11-09 10:13:36.254: D/dalvikvm(1020): Debugger has detached; object registry had 1 entries
11-09 10:13:36.334: I/Choreographer(248): Skipped 43 frames! The application may be doing too much work on its main thread.
11-09 10:13:36.714: E/Trace(1030): error opening trace file: No such file or directory (2)
11-09 10:13:37.234: I/Choreographer(248): Skipped 104 frames! The application may be doing too much work on its main thread.
11-09 10:13:37.324: D/AndroidRuntime(1030): Shutting down VM
11-09 10:13:37.324: W/dalvikvm(1030): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
11-09 10:13:37.344: E/AndroidRuntime(1030): FATAL EXCEPTION: main
11-09 10:13:37.344: E/AndroidRuntime(1030): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bogdanskoric.button/com.bogdanskoric.button.MainActivity}: java.lang.RuntimeException: Binary XML file line #11: You must supply a layout_width attribute.
11-09 10:13:37.344: E/AndroidRuntime(1030): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
11-09 10:13:37.344: E/AndroidRuntime(1030): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
11-09 10:13:37.344: E/AndroidRuntime(1030): at android.app.ActivityThread.access$600(ActivityThread.java:130)
11-09 10:13:37.344: E/AndroidRuntime(1030): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
11-09 10:13:37.344: E/AndroidRuntime(1030): at android.os.Handler.dispatchMessage(Handler.java:99)
11-09 10:13:37.344: E/AndroidRuntime(1030): at android.os.Looper.loop(Looper.java:137)
11-09 10:13:37.344: E/AndroidRuntime(1030): at android.app.ActivityThread.main(ActivityThread.java:4745)
11-09 10:13:37.344: E/AndroidRuntime(1030): at java.lang.reflect.Method.invokeNative(Native Method)
11-09 10:13:37.344: E/AndroidRuntime(1030): at java.lang.reflect.Method.invoke(Method.java:511)
11-09 10:13:37.344: E/AndroidRuntime(1030): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
11-09 10:13:37.344: E/AndroidRuntime(1030): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-09 10:13:37.344: E/AndroidRuntime(1030): at dalvik.system.NativeStart.main(Native Method)
11-09 10:13:37.344: E/AndroidRuntime(1030): Caused by: java.lang.RuntimeException: Binary XML file line #11: You must supply a layout_width attribute.
11-09 10:13:37.344: E/AndroidRuntime(1030): at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:491)
11-09 10:13:37.344: E/AndroidRuntime(1030): at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:5458)
11-09 10:13:37.344: E/AndroidRuntime(1030): at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:5594)
11-09 10:13:37.344: E/AndroidRuntime(1030): at android.widget.RelativeLayout$LayoutParams.<init>(RelativeLayout.java:1099)
11-09 10:13:37.344: E/AndroidRuntime(1030): at android.widget.RelativeLayout.generateLayoutParams(RelativeLayout.java:956)
11-09 10:13:37.344: E/AndroidRuntime(1030): at android.widget.RelativeLayout.generateLayoutParams(RelativeLayout.java:70)
11-09 10:13:37.344: E/AndroidRuntime(1030): at android.view.LayoutInflater.rInflate(LayoutInflater.java:748)
11-09 10:13:37.344: E/AndroidRuntime(1030): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
11-09 10:13:37.344: E/AndroidRuntime(1030): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
11-09 10:13:37.344: E/AndroidRuntime(1030): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
11-09 10:13:37.344: E/AndroidRuntime(1030): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
11-09 10:13:37.344: E/AndroidRuntime(1030): at android.app.Activity.setContentView(Activity.java:1867)
11-09 10:13:37.344: E/AndroidRuntime(1030): at com.bogdanskoric.button.MainActivity.onCreate(MainActivity.java:22)
11-09 10:13:37.344: E/AndroidRuntime(1030): at android.app.Activity.performCreate(Activity.java:5008)
11-09 10:13:37.344: E/AndroidRuntime(1030): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
11-09 10:13:37.344: E/AndroidRuntime(1030): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
11-09 10:13:37.344: E/AndroidRuntime(1030): ... 11 more
11-09 10:13:37.364: W/ActivityManager(151): Force finishing activity com.bogdanskoric.button/.MainActivity
11-09 10:13:37.374: W/WindowManager(151): Failure taking screenshot for (246x410) to layer 21010
11-09 10:13:37.894: W/ActivityManager(151): Activity pause timeout for ActivityRecord{4159fd60 com.bogdanskoric.button/.MainActivity}
11-09 10:13:38.234: I/Choreographer(248): Skipped 36 frames! The application may be doing too much work on its main thread.
MainActivty
package com.bogdanskoric.button;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainActivity extends Activity implements View.OnClickListener
{
Button buttonE;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
buttonE = (Button) findViewById(R.id.button);
buttonE.setOnClickListener (this);
}
private void buttonClick ()
{
startActivity(new Intent ("com.bogdanskoric.button.EmocijeActivityMainActivity"));
}
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId())
{
case R.id.button:
buttonClick();
break;
}
}
}
activity_main
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.bogdanskoric.button.MainActivity" >
<TextView
/>
<Button
android:id="#+id/button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="33dp"
android:layout_marginTop="42dp"
android:text="#string/button"
/>
</RelativeLayout>
EmocijeActivityMainActivity
package com.bogdanskoric.button;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class EmocijeActivityMainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.emocije_activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.emocije_activity_main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Button manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bogdanskoric.button"
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=".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>
<activity
android:name=".EmocijeActivityMainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.bogdanskoric.button.EmocijeActivityMainActivity" />
<category android:name="android.intent.category.DEFOULT" />
</intent-filter>
</activity>
</application>
</manifest>
The error says it all : Binary XML file line #11: You must supply a layout_width attribute.
Basically the error is that you have not defined any layout_width and layout_height in the xml attribute of TextView...
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
... Other Attributes
/>
Related
Hi I am trying to run an android app. Where my goal was to display a radar graph based on user preferences for that I have used the webview and sending the username to php file.
But Now I was getting an error stating that "java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.newairways/com.example.newairways.communication}: java.lang.ClassCastException: com.example.newairways.communication cannot be cast to android.app.Activity"
I Have tried my level best to solve this but I could able to it. and in error it was stated the communication class was not mentioned So I have also mentioned but I required the radar part to display. So Please help me in solving this.
Here is my logcat
08-04 19:59:21.861: D/gralloc_goldfish(654): Emulator without GPU emulation detected.
08-04 19:59:22.071: W/TextLayoutCache(654): computeValuesWithHarfbuzz -- need to force to single run
08-04 19:59:32.541: D/dalvikvm(654): GC_CONCURRENT freed 177K, 3% free 14296K/14599K, paused 7ms+7ms
08-04 19:59:36.962: W/TextLayoutCache(654): computeValuesWithHarfbuzz -- need to force to single run
08-04 19:59:45.762: W/SingleClientConnManager(654): Invalid use of SingleClientConnManager: connection still allocated.
08-04 19:59:45.762: W/SingleClientConnManager(654): Make sure to release the connection before allocating another one.
08-04 19:59:45.811: I/System.out(654): Response : User Found
08-04 19:59:45.811: I/System.out(654): ---IF---
08-04 19:59:46.682: D/dalvikvm(654): GC_CONCURRENT freed 214K, 3% free 14607K/14919K, paused 6ms+8ms
08-04 19:59:46.831: D/dalvikvm(654): GC_FOR_ALLOC freed 13K, 2% free 14946K/15239K, paused 52ms
08-04 19:59:50.781: D/AndroidRuntime(654): Shutting down VM
08-04 19:59:50.781: W/dalvikvm(654): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
08-04 19:59:50.831: E/AndroidRuntime(654): FATAL EXCEPTION: main
08-04 19:59:50.831: E/AndroidRuntime(654): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.newairways/com.example.newairways.communication}: java.lang.ClassCastException: com.example.newairways.communication cannot be cast to android.app.Activity
08-04 19:59:50.831: E/AndroidRuntime(654): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1879)
08-04 19:59:50.831: E/AndroidRuntime(654): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
08-04 19:59:50.831: E/AndroidRuntime(654): at android.app.ActivityThread.access$600(ActivityThread.java:122)
08-04 19:59:50.831: E/AndroidRuntime(654): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
08-04 19:59:50.831: E/AndroidRuntime(654): at android.os.Handler.dispatchMessage(Handler.java:99)
08-04 19:59:50.831: E/AndroidRuntime(654): at android.os.Looper.loop(Looper.java:137)
08-04 19:59:50.831: E/AndroidRuntime(654): at android.app.ActivityThread.main(ActivityThread.java:4340)
08-04 19:59:50.831: E/AndroidRuntime(654): at java.lang.reflect.Method.invokeNative(Native Method)
08-04 19:59:50.831: E/AndroidRuntime(654): at java.lang.reflect.Method.invoke(Method.java:511)
08-04 19:59:50.831: E/AndroidRuntime(654): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-04 19:59:50.831: E/AndroidRuntime(654): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-04 19:59:50.831: E/AndroidRuntime(654): at dalvik.system.NativeStart.main(Native Method)
08-04 19:59:50.831: E/AndroidRuntime(654): Caused by: java.lang.ClassCastException: com.example.newairways.communication cannot be cast to android.app.Activity
08-04 19:59:50.831: E/AndroidRuntime(654): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
08-04 19:59:50.831: E/AndroidRuntime(654): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1870)
08-04 19:59:50.831: E/AndroidRuntime(654): ... 11 more
08-04 20:06:29.651: D/gralloc_goldfish(707): Emulator without GPU emulation detected.
08-04 20:06:29.802: W/TextLayoutCache(707): computeValuesWithHarfbuzz -- need to force to single run
08-04 20:06:35.271: D/dalvikvm(707): GC_CONCURRENT freed 133K, 2% free 14335K/14599K, paused 7ms+6ms
08-04 20:06:47.093: W/TextLayoutCache(707): computeValuesWithHarfbuzz -- need to force to single run
08-04 20:06:55.241: W/SingleClientConnManager(707): Invalid use of SingleClientConnManager: connection still allocated.
08-04 20:06:55.241: W/SingleClientConnManager(707): Make sure to release the connection before allocating another one.
08-04 20:06:55.352: D/dalvikvm(707): GC_CONCURRENT freed 298K, 3% free 14484K/14855K, paused 6ms+8ms
08-04 20:06:55.441: I/System.out(707): Response : User Found
08-04 20:06:55.512: I/System.out(707): ---IF---
08-04 20:06:56.211: D/dalvikvm(707): GC_FOR_ALLOC freed 70K, 3% free 14754K/15111K, paused 46ms
08-04 20:06:56.334: D/dalvikvm(707): GC_FOR_ALLOC freed 3K, 3% free 15023K/15367K, paused 50ms
08-04 20:07:00.851: D/AndroidRuntime(707): Shutting down VM
08-04 20:07:00.851: W/dalvikvm(707): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
08-04 20:07:00.901: E/AndroidRuntime(707): FATAL EXCEPTION: main
08-04 20:07:00.901: E/AndroidRuntime(707): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.newairways/com.example.newairways.communication}: java.lang.ClassCastException: com.example.newairways.communication cannot be cast to android.app.Activity
08-04 20:07:00.901: E/AndroidRuntime(707): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1879)
08-04 20:07:00.901: E/AndroidRuntime(707): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
08-04 20:07:00.901: E/AndroidRuntime(707): at android.app.ActivityThread.access$600(ActivityThread.java:122)
08-04 20:07:00.901: E/AndroidRuntime(707): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
08-04 20:07:00.901: E/AndroidRuntime(707): at android.os.Handler.dispatchMessage(Handler.java:99)
08-04 20:07:00.901: E/AndroidRuntime(707): at android.os.Looper.loop(Looper.java:137)
08-04 20:07:00.901: E/AndroidRuntime(707): at android.app.ActivityThread.main(ActivityThread.java:4340)
08-04 20:07:00.901: E/AndroidRuntime(707): at java.lang.reflect.Method.invokeNative(Native Method)
08-04 20:07:00.901: E/AndroidRuntime(707): at java.lang.reflect.Method.invoke(Method.java:511)
08-04 20:07:00.901: E/AndroidRuntime(707): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-04 20:07:00.901: E/AndroidRuntime(707): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-04 20:07:00.901: E/AndroidRuntime(707): at dalvik.system.NativeStart.main(Native Method)
08-04 20:07:00.901: E/AndroidRuntime(707): Caused by: java.lang.ClassCastException: com.example.newairways.communication cannot be cast to android.app.Activity
08-04 20:07:00.901: E/AndroidRuntime(707): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
08-04 20:07:00.901: E/AndroidRuntime(707): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1870)
08-04 20:07:00.901: E/AndroidRuntime(707): ... 11 more
Here is my manifesto file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.newairways"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.newairways.login"
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.example.newairways.menu"
android:label="#string/app_name" >
</activity>s
<activity
android:name="com.example.newairways.bar"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.radar"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.measure"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.plan"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.day0"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.goaltest"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.relationship"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.start"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.discipline"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.skills"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.knowledge"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.emotions"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.adaptation"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.leadership"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.lifequality"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.Globalvars"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.communication"
android:label="#string/app_name" >
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
Does your activity extend android.app.activity ? Is the activity mentioned in the manifest file. Is the base package and fully qualified name of the activity class correct??
I have been trying to extend FragmentActivity. The same app works if I extend the MainActivity class to Activity and import necessary packages for a normal Activity.
The basic need is that i cannot access the map in a normal activity. It needs to extend FragmentActivity to run the following line.
googleMap= ((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
Here is the Java code
package com.dacoders.locationtodo;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
public class MainActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Here is the layout XML
<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.MapFragment"/>
Here is the AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dacoders.locationtodo"
android:versionCode="1"
android:versionName="1.0" >
<permission
android:name="com.dacoders.locationtodo.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.dacoders.locationtodo.permission.MAPS_RECEIVE"/>
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>
<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="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- The following two permissions are not required to use
Google Maps Android API v2, but are recommended. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.dacoders.locationtodo.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="API_KEY_HERE"/>
</application>
</manifest>
Here is the LOG
0622 21:01:25.911: D/dalvikvm(13621): Lateenabling CheckJNI
0622 21:01:25.991: D/AndroidRuntime(13621): Shutting down VM
0622 21:01:25.991: W/dalvikvm(13621): threadid=1: thread exiting with uncaught exception (group=0x41629930)
0622 21:01:26.001: E/AndroidRuntime(13621): FATAL EXCEPTION: main
0622 21:01:26.001: E/AndroidRuntime(13621): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dacoders.locationtodo/com.dacoders.locationtodo.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
0622 21:01:26.001: E/AndroidRuntime(13621): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.app.ActivityThread.access$600(ActivityThread.java:141)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.os.Handler.dispatchMessage(Handler.java:99)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.os.Looper.loop(Looper.java:137)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.app.ActivityThread.main(ActivityThread.java:5041)
0622 21:01:26.001: E/AndroidRuntime(13621): at java.lang.reflect.Method.invokeNative(Native Method)
0622 21:01:26.001: E/AndroidRuntime(13621): at java.lang.reflect.Method.invoke(Method.java:511)
0622 21:01:26.001: E/AndroidRuntime(13621): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
0622 21:01:26.001: E/AndroidRuntime(13621): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
0622 21:01:26.001: E/AndroidRuntime(13621): at dalvik.system.NativeStart.main(Native Method)
0622 21:01:26.001: E/AndroidRuntime(13621): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
0622 21:01:26.001: E/AndroidRuntime(13621): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
0622 21:01:26.001: E/AndroidRuntime(13621): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.app.Activity.setContentView(Activity.java:1881)
0622 21:01:26.001: E/AndroidRuntime(13621): at com.dacoders.locationtodo.MainActivity.onCreate(MainActivity.java:12)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.app.Activity.performCreate(Activity.java:5104)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
0622 21:01:26.001: E/AndroidRuntime(13621): ... 11 more
0622 21:01:26.001: E/AndroidRuntime(13621): Caused by: java.lang.ClassCastException: com.google.android.gms.maps.MapFragment cannot be cast to android.support.v4.app.Fragment
0622 21:01:26.001: E/AndroidRuntime(13621): at android.support.v4.app.Fragment.instantiate(Fragment.java:394)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.support.v4.app.Fragment.instantiate(Fragment.java:369)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
0622 21:01:26.001: E/AndroidRuntime(13621): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
0622 21:01:26.001: E/AndroidRuntime(13621): ... 20 more
Here is the layout XML
<fragment
I'm not sure if you can have a fragment as the root of your layout as fragments are supposed to be pieces that are put in another layout and exchanged.
Have you tried putting your fragment in a FrameLayout and see if it still crashes?
Your min sdk is 11. I guess you can make it 12 and use MapFragment.
To know why check the link http://developer.android.com/about/dashboards/index.html.
In that case (minsdk is 12 or above) you can extend Activity
GoogleMap mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
Also import
import com.google.android.gms.maps.MapFragment;
Or
You should use Support Fragment.
<fragment
class="com.google.android.gms.maps.SupportMapFragment"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
Your activity must extend FragmentActivity
SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
GoogleMap mMap = fm.getMap();
Make sure you have added support library
Also make sure you imported the below
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.SupportMapFragment;
I hae the same problem as all this topics about the problems of getting zxing working on a project in android, but none of the solutions worked for me. This is the error log:
11-09 11:06:16.009: E/AndroidRuntime(3481): FATAL EXCEPTION: main
11-09 11:06:16.009: E/AndroidRuntime(3481): java.lang.NoClassDefFoundError: com.google.zxing.client.android.R$layout
11-09 11:06:16.009: E/AndroidRuntime(3481): at com.google.zxing.client.android.CaptureActivity.onCreate(CaptureActivity.java:155)
11-09 11:06:16.009: E/AndroidRuntime(3481): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-09 11:06:16.009: E/AndroidRuntime(3481): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
11-09 11:06:16.009: E/AndroidRuntime(3481): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
11-09 11:06:16.009: E/AndroidRuntime(3481): at android.app.ActivityThread.access$1500(ActivityThread.java:123)
11-09 11:06:16.009: E/AndroidRuntime(3481): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
11-09 11:06:16.009: E/AndroidRuntime(3481): at android.os.Handler.dispatchMessage(Handler.java:99)
11-09 11:06:16.009: E/AndroidRuntime(3481): at android.os.Looper.loop(Looper.java:130)
11-09 11:06:16.009: E/AndroidRuntime(3481): at android.app.ActivityThread.main(ActivityThread.java:3835)
11-09 11:06:16.009: E/AndroidRuntime(3481): at java.lang.reflect.Method.invokeNative(Native Method)
11-09 11:06:16.009: E/AndroidRuntime(3481): at java.lang.reflect.Method.invoke(Method.java:507)
11-09 11:06:16.009: E/AndroidRuntime(3481): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
11-09 11:06:16.009: E/AndroidRuntime(3481): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
11-09 11:06:16.009: E/AndroidRuntime(3481): at dalvik.system.NativeStart.main(Native Method)
I have tried lots of combinations inside buildpath, adding the source project, adding de core.jar (named zxing-1.7.jar in my project), addiing it as external library...but when i don't get this problem at the bottom, then i get a dalvik format error, saying Lcom/zxing/android: already added.
I have also tried to put the .jar inside a folder called libs, but none working, checking and unchecking it on build path configs.
here's an image of my current Build Path order, http://postimage.org/image/f496ukwkf/ , but i tried with lots of different combinations, and none of them worked.
Thanks, i need to get it working, please.
You are trying to include code from android/ in your project. You're not intended to do this, and you haven't set it up correctly either. Integrating by Intent (http://code.google.com/p/zxing/wiki/ScanningViaIntent) is far easier if you are new to this. No library code to mess with.
I am trying an example given in o reilys book and testing it on LG P500 but all I get is force close with the following errors:
WARNING: Application does not specify an API level requirement!
[2011-11-09 15:43:38 - dloc] Device API version is 8 (Android 2.2.2)
**p.s i have mentioned api level**
**logcat:**
11-09 16:00:44.738: W/dalvikvm(8002): threadid=1: thread exiting with uncaught exception (group=0x40020ac0)
11-09 16:00:44.738: E/AndroidRuntime(8002): FATAL EXCEPTION: main
11-09 16:00:44.738: E/AndroidRuntime(8002): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.microjobsinc.dloc/com.microjobsinc.dloc.Main}: java.lang.ClassNotFoundException: com.microjobsinc.dloc.Main in loader dalvik.system.PathClassLoader[/data/app/com.microjobsinc.dloc-2.apk]
11-09 16:00:44.738: E/AndroidRuntime(8002): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
11-09 16:00:44.738: E/AndroidRuntime(8002): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-09 16:00:44.738: E/AndroidRuntime(8002): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-09 16:00:44.738: E/AndroidRuntime(8002): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-09 16:00:44.738: E/AndroidRuntime(8002): at android.os.Handler.dispatchMessage(Handler.java:99)
11-09 16:00:44.738: E/AndroidRuntime(8002): at android.os.Looper.loop(Looper.java:123)
11-09 16:00:44.738: E/AndroidRuntime(8002): at android.app.ActivityThread.main(ActivityThread.java:4627)
11-09 16:00:44.738: E/AndroidRuntime(8002): at java.lang.reflect.Method.invokeNative(Native Method)
11-09 16:00:44.738: E/AndroidRuntime(8002): at java.lang.reflect.Method.invoke(Method.java:521)
11-09 16:00:44.738: E/AndroidRuntime(8002): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
11-09 16:00:44.738: E/AndroidRuntime(8002): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
11-09 16:00:44.738: E/AndroidRuntime(8002): at dalvik.system.NativeStart.main(Native Method)
11-09 16:00:44.738: E/AndroidRuntime(8002): Caused by: java.lang.ClassNotFoundException: com.microjobsinc.dloc.Main in loader dalvik.system.PathClassLoader[/data/app/com.microjobsinc.dloc-2.apk]
11-09 16:00:44.738: E/AndroidRuntime(8002): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
11-09 16:00:44.738: E/AndroidRuntime(8002): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
11-09 16:00:44.738: E/AndroidRuntime(8002): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
11-09 16:00:44.738: E/AndroidRuntime(8002): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
11-09 16:00:44.738: E/AndroidRuntime(8002): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
11-09 16:00:44.738: E/AndroidRuntime(8002): ... 11 more
11-09 16:00:49.848: W/dalvikvm(8013): threadid=1: thread exiting with uncaught exception (group=0x40020ac0)
11-09 16:00:49.858: E/AndroidRuntime(8013): FATAL EXCEPTION: main
Code is written below
public class main extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// find the TextViews
TextView tvLatitude = (TextView)findViewById(R.id.tvLatitude);
TextView tvLongitude = (TextView)findViewById(R.id.tvLongitude);
// get handle for LocationManager
LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
// connect to the GPS location service
String providerName = LocationManager.GPS_PROVIDER;
Location loc = lm.getLastKnownLocation( providerName);
// fill in the TextViews
tvLatitude.setText(Double.toString(loc.getLatitude()));
tvLongitude.setText(Double.toString(loc.getLongitude()));
}
}
What is the cause of this problem and how can I fix it?
You need to change the android project properties to use Google Apis with the platform version that you desire.
I'm trying to implement the 'tab layout' example from the Android SDK tutorials here:
http://developer.android.com/resources/tutorials/views/hello-tabwidget.html
I noticed that lots of people have encountered problems in implementing this.I think I read all the possible links on google/stackoverflow and tried/checked everything but still can't make it work. I still keep on getting the error "The application Hello Tab Widget stopped unexpectedly. Please try again." at launch.
I've uploaded my entire project here (Android 2.3.3):
https://www.yousendit.com/download/VnBxak85UnFCSnF4dnc9PQ
Also, here's the manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kaushal.hellotabwidget"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".hellotabwidget"
android:label="#string/app_name">
<!-- android:theme="#android:style/Theme.NoTitleBar">-->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".AlbumsActivity"></activity>
<activity android:name=".ArtistsActivity"></activity>
<activity android:name=".SongsActivity"></activity>
</application>
</manifest>
And the HelloTabWidget.java file,
package com.kaushal.hellotabwidget;
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TabHost;
public class HelloTabWidget extends TabActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, ArtistsActivity.class);
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("artists").setIndicator("Artists",
res.getDrawable(R.drawable.ic_tab_artists))
.setContent(intent);
tabHost.addTab(spec);
// Do the same for the other tabs
intent = new Intent().setClass(this, AlbumsActivity.class);
spec = tabHost.newTabSpec("albums").setIndicator("Albums",
res.getDrawable(R.drawable.ic_tab_albums))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, SongsActivity.class);
spec = tabHost.newTabSpec("songs").setIndicator("Songs",
res.getDrawable(R.drawable.ic_tab_songs))
.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(0);
}
}
And a sample logcat when the app launches,
04-25 13:10:42.105 D/AndroidRuntime( 671):
04-25 13:10:42.105 D/AndroidRuntime( 671): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
04-25 13:10:42.105 D/AndroidRuntime( 671): CheckJNI is ON
04-25 13:10:43.135 D/AndroidRuntime( 671): Calling main entry com.android.commands.pm.Pm
04-25 13:10:43.195 D/AndroidRuntime( 671): Shutting down VM
04-25 13:10:43.215 I/AndroidRuntime( 671): NOTE: attach of thread 'Binder Thread #3' failed
04-25 13:10:43.215 D/dalvikvm( 671): GC_CONCURRENT freed 100K, 72% free 296K/1024K, external 0K/0K, paused 3ms+5ms
04-25 13:10:43.225 D/jdwp ( 671): adbd disconnected
04-25 13:10:43.975 D/AndroidRuntime( 681):
04-25 13:10:43.975 D/AndroidRuntime( 681): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
04-25 13:10:43.975 D/AndroidRuntime( 681): CheckJNI is ON
04-25 13:10:45.065 D/AndroidRuntime( 681): Calling main entry com.android.commands.am.Am
04-25 13:10:45.135 I/ActivityManager( 67): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.kaushal.hellotabwidget/.hellotabwidget } from pid 681
04-25 13:10:45.205 D/AndroidRuntime( 681): Shutting down VM
04-25 13:10:45.285 I/AndroidRuntime( 681): NOTE: attach of thread 'Binder Thread #3' failed
04-25 13:10:45.315 D/dalvikvm( 681): GC_CONCURRENT freed 101K, 69% free 318K/1024K, external 0K/0K, paused 3ms+84ms
04-25 13:10:45.385 D/jdwp ( 681): adbd disconnected
04-25 13:10:45.456 I/ActivityManager( 67): Start proc com.kaushal.hellotabwidget for activity com.kaushal.hellotabwidget/.hellotabwidget: pid=690 uid=10037 gids={1015}
04-25 13:10:46.815 D/AndroidRuntime( 690): Shutting down VM
04-25 13:10:46.815 W/dalvikvm( 690): threadid=1: thread exiting with uncaught exception (group=0x40015560)
04-25 13:10:46.845 E/AndroidRuntime( 690): FATAL EXCEPTION: main
04-25 13:10:46.845 E/AndroidRuntime( 690): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.kaushal.hellotabwidget/com.kaushal.hellotabwidget.hellotabwidget}: java.lang.ClassNotFoundException: com.kaushal.hellotabwidget.hellotabwidget in loader dalvik.system.PathClassLoader[/data/app/com.kaushal.hellotabwidget-2.apk]
04-25 13:10:46.845 E/AndroidRuntime( 690): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
04-25 13:10:46.845 E/AndroidRuntime( 690): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
04-25 13:10:46.845 E/AndroidRuntime( 690): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-25 13:10:46.845 E/AndroidRuntime( 690): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-25 13:10:46.845 E/AndroidRuntime( 690): at android.os.Handler.dispatchMessage(Handler.java:99)
04-25 13:10:46.845 E/AndroidRuntime( 690): at android.os.Looper.loop(Looper.java:123)
04-25 13:10:46.845 E/AndroidRuntime( 690): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-25 13:10:46.845 E/AndroidRuntime( 690): at java.lang.reflect.Method.invokeNative(Native Method)
04-25 13:10:46.845 E/AndroidRuntime( 690): at java.lang.reflect.Method.invoke(Method.java:507)
04-25 13:10:46.845 E/AndroidRuntime( 690): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-25 13:10:46.845 E/AndroidRuntime( 690): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-25 13:10:46.845 E/AndroidRuntime( 690): at dalvik.system.NativeStart.main(Native Method)
04-25 13:10:46.845 E/AndroidRuntime( 690): Caused by: java.lang.ClassNotFoundException: com.kaushal.hellotabwidget.hellotabwidget in loader dalvik.system.PathClassLoader[/data/app/com.kaushal.hellotabwidget-2.apk]
04-25 13:10:46.845 E/AndroidRuntime( 690): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
04-25 13:10:46.845 E/AndroidRuntime( 690): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
04-25 13:10:46.845 E/AndroidRuntime( 690): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
04-25 13:10:46.845 E/AndroidRuntime( 690): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
04-25 13:10:46.845 E/AndroidRuntime( 690): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
04-25 13:10:46.845 E/AndroidRuntime( 690): ... 11 more
04-25 13:10:46.855 W/ActivityManager( 67): Force finishing activity com.kaushal.hellotabwidget/.hellotabwidget
04-25 13:10:47.375 W/ActivityManager( 67): Activity pause timeout for HistoryRecord{40745f70 com.kaushal.hellotabwidget/.hellotabwidget}
04-25 13:10:58.235 W/ActivityManager( 67): Activity destroy timeout for HistoryRecord{40745f70 com.kaushal.hellotabwidget/.hellotabwidget}
04-25 13:11:05.205 D/dalvikvm( 67): GC_CONCURRENT freed 515K, 42% free 4437K/7623K, external 884K/1297K, paused 10ms+10ms
0
Please let me know what I'm doing wrong here. Have been trying to figure this out for more than a day now but can't make it work.
This is my first posting to Stackoverflow. Please forgive me if I missed any rules of the posting:). Thanks all for your help in advance.
In your Manifest, replace:
<activity android:name=".hellotabwidget"
with:
<activity android:name=".HelloTabWidget"
Activity names are case sensitive (they are class names after all).