Imported android project to Eclipse: Cant compile - android

I have imported a project to Eclipse. The version of the API was 15 and it compiled successfully, but I needed 7th because on my phone the OS cannot be updated. After changing the version of the Android API to older one (7th) I can't compile the project, the follwing errors occures:
import android.hardware.usb.UsbConstants;
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbDeviceConnection;
import android.hardware.usb.UsbEndpoint;
import android.hardware.usb.UsbInterface;
import android.hardware.usb.UsbManager;
It says R cannot be resolved to a variable:
setContentView(R.layout.main);
And in main.xml
android:layout_width="match_parent"
it says: String types not allowed (at 'layout_width' with value 'match_parent').
Is it possible to resolve this errors, but still using the old API version?

If you need the USB functionality: No. It exists since API level 12.

You have to compile your project with the latest Android Api.
Project Properties -> Android -> Android 4.0
In the manifest, you can set the
<uses-sdk android:minSdkVersion="7" />
If you are not using any library or new feature, it should work.

Add the Jar of API 15 from platforms folder and include in Android MAnifesh as Android minsdk as 9 and target sdk as 15 then i hope your app will run

Related

Can not resolve symbol error in import statements in Android Studio Project

android studio code screeshot
Some Android imports are showing...Cant resolve symbol. even though those classes are available in SDK/Sources/...|(Red color code in picture)
Did you setup support library?
I think this is similar question.
You must setup support library same version of your project SDK version.
(ex. Android SDK version is 22, you must import com.android.support:appcompat-v7:22.+)

eclipse can't find android.support.v4.widget.SwipeRefreshLayout

Even after clicking on Add Support Library and choosing version 19, eclipse still can't find android.support.v4.widget.SwipeRefreshLayout. Does anyone know how to get this to work? I am using
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="19" />
I am working on a mac mavericks computer with Juno.
update: import section
import java.util.Observer;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.TextView;
import android.support.v4.widget.SwipeRefreshLayout;//red underline
Update
By the way, I don't know if this matters: this is an Appengine Connected Android Project, which I build using Google-Eclipse-Plugin
Update 3:
It's looking like the Android Support Library 19.1.0 is not available through the SDK Manager. How else might I obtain it?
It was difficult to update the support library to version 19.1 so i downloaded it manually from https://dl-ssl.google.com/android/repository/support_r19.1.zip and added the jar to my build path manually. works for me. I dont know why the 19 update shows instead of 19.1.0
So it turns out the library is in the following location
/android-sdk-macosx/extras/android/m2repository/com/android/support/support-v4/19.1.0
As opposed to the usual
/android-sdk-macosx/extras/android/support
Also I had to restart eclipse and go to Android SDK Manager over and over and over, until the 19.1.0 version shows up.
I hope this saves someone else some trouble.
The SDK Manager update Android Support Library to 19.1.0.
But when you use Android Tools > Add Support Library, eclipse update Android Support Library to 19.0. I think this is a bug. Copy Android Support Library 19.1.0 to libs folder manually.
It looks as if you don't have the android-support-v4.jar in Java Build Path. Add it from the android-support-v7-appcompat.
For some reason, even though you may include v4 support library or you may have v7-appcompat included in your project, you may not be able to import SwipeRefreshLayout.
You need to make sure that
you change the target=android-19 to target=android-22(It should be anything greater that 19) and
manually import : import android.support.v4.widget.SwipeRefreshLayout; in your activity which will resolve the import related issue.
I had the same problem with old project. But when I create new project, Eclipse can find this import.
It's a problem with updating support library from eclipse: https://code.google.com/p/android/issues/detail?id=67991
Just update it by starting Android SDK manager manually and add new v4 lib to your project.
Thanks for tehnolog's tips.
Update to 19.1 by follow above link -> create new project and import android.support.v4 library -> simply copy android.support.v4.jar to old project's libs folder, Add To BuildPath. SwipeRefreshLayout will appear :D
In androidx, add
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
inorder to use SwipeRefreshLayout

Renderscript via the support library

Seems to me that android has an android.support.v8 package that contains Renderscript support. The thing is, this doesn't seem documented anywhere - the support library docs don't say anything about a v8 package, just v4 and v13.
Is that package supported on all devices with API level 8 and above and can it be safely used in production?
Its not yet production quality.
My Android tools contain the files:
./build-tools/18.1.0/renderscript/lib/renderscript-v8.jar
./build-tools/18.1.1/renderscript/lib/renderscript-v8.jar
Putting them in the libs/ directory of your project will result in a working build in Eclipse and with ant.
PSA for Googlers: RenderScript is now part of the Android Support Library. You can use it on Android 2.2+.
I have eclipse, android sdk tools 22.6.3, android platform tools 19.0.1 and I set both of these projects API 19 android 4.4.2.
I was able to compile and run hellocompute(from the samples of android 19) and wants to change it to android support v8 things.
following steps works for me:
1.set android build target to 4.4.2 api 19.
2.add "rendersrcipt-v8.jar" to libraries in android build path
3.in project.properties set things like
"target=android-19
renderscript.target=19
renderscript.support.mode=true
sdk.buildtools=19.0.3"
4.Comment out the following import lines:
import android.renderscript.RenderScript;
import android.renderscript.Allocation;
and import
import android.support.v8.renderscript.*;
5.clean the project and rebuild.

Android Support Library errors

I have recently updated a project that makes use of the Android Support Library ( android-support-v4.jar )
I updated the support library by "Android Tools > Add Support Library"
After doing this my project fails to build and the following imports that worked fine previously now error.
import android.support.v4.app.FragmentManager;
import android.support.v4.widget.SearchViewCompat;
import android.support.v4.widget.SearchViewCompat.OnQueryTextListenerCompat;
With errors long the lines of "The import android.support.v4.widget cannot be resolved"
What have I done wrong? how do I get it working again?
Which API are you using? It is best to use the Android SDK Manager in Eclipse(ADT) plugin to download the support libraries.
The Android Support v4 JAR needs to be in the 'libs' folder of your project. Make sure you have the JAR 'copied' in the folder. It is best to manually do it yourself to make sure it is there.
The best way to fix the 'red' import errors in Eclipse is
Ctrl + Shift + O
to automatically import the correct imports.
Please let me know if this helps! I have had problems with Android imports as well.
Regards,
The jar file also needs to be in your build path.

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

Categories

Resources