Cannot create android project compile with older API (like API 17) - android

Why I can only create android project that compile with API 21 or API 22? other than this 2, all will have error with R cannot be resolved, and if I import android.R, it will give me another error which is activity_main cannot be resolved or is not a field. I search for solution from Google but all doesn't work for me. Help me please.
and here is the error if I import android.R
and if I change to avtivity_list_item there still have error.

Well for the first error:
check your SDK Manager to see if you have the the 4.2.2(API 17) installed.
And for the second:
I had this problem sometime ago, all you have to do is clean your project and build it again as this answer suggests link, see if that helps.

Related

cannot find symbol class DiskInfo and some other packages despite being present in SDK folder

I have an activity in which i have imported android.os.storage.DiskInfo and some other packages. Android Studio gives errors when trying to make the project saying:
error: cannot find symbol class DiskInfo
When i tried to resolve this problem i found out that all packages are present in folder $SDK-HOME\sources\android-24\android\os\storage but i don't know why Studio couldn't import them properly.
Is there anybody who have experienced problems in import and have solved it?
Thanks
p.s: i am using Android API 24
That is because of #hide in android source code. Actually Android is not allowing developers to use some classes. A solution is to use modified SDK which contains hidden classes. you can find it here https://github.com/anggrayudi/android-hidden-api
Check out : TargetSdk version and support package version.

Compiling and using AppCompatActivity in Eclipse

I have the latest Android Support Library, Android Support Repository and Google Repository (Rev. 23.1, 24, 22 respectively) and working with Eclipse Mars.1(4.5.1)
In the process of giving a make-over to an existing app, I am trying to import the v7.AppCompatActivity library, closing all other projects in workspace and silent prayers. ( ;-) )
Observations:
I daresay I have been unsuccessful even after following the instructions here to the dot.
Ian Lake's blog looks all hunky-dory, but Utopian.
Reading up tons of excellent answers on SO did not yet help. No matter what target is set in the project.properties page or what Build Target is set in the Eclipse Project Properties dialog - just cannot seem to get rid of this (and very similar) compile error(s):
android-support-v7-appcompat\res\values-v23\styles_base.xml:20: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.
Going by the number of similar questions, I am surely not alone. Pray, can someone kindly throw some light on how to import the v7 support library without going insane?
Thanks in advance!
None of the answers or blogs pointed out the following, except #pkuszewski.
The above issue resolves on
upgrading to Android 6 Marshmallow API 6.0 with the SDK manager
setting the Build Target for the AppCompat project to Android 6.0
Did I hear, "Duh"? :)
Thanks, #pkuszewski!
SDK Manager fragment looks like this, post the fix:

resolving appcompat_v7 error

I am having a issue regarding the resolving of appcompat_v7...As mentioned on many answers i imported the jar file from the \sdk\extras\android\support\v7\appcompat\libs...
but the problem is under properties->android i am getting a red cross next to appcompat_v7
as mentioned on various answers i then clicked on add button here...but i get no library name
the library is installed as the import is working properly as can be seen here the import shows no error..but my style.xml file in the res folder is showing the following error
can somebody please tel me what i am doing wrong here..
also my SDK manager shows that my android support library is installed...
I am just new to android and cant figure out what I am doing wrong here..
You dont import jar's from the appcompact-v7 library. You import the library itself in your workspace. Then you add the library into your project. In your project you can remove the appcompact-v7 in red and add it again. That should solve the issue.
Note also that:
You must have the latest versions of SDK Tools / Build Tools / Platform Tools. If you try this and it doesn't work, then go to the Android SDK Manager and make sure you have the latest versions of the required tools.
In case your project only requires API level 14 (Ice Cream Sandwich) & above, select API level 14 for "minimum required SDK" in the project wizard when you create a new project. Now the appcompat_v7 library will not be required for this project, and the application will use the native ActionBar class which is present in AOSP builds from ICS onwards.

Android samples - Accelerometer and APIDemos do not build

I am new to Android development. I have succesfully installed eclipse with Android Developer Tool plugin and many of the samples work fine.
But Android samples - Accelerometer and APIDemos do not build. I see many build errors notifying to fix the errors in code. I dont think Google has released APIDemo sample with build errors.
Thanks in advance, please advice how to fix these errors, or if any configuration/setting is required.
I have set the Java compiler compliance level to 1.6.
Error information(for acceralometer sample):
The project contains error(s) in application. Please fix them before running
Error details:
The method onAccuracyChanged(Sensor, int) of type AccelerometerPlayActivity.SimulationView must override a superclass method
AccelerometerPlayActivity.java /AccelerometerPlay/src/com/example/android/accelerometerplay line 456
Java Problem
Call requires API level 8 (current min is 5):
android.view.Display#getRotation AccelerometerPlayActivity.java /AccelerometerPlay/src/com/example/android/accelerometerplay
line 389 Android Lint Problem
Regards,
Jai
Look for the line androidminSdkVersion ="5" in your android.manifest file
and change its value from 5 to 8 or anything more than 8
Alternative is
Go to project properties by right clicking on you project,
thereafter look for Android in properties.
You have to select the build target here equivalent to the api for which it the sample project is build for
Refer Image
Say if you are using the sample from folder android-12 then you have to check the same option(ie API Level 12) here in properties
A possible reason can be a slow PC, which does not build in time. Then errors occur due to absence of R.java
In that case (errors are with something like R.id.stuff), build the project and wait.
I found the fix myself!
Earlier I tried with Andriod version 4.0. Now I just tried ApiDemos sample with Android version 4.1.2. It worked fine. I also deployed the apk in my mobile. It just works fine.

Compilation Error in Android Api sample applicaiton after import into eclipse

I have imported the android api sample applicaition into Eclipse. I am getting compile error in import and where ever this R is used. Api levels are fine, I couldnt see R.class is getting generated. Please spot my prob and help me out fix this.
`import com.example.android.apis.R;`
clean the project(go to project->clean)...if not solved
manually add the library(right click project->properties-->search for 'java build path)
I finally debugged why this hasn't been building. (I had it running in older SDKs.)
After trying the various suggestions here to no avail, I found that the project is missing the accessibility_node_provider_instructions string resource from res/values/strings.xml. Plus it also needed the android-support-v4.jar library for PrintBitmap.java.
This is with Android 4.4.2 (API 19).
Check if the package name in the manifest tag of AndroidManifest.xml is correct com.example.android.apis
If you have created the api samples project via. eclipse -> New ->Android Sample Project you should not have any project with package.
The jre system libray was not added in the project, once added the issue get resolved.

Categories

Resources