Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run the Android Support4Demo in Eclipse

I'm struggling with getting the demo of the level 4 support library set up in Eclipse and running. Apologies in advance for the length; I want to completely describe what I have done. Would really appreciate the help of one of the experts here in SO.

Here is what I've done -

  • 1 - Create New Project:

    Rather than trying to let Eclipse "Create project from existing source" or "Create project from existing sample" and all the problems that seem to result from those project setup approaches I created a new project.

  • 2 - 'src', 'res' sub-directories:

    Deleted all files that were auto-created from these directories and then reproduced the folder structure and all files into the project from the sdk version of the Support4Demo.

  • 3 - Added support jar

    Created a sub-directory named 'lib' and added a COPY of the android-support-v4.jar to it. I then added this to the Build Path (this resulted in new folder named "Reference Libraries" with the android-support-v4.jar file in it.

  • 4 - AndroidManifest.xml:

    Replaced the auto-generated manifest with the one from the demo project directory.

Problem/Question

I get a warning from eclipse about the target API level in

Attribute minSdkVersion (4) is lower than the project target API level (13)

OK, I understand that one. (I want to be able to run this on a level 8 (or lower) virtual device. That's what this support library is for.)

But I also get an error in the manifest file that I can't make sense of -

error: No resource identifier found for attribute 'stopWithTask'
in package 'android' AndroidManifest.xml /Supportv4Demo line 226
Android AAPT Problem

The line in the manifest that this refers to is a Service reference -

<service android:name=".content.LocalServiceBroadcaster$LocalService"
                     android:stopWithTask="true" />

I'm not very experienced with Eclipse (and that's certainly part of my problem) but I suspect that Eclipse has tinkered with the includes somehow and that I'm not getting the proper package reference somewhere. I've inspected the class LocalServiceBroadcaster and it's 'includes' look like this -

package com.example.android.supportv4.content;

import com.example.android.supportv4.R;
import android.R.attr;
import android.app.Activity;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
... more includes
import android.support.v4.app.ServiceCompat;
import android.support.v4.content.LocalBroadcastManager;
... more includes

How do I get this demo of the support libraries setup and running?
Thanks in advance for any help you can provide!

like image 245
PaulP Avatar asked Dec 08 '25 07:12

PaulP


1 Answers

As you can see in the docs, stopWithTask is only available in API level 14 and above. Either change your target SDK level to 14 or remove that attribute. (It's nothing to do with the includes).

like image 93
kabuko Avatar answered Dec 09 '25 19:12

kabuko