Implementing GreenDroid afterwards

1.3k Views Asked by At

I just added the GreenDroid Library into my Application. I extended the startview with GDActivity and added the NFFApplication and added into the Manifest under the application tag android:name=".logic.NFFApplication".

NFFAplication:

public class NFFApplication extends GDApplication {

    @Override
    public Class<?> getHomeActivityClass() {
        return NFFApplication.class;
    }

    @Override
    public Intent getMainApplicationIntent() {
        return new Intent(NFFApplication.this,MainView.class);
    }

}

Login Activity:

public class LoginView extends GDActivity {

    private ProgressDialog pd = null;
    Editor editor = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setTitle("Movie");
    setActionBarContentView(R.layout.loginlayout);

LogCat:

04-05 16:12:16.714: E/AndroidRuntime(443): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.korn.nff/com.korn.nff.view.LoginView}: android.view.InflateException: Binary XML file line #27: Error inflating class greendroid.widget.ActionBar
04-05 16:12:16.714: E/AndroidRuntime(443):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
04-05 16:12:16.714: E/AndroidRuntime(443):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
04-05 16:12:16.714: E/AndroidRuntime(443):  at android.app.ActivityThread.access$2200(ActivityThread.java:119)
04-05 16:12:16.714: E/AndroidRuntime(443):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
04-05 16:12:16.714: E/AndroidRuntime(443):  at android.os.Handler.dispatchMessage(Handler.java:99)
04-05 16:12:16.714: E/AndroidRuntime(443):  at android.os.Looper.loop(Looper.java:123)
04-05 16:12:16.714: E/AndroidRuntime(443):  at android.app.ActivityThread.main(ActivityThread.java:4363)
04-05 16:12:16.714: E/AndroidRuntime(443):  at java.lang.reflect.Method.invokeNative(Native Method)
04-05 16:12:16.714: E/AndroidRuntime(443):  at java.lang.reflect.Method.invoke(Method.java:521)
04-05 16:12:16.714: E/AndroidRuntime(443):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-05 16:12:16.714: E/AndroidRuntime(443):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-05 16:12:16.714: E/AndroidRuntime(443):  at dalvik.system.NativeStart.main(Native Method)
04-05 16:12:16.714: E/AndroidRuntime(443): Caused by: android.view.InflateException: Binary XML file line #27: Error inflating class greendroid.widget.ActionBar
04-05 16:12:16.714: E/AndroidRuntime(443):  at android.view.LayoutInflater.createView(LayoutInflater.java:513)
04-05 16:12:16.714: E/AndroidRuntime(443):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
04-05 16:12:16.714: E/AndroidRuntime(443):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
04-05 16:12:16.714: E/AndroidRuntime(443):  at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
04-05 16:12:16.714: E/AndroidRuntime(443):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-05 16:12:16.714: E/AndroidRuntime(443):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-05 16:12:16.714: E/AndroidRuntime(443):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
04-05 16:12:16.714: E/AndroidRuntime(443):  at android.app.Activity.setContentView(Activity.java:1622)
04-05 16:12:16.714: E/AndroidRuntime(443):  at greendroid.app.GDActivity.ensureLayout(GDActivity.java:187)
04-05 16:12:16.714: E/AndroidRuntime(443):  at greendroid.app.GDActivity.getActionBar(GDActivity.java:265)
04-05 16:12:16.714: E/AndroidRuntime(443):  at greendroid.app.GDActivity.setTitle(GDActivity.java:256)
04-05 16:12:16.714: E/AndroidRuntime(443):  at com.korn.nff.view.LoginView.onCreate(LoginView.java:39)
04-05 16:12:16.714: E/AndroidRuntime(443):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-05 16:12:16.714: E/AndroidRuntime(443):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
04-05 16:12:16.714: E/AndroidRuntime(443):  ... 11 more
04-05 16:12:16.714: E/AndroidRuntime(443): Caused by: java.lang.reflect.InvocationTargetException
04-05 16:12:16.714: E/AndroidRuntime(443):  at greendroid.widget.ActionBar.<init>(ActionBar.java:130)
04-05 16:12:16.714: E/AndroidRuntime(443):  at java.lang.reflect.Constructor.constructNative(Native Method)
04-05 16:12:16.714: E/AndroidRuntime(443):  at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
04-05 16:12:16.714: E/AndroidRuntime(443):  at android.view.LayoutInflater.createView(LayoutInflater.java:500)
04-05 16:12:16.714: E/AndroidRuntime(443):  ... 24 more
04-05 16:12:16.714: E/AndroidRuntime(443): Caused by: android.content.res.Resources$NotFoundException: File res/drawable-hdpi/title_bar_shadow.9.png from drawable resource ID #0x0
04-05 16:12:16.714: E/AndroidRuntime(443):  at android.content.res.Resources.loadDrawable(Resources.java:1710)
04-05 16:12:16.714: E/AndroidRuntime(443):  at android.content.res.TypedArray.getDrawable(TypedArray.java:548)
04-05 16:12:16.714: E/AndroidRuntime(443):  at android.view.View.<init>(View.java:1850)
04-05 16:12:16.714: E/AndroidRuntime(443):  at android.view.View.<init>(View.java:1799)
04-05 16:12:16.714: E/AndroidRuntime(443):  at android.view.ViewGroup.<init>(ViewGroup.java:284)
04-05 16:12:16.714: E/AndroidRuntime(443):  at android.widget.LinearLayout.<init>(LinearLayout.java:92)
04-05 16:12:16.714: E/AndroidRuntime(443):  at greendroid.widget.ActionBar.<init>(ActionBar.java:134)
04-05 16:12:16.714: E/AndroidRuntime(443):  ... 28 more
04-05 16:12:16.714: E/AndroidRuntime(443): Caused by: java.io.FileNotFoundException: res/drawable-hdpi/title_bar_shadow.9.png
04-05 16:12:16.714: E/AndroidRuntime(443):  at android.content.res.AssetManager.openNonAssetNative(Native Method)
04-05 16:12:16.714: E/AndroidRuntime(443):  at android.content.res.AssetManager.openNonAsset(AssetManager.java:390)
04-05 16:12:16.714: E/AndroidRuntime(443):  at android.content.res.Resources.loadDrawable(Resources.java:1702)
1

There are 1 best solutions below

0
On BEST ANSWER

I'm not 100% sure if this is the issue, but can it be that you've forgotten to override the theme? Greendroid needs a custom theme for the application to run.

Here's the line in the greendroid documentation:

You finally need to make your project use the GreenDroid base theme. In your AndroidManifest.xml, go to the application tag and add android:theme="@style/Theme.GreenDroid" as a new attribute.

Steps you have to follow:

  1. Download the GreenDroid library on your computer with a simple: git clone http://github.com/cyrilmottier/GreenDroid.git. As usual, Git will clone the GreenDroid repository and create a folder GreenDroid that contains a 3 folders: GreenDroid: the core library. This is the code that will be mostly linked to your code GreenDroid-GoogleAPIs: GreenDroid's extension including Google APIs related features (GDMapActivity for instance) GDCatalog: the demonstration application. This project contains a lot of snippet of code showing you how to use GreenDroid.

  2. Since May 2010, the ADT plugin added an amazing new feature: the ability to work with library projects. Using GreenDroid consists on applying the GreenDroid project as a library to your application. A complete description on how to use library projects is given on the Android documentation website. Make sure your development environment uses the latest tools and platforms, since older releases of the tools and platforms do not support building with library project.

  3. In case you want to use some Google APIs features, make sure you are using the GreenDroid-GoogleAPIs library. GreenDroid-GoogleAPIs is based on GreenDroid. As a result, you don't need to link GreenDroid as an Android library to your project. By default, the GreenDroid theme inherits from @android:style/Theme. If your project inherits from a different theme, you'll have to modify the GreenDroid library on your own (and do that everytime you are updating GreenDroid as updating deletes all of your changes - still working on a way to overcome that problem). Open the res/values/gd_themes.xml and replace the parent theme @android:style/Theme with your own theme.

  4. A lot of GreenDroid's feature (GDActivity, GDListActivity or GDTabActivity for instance) requires your application to be a GDApplication so make sure your application is a GDApplication class. In order to do that, simply add android:name="greendroid.app.GDApplication (where greendroid.app.GDApplication may be replaced by your own class that inherits from GDApplication) in the application tag of your AndroidManifest.xml.

  5. You finally need to make your project use the GreenDroid base theme. In your AndroidManifest.xml, go to the application tag and add android:theme="@style/Theme.GreenDroid" as a new attribute.