How to run the Android Support4Demo in Eclipse - android

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!

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).

Related

Import appcompat to new eclipse

I just installed new eclipse version Neon Release 4.6.0, and downloaded sdk manager from there I downloaded all things but still can't find appcompat on: android-sdk-windows\extras\android\support folder..
I read alot of posts they are saying that you have to go on support folder but I have no support folder I just have :
> D:\Eclipse\android-sdk-windows\extras\android\gapid
> D:\Eclipse\android-sdk-windows\extras\android\gapid_3
> D:\Eclipse\android-sdk-windows\extras\android\m2repository
And my problem is when I create and Android Application I see errors on:
extends ActionBarActivity
and there is red lined this line too:
import android.support.v7.app.ActionBarActivity;
and alot of other lines in project for examplre R.fdf.dfd
Any idea how to import that library to may workspace and work ?
I found some files but cant make my project work I found them here :
\android-sdk-windows\extras\android\m2repository\com\android\support\appcompat-v7

How to import Listviewanimation to eclipse

Can someone give me a somewhat detailed step by step of how to import this library into an eclipse android project. I have imported many in the past, but they each seem to have different caveats to them and I can't figure this one out.
Here is the link to the main page of the library. I am trying to import lib-manipulation
http://nhaarman.github.io/ListViewAnimations/
currently when I import it there are errors in the project specifically in the manifest where it says
error: No resource identifier found for attribute 'allowBackup' in package android'
next to:
<application android:allowBackup="true">
<activity android:name="com.nhaarman.listviewanimations.itemmanipulation.swipedismiss.SwipeTouchListenerTestActivity" />
<activity android:name="com.nhaarman.listviewanimations.itemmanipulation.dragdrop.DynamicListViewTestActivity" />
</application>
It says on their page you need nineoldandroids but I already have that imported into my main project. When I import it (again the library shows errors at this point) I get the red exclamation point and sure enough there is a dependency issue which says the binary for the library cannot be found. I'd really like to use this library for my current project and those in the future. Please help! Thank you.
For Eclipse , Right click your project in the package explorer view (left side pane) and click on Properties and check Your Build Target (under Android Tab), is it pointing to the minimum SDK defined in the AndroidManifest.xml

cannot open a new android project on ubuntu

i tryed to start a new android project on ubuntu 13.04 but when i'm starting my project it gives me a compillation error.
the error is with the R library ("R cannot be resolved to a variable").
when i tries to import the import android.R it just give me another error.
any one maybe know what is my problem?
You normally shouldn't manually import R. If Organize Imports (ctrl-shift-o) causes it to be added to the list of imports, that often indicates an inconsistency between the package name used in the package statement at the top of your source file and the package name used in your AndroidManifest.xml file. Make sure those two match.

Cannot import google cloud endpoints client library class in Android project

I'm having difficulty getting Google Cloud Endpoints working. I have an Python endpoints project running on GAE and it works perfectly using the api explorer. However I'm struggling to properly generate the client library and use it in my android app. I've tried a number of sample projects and have the same problem every time; I can't import and use the model classes from the client libraries.
Here's what I'm doing (for this example I'll use the helloworld api python sample at https://github.com/GoogleCloudPlatform/appengine-endpoints-helloendpoints-python)
Unzip the sample code
Generate the client library by navigating to folder and running
<gae-sdk>\endpointscfg.py get_client_lib java helloworld_api.HelloWorldApi
Unzip the generated folder and copy into root of project in eclipse
In Eclipse add "your_app_id_appspot_com-helloworld-v1-20140310110152-java-1.17.0-rc-sources.jar" to build path (Right click the JAR> Build Path>Add to Build Path)
At this stage, I can import com.appspot.your_app_id.helloworld.model.*but I cannot import com.appspot.your_app_id.helloworld.model.Greeting
Can anyone shed any light on what's happening here? I have tried many different ways to get this to work but have the same problem every time.
Many thanks,
Tom
The problem is that by default, the generated zip file only contains a sources jar, not an actual compiled library jar which your Android app can use.
Here's the solution:
In your backend api folder (from the same place where your app.yaml is located), generate the client library as a gradle library, like so:
<gae-sdk-path>\endpointscfg.py get_client_lib java -bs gradle helloworld_api.HelloWorldApi
You'll now have a helloworld-v1.zip. Unzip this (either right here or in somewhere convenient like ~/temp)
This will create a folder called helloworld, which should have a build.gradle in there along with a src folder.
Build your client library using "gradle install" in this folder.
Copy build/libs/helloworld-v1-1.X.X-SNAPSHOT.jar into your Android app's libs folder.
Add it as a library in Android Studio by right-click/add-as-library.
Your classes should now resolve correctly.
Step 4 should install the just-built client library into your local maven repository. You can follow the instructions in readme.html in the helloworld/ folder you extracted to integrate directly with your Android app's gradle build system instead of copying the jar your built manually.
This post said that there is a bug with Android Studio's Add As Library: Android Studio: IncorrectOperationException when 'Add as Library' is clicked whilst trying to configure Google Apps Endpoints client libraries
Not sure if it applies to Eclipse.
I was able to solve this problem and have provided the solution below.
I switched to Android Studio Preview 0.4.6 from Eclipse which helped get rid of some of Googles library import issues(through I guess build.gradle config). I feel it was not a problem of Eclipse which I was using earlier.
I was able to to fix the import issues. The code on the tutorial segments on the official Google docs needs to be put in sync.
The solution is to roughly do the following changes:
In MainActivity.java, replace:
HelloGreeting with HelloworldApiGreeting
In MainActivity.java, add the following at the top:
import android.widget.Toast;
import android.os.AsyncTask;
import android.util.Log
import com.appspot.androidbackend1.helloworld.model.HelloworldApiGreeting;
import com.appspot.androidbackend1.helloworld.model.HelloworldApiGreetingCollection;
In MainActivity.java, comment the following at the top:
import com.appspot.androidbackend1.helloworld.Helloworld.Greetings.Multiply;
import com.appspot.androidbackend1.helloworld.model.HelloGreeting;
In Application.java, add the following at the top:
import com.appspot.androidbackend1.helloworld.model.HelloworldApiGreeting;
In Application.java, replace:
HelloGreeting with HelloworldApiGreeting
Hope this saves time for others

android.support.v13.dreams.BasicDream cannot be resolved

I'm trying to work on extending BasicDream which exists in package: android.support.v13.dreams. I have tried downloading all most all android version (just trying luck to get it working) but I'm unable to import it. i.e. On
import android.support.v13.dreams.BasicDream; statement I'm getting an error:
The import xxxxxx... cannot be resolved.
I tried copying my sdk/extras/libs/../android-support-v13.jar in my libs folder and added to build path but found this package does not show dreams. While typing import statement I'm able to see v13 i.e. I can write import android.support.v13.app.*; but it does not have dreams/basicdream.
Tried google and do found the source code of this class but no idea why my jar file does not have these classes or how to use it. Please suggest what am I missing here.
Update: Finally I figured out that BasicDream was part of Android Support Library version 13 Link: BasicDream source codeshipped with android 4.1.2 however latest Android Support Library version 13 does not have Basic Dream.support library v13 class list
As I'm working on some native functionality, I downloaded BasicDream source code from the link mentioned above and included in same folder where I have my other source files. Updated the package to my application package
In your case probably the best way to get it is to check code of this class on GrepCode and manually resolve (copy) all dependencies. Good luck!

Categories

Resources