I've started to learn Android Development and I got this snippit off of google android development site, it keeps on crashing.
My specs are:
Android 4.0.3
API 15
Code:
package lewes.android.hello;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);
}
}
I get...
Unfortenualy, HelloAndroid is not responding.
Please help me!
MY MANIFEST:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="lewes.android.hello"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".HelloWorld"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
LogCat:
03-17 11:35:19.835: D/AndroidRuntime(562): Shutting down VM
03-17 11:35:19.835: W/dalvikvm(562): threadid=1: thread exiting with uncaught
exception (group=0x409c01f8)
03-17 11:35:19.914: E/AndroidRuntime(562): FATAL EXCEPTION: main
03-17 11:35:19.914: E/AndroidRuntime(562): java.lang.RuntimeException: Unable to
instantiate activity
ComponentInfo{lewes.android.hello/lewes.android.hello.HelloWorld}:
java.lang.ClassNotFoundException: lewes.android.hello.HelloWorld
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread.access$600(ActivityThread.java:123)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.os.Handler.dispatchMessage(Handler.java:99)
03-17 11:35:19.914: E/AndroidRuntime(562): at android.os.Looper.loop(Looper.java:137)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread.main(ActivityThread.java:4424)
03-17 11:35:19.914: E/AndroidRuntime(562): at
java.lang.reflect.Method.invokeNative(Native Method)
03-17 11:35:19.914: E/AndroidRuntime(562): at
java.lang.reflect.Method.invoke(Method.java:511)
03-17 11:35:19.914: E/AndroidRuntime(562): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-17 11:35:19.914: E/AndroidRuntime(562): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-17 11:35:19.914: E/AndroidRuntime(562): at dalvik.system.NativeStart.main(Native
Method)
03-17 11:35:19.914: E/AndroidRuntime(562): Caused by:
java.lang.ClassNotFoundException: lewes.android.hello.HelloWorld
03-17 11:35:19.914: E/AndroidRuntime(562): at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
03-17 11:35:19.914: E/AndroidRuntime(562): at
java.lang.ClassLoader.loadClass(ClassLoader.java:501)
03-17 11:35:19.914: E/AndroidRuntime(562): at
java.lang.ClassLoader.loadClass(ClassLoader.java:461)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.Instrumentation.newActivity(Instrumentation.java:1023)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
03-17 11:35:19.914: E/AndroidRuntime(562): ... 11 more
03-17 11:40:20.114: I/Process(562): Sending signal. PID: 562 SIG: 9
Delete one of the application sections from your manifest.
Keep the one where the activity corresponds to the name of your class.
make your manifest look exactly like this
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="lewes.android.hello"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".HelloAndroid"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Change
<activity
android:name=".HelloAndroidActivity"
to
<activity
android:name=".HelloAndroid"
SDK does not mention about this. But as my experience, activity (this) can not be used inside onCreate(Bundle) to initialize new objects. To be used as a parameter for constructors, this is nothing within onCreate().
You can follow this hello world. It uses static xml layout.
Hope this helps you :-)
Related
Im doing the following tutorial on creating an Android App using Google App Engine: https://cloud.google.com/developers/articles/how-to-build-mobile-app-with-app-engine-backend-tutorial
I am using Eclipse in Windows 7. I got to the part where you run the application to display the newly uploaded information from "places.csv". The problem is I'm getting the following error:
03-15 17:00:31.137: E/AndroidRuntime(1151): FATAL EXCEPTION: main
03-15 17:00:31.137: E/AndroidRuntime(1151): Process: com.apps.mobileassistant, PID: 1151
03-15 17:00:31.137: E/AndroidRuntime(1151): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.apps.mobileassistant/com.apps.mobileassistant.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.apps.mobileassistant.MainActivity" on path: DexPathList[[zip file "/data/app/com.apps.mobileassistant-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.apps.mobileassistant-2, /system/lib]]
03-15 17:00:31.137: E/AndroidRuntime(1151): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2102)
03-15 17:00:31.137: E/AndroidRuntime(1151): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
03-15 17:00:31.137: E/AndroidRuntime(1151): at android.app.ActivityThread.access$700(ActivityThread.java:135)
03-15 17:00:31.137: E/AndroidRuntime(1151): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
03-15 17:00:31.137: E/AndroidRuntime(1151): at android.os.Handler.dispatchMessage(Handler.java:102)
03-15 17:00:31.137: E/AndroidRuntime(1151): at android.os.Looper.loop(Looper.java:137)
03-15 17:00:31.137: E/AndroidRuntime(1151): at android.app.ActivityThread.main(ActivityThread.java:4998)
03-15 17:00:31.137: E/AndroidRuntime(1151): at java.lang.reflect.Method.invokeNative(Native Method)
03-15 17:00:31.137: E/AndroidRuntime(1151): at java.lang.reflect.Method.invoke(Method.java:515)
03-15 17:00:31.137: E/AndroidRuntime(1151): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
03-15 17:00:31.137: E/AndroidRuntime(1151): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
03-15 17:00:31.137: E/AndroidRuntime(1151): at dalvik.system.NativeStart.main(Native Method)
03-15 17:00:31.137: E/AndroidRuntime(1151): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.apps.mobileassistant.MainActivity" on path: DexPathList[[zip file "/data/app/com.apps.mobileassistant-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.apps.mobileassistant-2, /system/lib]]
03-15 17:00:31.137: E/AndroidRuntime(1151): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
03-15 17:00:31.137: E/AndroidRuntime(1151): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
03-15 17:00:31.137: E/AndroidRuntime(1151): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
03-15 17:00:31.137: E/AndroidRuntime(1151): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
03-15 17:00:31.137: E/AndroidRuntime(1151): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2093)
MobileAssistant App Manifest.xml
<?xml version="1.0" encoding="utf-8" standalone="no"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.apps.mobileassistant">
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19"/>
<uses-permission android:name="android.permission.INTERNET"/>
<permission android:name="com.apps.mobileassistant.permission.C2D_MESSAGE" android:protectionLevel="signature"/>
<uses-permission android:name="com.apps.mobileassistant.permission.C2D_MESSAGE"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.USE_CREDENTIALS"/>
<application android:allowBackup="true" android:icon="#drawable/ic_launcher" android:label="#string/app_name" android:theme="#style/AppTheme">
<activity android:label="#string/app_name" android:name="com.apps.mobileassistant.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<service android:name=".GCMIntentService"/>
<receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<category android:name="com.apps.mobileassistant"/>
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
<category android:name="com.apps.mobileassistant"/>
</intent-filter>
</receiver>
<activity android:launchMode="singleTop" android:name=".RegisterActivity"/>
</application>
</manifest>
Also when in debug mode I get a "Source Not Found" error in Thread[<1> main].
Can someone help me with this?
Just as it is exactly what your current message error is saying to you:
ComponentInfo{com.apps.mobileassistant/com.apps.mobileassistant.MainActivity}:
java.lang.ClassNotFoundException:
Didn't find class "com.apps.mobileassistant.MainActivity"
on path: DexPathList[[zip file "/data/app/com.apps.mobileassistant-2.apk"],
nativeLibraryDirectories=[/data/app-lib/com.apps.mobileassistant-2
You either have made some mistake on setting up your project and required library, or simply has some class missing, or has not informed in your code the respective class through import and the class name.
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
I made a test a program for my University which uses Google maps following a tutorial. I made everything like in tutorial, but my app crashes before even showing anything with message "Unfortunately SocialFoot has stopped". I tried to debug and it seems like it crashes even before entering to onCreate method. This is my code:
package it.univpm.dii.socialfoot;
import com.actionbarsherlock.app.SherlockMapActivity;
import android.os.Bundle;
public class SocialFootActivity extends SherlockMapActivity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
#Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
Logcat:
05-18 19:29:59.343: E/AndroidRuntime(3405): FATAL EXCEPTION: main
05-18 19:29:59.343: E/AndroidRuntime(3405): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{it.univpm.dii.socialfoot/it.univpm.dii.socialfoot.activities.SocialFootActivity}: java.lang.ClassNotFoundException: it.univpm.dii.socialfoot.activities.SocialFootActivity
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.os.Handler.dispatchMessage(Handler.java:99)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.os.Looper.loop(Looper.java:137)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.app.ActivityThread.main(ActivityThread.java:4424)
05-18 19:29:59.343: E/AndroidRuntime(3405): at java.lang.reflect.Method.invokeNative(Native Method)
05-18 19:29:59.343: E/AndroidRuntime(3405): at java.lang.reflect.Method.invoke(Method.java:511)
05-18 19:29:59.343: E/AndroidRuntime(3405): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-18 19:29:59.343: E/AndroidRuntime(3405): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-18 19:29:59.343: E/AndroidRuntime(3405): at dalvik.system.NativeStart.main(Native Method)
05-18 19:29:59.343: E/AndroidRuntime(3405): Caused by: java.lang.ClassNotFoundException: it.univpm.dii.socialfoot.activities.SocialFootActivity
05-18 19:29:59.343: E/AndroidRuntime(3405): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
05-18 19:29:59.343: E/AndroidRuntime(3405): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
05-18 19:29:59.343: E/AndroidRuntime(3405): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
05-18 19:29:59.343: E/AndroidRuntime(3405): ... 11 more
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="it.univpm.dii.socialfoot"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_GPS" />
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Sherlock" >
<uses-library android:name="com.google.android.maps" />
<activity
android:name=".SocialFootActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Layout:
The logs indicate the app is trying to launch it.univpm.dii.socialfoot.activities.SocialFootActivity, but SocialFootActivity is in package it.univpm.dii.socialfoot. If this is happening at the start of your application (since that activity is set as the launch activity), I would try cleaning and rebuilding your project and trying again.
I'm a bit stuck on this. Android is throwing a ClassNotFoundException even though there is such a class.
04-20 09:07:50.179: E/AndroidRuntime(525): FATAL EXCEPTION: main
04-20 09:07:50.179: E/AndroidRuntime(525): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.company.app/com.company.app.Main}: java.lang.ClassNotFoundException: com.company.app.Main
04-20 09:07:50.179: E/AndroidRuntime(525): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
04-20 09:07:50.179: E/AndroidRuntime(525): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
04-20 09:07:50.179: E/AndroidRuntime(525): at android.app.ActivityThread.access$600(ActivityThread.java:123)
04-20 09:07:50.179: E/AndroidRuntime(525): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
04-20 09:07:50.179: E/AndroidRuntime(525): at android.os.Handler.dispatchMessage(Handler.java:99)
04-20 09:07:50.179: E/AndroidRuntime(525): at android.os.Looper.loop(Looper.java:137)
04-20 09:07:50.179: E/AndroidRuntime(525): at android.app.ActivityThread.main(ActivityThread.java:4424)
04-20 09:07:50.179: E/AndroidRuntime(525): at java.lang.reflect.Method.invokeNative(Native Method)
04-20 09:07:50.179: E/AndroidRuntime(525): at java.lang.reflect.Method.invoke(Method.java:511)
04-20 09:07:50.179: E/AndroidRuntime(525): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-20 09:07:50.179: E/AndroidRuntime(525): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-20 09:07:50.179: E/AndroidRuntime(525): at dalvik.system.NativeStart.main(Native Method)
04-20 09:07:50.179: E/AndroidRuntime(525): Caused by: java.lang.ClassNotFoundException: com.company.app.Main
04-20 09:07:50.179: E/AndroidRuntime(525): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
04-20 09:07:50.179: E/AndroidRuntime(525): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
04-20 09:07:50.179: E/AndroidRuntime(525): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
04-20 09:07:50.179: E/AndroidRuntime(525): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
04-20 09:07:50.179: E/AndroidRuntime(525): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
04-20 09:07:50.179: E/AndroidRuntime(525): ... 11 more
There is such a class called Main in Main.java.
public class Main extends FragmentActivity which is in the package com.company.app.
It was working before but when I went back to work on the app today it just stopped working. I don't know what happened.
It is defined correctly in the Manifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.company.app"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="4" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Light" >
<activity
android:label="#string/app_name"
android:name=".Main" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Few things I've tried:
Restarting Eclipse
Restarting the emulator
Uninstalling and reinstalling the app in the emulator
Cleaning the project.
Checking if gen and src is in the Source tab of the build path.
As it looks right now, I may have to abandon the current project and start from scratch.
Any help would be much appreciated.
UPDATE:
The app works if Main extends Activity instead of FragmentActivity. Perhaps it is something with the Android Support package?
UPDATE 2:
I'm pretty sure it is. When I don't use the support package and I use the normal Fragment classes in Android 3.0 and up, the app works fine.
The problem is now fixed. :)
For some reason the Android support package removed itself from the /libs directory in the project and it was referencing it from an external location (outside the workspace directory).
I will mark Abdu Egal's first answer as correct as he directed me on the right track.
It seems that there is an error in the onCreate of your main activity. Did you provide an onCreate(Bundle savedInstance) if so , try to clear it and see if it works then.
If that does not work, try to use extend Activity instead of extend FrameActivity.
Good luck
From your quition detail i assume that you forgot to declare your FrameActivity into AndroidManifest.xml , kindly check your AndroidManifest.xml file entry.
I think you used the FragmentActivity the wrong way, I guess FragmentActivities should be a part of a normal activity, see below:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<fragment
android:name="com.mamlambo.tutorial.tutlist.TutListFragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:id="#+id/tutlist_fragment"
android:layout_weight="45">
</fragment>
<fragment
android:name="com.mamlambo.tutorial.tutlist.TutViewerFragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:id="#+id/tutview_fragment"
android:layout_weight="55">
</fragment>
</LinearLayout>
Taken from this link (part 9)
http://mobile.tutsplus.com/tutorials/android/android-sdk_fragments/
Right click on your project folder => Properties => Java Build Path => Order and Export => check the box "Android Private Libraries" if not checked. Make a clean. And it works !
I got the same problem with MobilTuts sample, problem was with support library.
I have changed the build target to a higher API than 10, something like 15 for example, and then all errors vanished.
Project Properties --> Android --> Project Build Target --> Set it to 15 .e.g
Recommendation: set MIN API inside manifest to 8 at lest.
I'm having a force close problem whenever I try to launch the settings for my live wallpaper. I don't really have anything there, so I'm not sure what could possibly be causing the problem... Here is the logCat
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): FATAL EXCEPTION: main
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): java.lang.IllegalStateException: Could not execute method of the activity
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at android.view.View$1.onClick(View.java:2072)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at android.view.View.performClick(View.java:2408)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at android.view.View$PerformClick.run(View.java:8818)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at android.os.Handler.handleCallback(Handler.java:587)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at android.os.Handler.dispatchMessage(Handler.java:92)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at android.os.Looper.loop(Looper.java:143)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at android.app.ActivityThread.main(ActivityThread.java:4701)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at java.lang.reflect.Method.invokeNative(Native Method)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at java.lang.reflect.Method.invoke(Method.java:521)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at dalvik.system.NativeStart.main(Native Method)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): Caused by: java.lang.reflect.InvocationTargetException
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at com.android.wallpaper.livepicker.LiveWallpaperPreview.configureLiveWallpaper(LiveWallpaperPreview.java:113)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at java.lang.reflect.Method.invokeNative(Native Method)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at java.lang.reflect.Method.invoke(Method.java:521)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at android.view.View$1.onClick(View.java:2067)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): ... 11 more
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): Caused by: java.lang.SecurityException: Permission Denial: starting Intent { cmp=com.SSTSoft.BallInABox/.BallInABoxSettings (has extras) } from ProcessRecord{45b9eb18 12429:com.android.wallpaper.livepicker/10050} (pid=12429, uid=10050) requires null
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at android.os.Parcel.readException(Parcel.java:1247)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at android.os.Parcel.readException(Parcel.java:1235)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1298)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1373)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at android.app.Activity.startActivityForResult(Activity.java:2817)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at android.app.Activity.startActivity(Activity.java:2923)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): ... 15 more
I think it's that permission denial line, but I have no clue what could be causing it... Is there some hidden permission I need to set? This is my first liveWallpaper.
Thanks!
Ugh, I found the problem... It turns out I needed the preference activity in the manifest have exported set to "true". There's an hour I'll never get back!
While the accepted answer definitely works, it's not the correct way to do it. Setting export to true just means the activity can be launched outside of your application. However, the way this should be done is to declare the activity like this:
<activity android:name="com.example.SettingsActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
Yes, you need to set the SET_WALLPAPER permission in Android manifest file. You can use the following line inside the <manifest></manifest> element;
<uses-permission android:name="android.permission.SET_WALLPAPER" />
Update:
Reference: <uses-permission> element.