android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar - android

I'm new to android programming and started a sample hello world program, but stuck with below error:
07-05 13:52:20.830: W/dalvikvm(898): threadid=1: thread exiting with uncaught exception (group=0xb2ac4d70)
07-05 13:52:20.850: E/AndroidRuntime(898): FATAL EXCEPTION: main
07-05 13:52:20.850: E/AndroidRuntime(898): Process: com.example.helloandroid, PID: 898
07-05 13:52:20.850: E/AndroidRuntime(898): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.helloandroid/com.example.helloandroid.MainActivity}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
07-05 13:52:20.850: E/AndroidRuntime(898): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
07-05 13:52:20.850: E/AndroidRuntime(898): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
07-05 13:52:20.850: E/AndroidRuntime(898): at android.app.ActivityThread.access$800(ActivityThread.java:138)
07-05 13:52:20.850: E/AndroidRuntime(898): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
07-05 13:52:20.850: E/AndroidRuntime(898): at android.os.Handler.dispatchMessage(Handler.java:102)
07-05 13:52:20.850: E/AndroidRuntime(898): at android.os.Looper.loop(Looper.java:136)
07-05 13:52:20.850: E/AndroidRuntime(898): at android.app.ActivityThread.main(ActivityThread.java:5026)
07-05 13:52:20.850: E/AndroidRuntime(898): at java.lang.reflect.Method.invokeNative(Native Method)
07-05 13:52:20.850: E/AndroidRuntime(898): at java.lang.reflect.Method.invoke(Method.java:515)
07-05 13:52:20.850: E/AndroidRuntime(898): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
07-05 13:52:20.850: E/AndroidRuntime(898): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
07-05 13:52:20.850: E/AndroidRuntime(898): at dalvik.system.NativeStart.main(Native Method)
07-05 13:52:20.850: E/AndroidRuntime(898): Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
07-05 13:52:20.850: E/AndroidRuntime(898): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275)
07-05 13:52:20.850: E/AndroidRuntime(898): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872)
07-05 13:52:20.850: E/AndroidRuntime(898): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129)
07-05 13:52:20.850: E/AndroidRuntime(898): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303)
07-05 13:52:20.850: E/AndroidRuntime(898): at android.app.Activity.setContentView(Activity.java:1930)
07-05 13:52:20.850: E/AndroidRuntime(898): at com.example.helloandroid.MainActivity.onCreate(MainActivity.java:13)
07-05 13:52:20.850: E/AndroidRuntime(898): at android.app.Activity.performCreate(Activity.java:5242)
07-05 13:52:20.850: E/AndroidRuntime(898): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
07-05 13:52:20.850: E/AndroidRuntime(898): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
Manifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.helloandroid"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.helloandroid.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>
</application>
</manifest>
MainActivity.Java
package com.example.helloandroid;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
activity_main.xml
<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"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello" />
</RelativeLayout>
Please help me to find out where I'm going wrong, I am currently on Android 4.3, API 18,
I've tried Android 4.0.3 API 15, Android 4.4W API 20; I have also tried editing sdk as below, but no luck.
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="19" />

4.4W is Android Wear SDK. (dont target to android wear device)
try changing target sdk version to 19
As mentioned in another answer:
Do not use API Level of 20 and Platform 4.4W, as Android Virtual Device. With Level 19 and Platform 4.2.2 set on ADV everything runs as it should.

I had the same issue. But sdk version was not the cause for this exception.
In the AndroidManifest.xml file you have the theme has ActionBar in it.
android:theme="#style/AppTheme" >
Change the above line to
android:theme="#android:style/Theme.DeviceDefault" >
That will fix the exception.

4.4W is Android Wear SDK.
This error is because the device you are targeting is Android Wear which has a different design pattern.
If you are developing a mobile application, change your AVD and target any API below 20 or choose API 20 (L preview).
Or if you are really targeting for Android Wear, change your app design.

Am using Android Studio beta 0.8.6 with java 7.
I had the same issue. And fixed it this way.
In the AndroidManifest.xml file you have the theme has ActionBar in it.
android:theme="#style/AppTheme" >
Change the above line to
android:theme="#android:style/Theme.DeviceDefault" >
That will fix the exception.
As mentioned by Gangadhar in prev answer ,sdk version was not the cause for this exception.
And tested it with helloWorld app.

I got this error because I tried to run the mobile part of a wear project on the Samsung Gear device. After switching from "mobile" to "wear" in the run configurations, everything worked (API level 20 and platform 4.4W is indeed the right choice in this case).

I got this problem when trying to create the project in Eclipse.
I had to add the following to the manifest file:
<uses-feature android:name="android.hardware.type.watch" />

go to values/styles.xml and set the styles as follow:
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.DeviceDefault">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
Also, in folders res/values-v11 and res/values-v14, and all folders in values-vxx change the styles.xml file as follows:
<resources>
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.DeviceDefault">
<!-- API 14 theme customizations can go here. -->
</style>
</resources>
You have not to add action bar themes as they are not compatible with wear devices.

Change target sdk version to 19
Install API level 19 and platform 4.4.2
Use API level 19 & platform 4.4.2 while running application in AVD.

I have struggle a lot to fix the issue. Nothing work for me except the changes I made in AndroidManifest.xml.
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="21" />
Remove android:targetSdkVersion, it worked for me, you can also try.

Related

Why won't my Android App open in Fullscreen?

I know that this question has been asked before, but the provided answers did not solve my case, so I'll ask for an individual solution.
My code
My AndroidManifest.xml looks like this:
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
>
<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=".KategorieAuswahl"
android:label="#string/title_activity_kategorie_auswahl" >
</activity>
<activity
android:name=".ZeigeFragen"
android:label="#string/title_activity_zeige_fragen" >
</activity>
</application>
And my styles.xml looks like this:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
I want my App to open in fullscreen and to hide the TitleBar. The first thing I did was to add a android:theme="#android:style/Theme.NoTitleBar.Fullscreen" attribute to the <application>-Tag of my AndroidManifest.xml.
This leads to the error You need to use a Theme.AppCompat theme (or descendant) with this activity. Here is the full stacktrace:
05-27 21:24:26.889 2121-2121/de.test.myapp E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{de.test.myapp/de.test.myapp.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
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:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.AppCompatDelegateImplBase.onCreate(AppCompatDelegateImplBase.java:113)
at android.support.v7.app.AppCompatDelegateImplV7.onCreate(AppCompatDelegateImplV7.java:146)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:59)
at de.test.myapp.MainActivity.onCreate(MainActivity.java:24)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
            at android.app.ActivityThread.access$600(ActivityThread.java:130)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:4745)
            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:786)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
            at dalvik.system.NativeStart.main(Native Method)
There are multiple questions on stackoverflow referencing this error.
Approach #1
One solution suggests to change the Java inheritance from ActionBarActivity to Activity and leave the manifest as it is.
So I updated my the <style> element in my styles.xml and removed the DarkActionBar part:
<style name="AppTheme" parent="Theme.AppCompat.Light">
This still gives me the same error.
Approach #2
The next solution suggests to change my styles.xml's parent attribute from
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
to <style name="AppTheme" parent="Theme.AppCompat">
This makes it possible to use android:theme="#style/Theme.AppCompat.NoActionBar" for my <activity>, but I don't see an option to make it fullscreen then.
Approach #3
Another solution soggests to add <item name="android:windowNoTitle">true</item> to my <style> element but this doesn't change anything at all.
Conclusion
I really tried a lot, but nothing seems to work. Anyway I have problems understanding the theme inheritance chain and when I may use .NoTitleBar and .Fullscreen.
After all I don't care which theme to use, as long I can make the app fullscreen without a title bar. Can you help me to pick the right attributes?
extend ActionBarActivity or the new one, and use Theme.AppCompat.NoActionBar, now in your Activity
if (Build.VERSION.SDK_INT < 16) {
Activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}else{
Activity.getWindow().getDecorView().
setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
}
Hope it helps..

ActionBarSherlock with Android Action Bar Style Generator

I'm using ActionBarSherlock with Android Action Bar Style Generator (http://jgilfelt.github.io/android-actionbarstylegenerator/) and it works perfectly with API v14+, but on v10-v14, I get the following:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp/com.myapp.loginregistration.Login}: java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1821)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1842)
at android.app.ActivityThread.access$1500(ActivityThread.java:132)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4263)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.
at com.actionbarsherlock.internal.ActionBarSherlockCompat.generateLayout(ActionBarSherlockCompat.java:976)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.installDecor(ActionBarSherlockCompat.java:902)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:836)
at com.actionbarsherlock.app.SherlockActivity.setContentView(SherlockActivity.java:229)
at com.myapp.loginregistration.Login.onCreate(Login.java:25)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1785)
Is there anyway to get the style generator to work with the Api 10-14? Right now I have it set to default to Theme.Sherlock when using the lower API phones, so the bug goes away, but its not the style I would like.
What style would you like?
The theme generator works with stock Android Holo, ActionbarSherlock or Appcompat.
Theme.Sherlock, Theme.Sherlock.Light and Theme.Sherlock.Light.DarkActionbar are all just ports of Holo, Holo.Light, and Holo.Light.DarkActionbar, so any theme that you can get in api 11+, you can get with ActionbarSherlock.
What style are you trying to achieve?

ClassNotFoundException in dalvik.system.PathClassLoader

i am running one android application in which i am using ActionBar but from supported library for android 2.2
i have added two external jar file as a support libraries
android-support-v7-appcompact.jar
android-support-v13.jar
but when i run the sample in my device i getting following runtime error
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.example.android.navigationdrawerexample/com.example.android.navigationdrawerexample.NavMainActivity}:
java.lang.ClassNotFoundException:
com.example.android.navigationdrawerexample.NavMainActivity in loader
dalvik.system.PathClassLoader[/data/app/com.example.android.navigationdrawerexample-1.apk]
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2703)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2797)
at android.app.ActivityThread.access$2300(ActivityThread.java:135)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:2132)
at android.os.Handler.dispatchMessage(Handler.java:99) at
android.os.Looper.loop(Looper.java:143) at
android.app.ActivityThread.main(ActivityThread.java:4914) at
java.lang.reflect.Method.invokeNative(Native Method) at
java.lang.reflect.Method.invoke(Method.java:521) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) at
dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.example.android.navigationdrawerexample.NavMainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.android.navigationdrawerexample-1.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
at android.app.Instrumentation.newActivity(Instrumentation.java:1033)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2695)
here is the menifest file content
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.navigationdrawerexample"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />
<application
android:label="#string/app_name"
android:icon="#drawable/ic_launcher"
>
<activity android:name="NavMainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
order of jar files
You should not only look at errors but also at warnings (orange text color in eclipse logcat view). Dalvik class loading are often preceded by some interesting informations about why a class can't be loaded by the Dalvik, something like a super class not existing.

NoSuchMethodError error for getActionBar() (API-8)

when i run the app it installs but then crashes, ecplise isnt telling there is anything wrong with my code.
i think its a problem with my manifest...
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.secondapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.secondapp" />
</activity>
</application>
</manifest>
do u guys see any problems?
10-19 10:41:25.589: E/AndroidRuntime(10147): FATAL EXCEPTION: main
10-19 10:41:25.589: E/AndroidRuntime(10147): java.lang.NoSuchMethodError: com.example.secondapp.MainActivity.getActionBar
10-19 10:41:25.589: E/AndroidRuntime(10147): at com.example.secondapp.MainActivity.onCreate(MainActivity.java:15)
10-19 10:41:25.589: E/AndroidRuntime(10147): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-19 10:41:25.589: E/AndroidRuntime(10147): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
10-19 10:41:25.589: E/AndroidRuntime(10147): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
10-19 10:41:25.589: E/AndroidRuntime(10147): at android.app.ActivityThread.access$1500(ActivityThread.java:123)
10-19 10:41:25.589: E/AndroidRuntime(10147): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
10-19 10:41:25.589: E/AndroidRuntime(10147): at android.os.Handler.dispatchMessage(Handler.java:99)
10-19 10:41:25.589: E/AndroidRuntime(10147): at android.os.Looper.loop(Looper.java:130)
10-19 10:41:25.589: E/AndroidRuntime(10147): at android.app.ActivityThread.main(ActivityThread.java:3835)
10-19 10:41:25.589: E/AndroidRuntime(10147): at java.lang.reflect.Method.invokeNative(Native Method)
10-19 10:41:25.589: E/AndroidRuntime(10147): at java.lang.reflect.Method.invoke(Method.java:507)
10-19 10:41:25.589: E/AndroidRuntime(10147): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
10-19 10:41:25.589: E/AndroidRuntime(10147): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
10-19 10:41:25.589: E/AndroidRuntime(10147): at dalvik.system.NativeStart.main(Native Method)
this is the logcat, not sure if this will help
Use getSupportActionBar available with support library v7 as described here on the 6. Retrieve the Action Bar section
getSupportActionBar documentation
java.lang.NoSuchMethodError: com.example.secondapp.MainActivity.getActionBar
On your MainActivity class, you call getActionBar() which is not available to your application.
Your android:minSdkVersion is set to 8 (API-8), which does not provide getActionBar() (only since API-11).
You should use ActionBarSherlock for good backward compatibility, or set android:minSdkVersion but then all devices < API-11 won't be targeted.
This is because the getActionBar is a method of api 11, but you can do this:
if (android.os.Build.VERSION.SDK_INT >= 11)
getActionBar().setDisplayHomeAsUpEnabled(true); //example
and in the activity class add this suppress Lint:
#SuppressLint("NewApi")
I faced this same issue before. I just replace
getActionBar()
with
getSupportActionBar()
You are probably running on a phone that is lower than API 11, which is when the method getActionBar was introduced. If you need to run on devices lower than API level 11, then you will need to guard against executing those calls that only exist on newer API levels, or else use a compatibility library such as ActionBarSherlock or Action Bar Compatiblity. (See this thread for a discussion of the differences between these two.)
Change the android:minSdkVersion="8" to android:minSdkVersion="11" and all the newer API calls that you are making will light up as errors. This will make it easier to locate those parts of your code that need attention.
For api < 11 you have to use:
getSupportActionBar();
Algo make sure you are using appcompat, add this on build.gradle, the 19.+ should be your project target version.
compile 'com.android.support:appcompat-v7:19.+'
Also if you are using invalidateOptionsMenu() for navigation drawer use this instead:
supportInvalidateOptionsMenu();

Jar-file issue with ADT r17

I seem to have a tricky problem since the latest ADT update to release 17.
I have made a simple application to illustrate my problem, I don't know if I'm doing anything wrong. The main Activity of my application is inheriting from FragmentActivity in the support package and somehow the application crashes at launch.
To illustrate, I made a sample project.
First of all, here is the code of my dummy class, DummyProjectActivity, very simple:
public class DummyProjectActivity extends FragmentActivity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
Then, there is the manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="be.emich.labs"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".DummyProjectActivity"
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>
The .jar file is imported correctly in the project and I am getting this stack trace:
E/AndroidRuntime(11509): FATAL EXCEPTION: main
E/AndroidRuntime(11509): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{be.emich.labs/be.emich.labs.DummyProjectActivity}: java.lang.ClassNotFoundException: be.emich.labs.DummyProjectActivity
E/AndroidRuntime(11509): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1879)
E/AndroidRuntime(11509): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
E/AndroidRuntime(11509): at android.app.ActivityThread.access$600(ActivityThread.java:122)
E/AndroidRuntime(11509): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
E/AndroidRuntime(11509): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(11509): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(11509): at android.app.ActivityThread.main(ActivityThread.java:4340)
E/AndroidRuntime(11509): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(11509): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(11509): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime(11509): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime(11509): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(11509): Caused by: java.lang.ClassNotFoundException: be.emich.labs.DummyProjectActivity
E/AndroidRuntime(11509): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
E/AndroidRuntime(11509): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
E/AndroidRuntime(11509): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
E/AndroidRuntime(11509): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
E/AndroidRuntime(11509): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1870)
E/AndroidRuntime(11509): ... 11 more
What am I doing wrong here? Could this be a bug in the latest dev tools?
I am encountering the problem in every project that uses FragmentActivity from the compatibility library. I don't get what could be wrong. Anyone else having this problem? Help would be greatly appreciated. I'm not having the problem with an Activity that inherits from FragmentActivity. I have uninstalled/reinstalled the application. Done various "clean project". Restarted Eclipse.
UPDATE: The issue is apparently not linked to the compatibility package but the way ADT r17 handles linking of jar files. Jars to be included should be put into the libs/ folder and ADT will link them automatically. Otherwise they will be missing from the APK and make the app crash whenever the code from the jarfile is invoked.
Until the latest release tools right click > Add compatibility package on my project wasn't working and I included the jar file manually through the project properties. I tried "Add compatibility package" again and since r17 it seems this is fixed for my machine. This fixed the problem.
http://tools.android.com/recent/dealingwithdependenciesinandroidprojects
I had a lot of trouble too. Just beginning developing and this kind of thing occured hahaha

Categories

Resources