error in every new android project with eclipse - android

I am trying to create an android project and it gives me errors
and errors appear only if I have more than one android project (R cannot be resolved to a variable ) and if i import it errors change to (R.menu.main,R.layout.activity_main,R.id.action_settings

Change android:minSdkVersion to 11 in your androidmanifest.xml. Yours is currently 8 which does not allow the call your are trying to make in onCreateView() method. First error in your screenshot clearly says it.
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="23" />
target SDK could be what you want.
Based on your comment if you still want to continue using API level 8. You should determine the API level at runtime and then call the method that works for the Android version on device. Read this for more info: Check System Version at Runtime

Related

How to combine two projects made under different API level?

I m creating a customised music player with some additional features in it.... for that i copied one project whose API level is 10 and pasted it in my current working project whose API level is 19..... i m getting an error "Using 1.7 requires compiling with Android 4.4 (KitKat); currently using API 10"...... I don't know how to make two API level work in the same project ..... please help....... i tried cleaning my project and rebuilding it ..... but after that it shows R cannot be resolved to a variable
Try changing the api level on the project, in your project manifest you will find this line:
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="19" />
Change the targetSdkVersion to 19 to make it work with Android 4.4.

Android Lint error: Class requires API level 3, current is min is 1

When running my Android app I often get a list of errors, wich says
Class requires API level 3 (current min is 1): android.hardware.SensorEventListener
I've searched for the correct answer to this, like Android tools > Clear Link Markers, but this doesn't solve the problem. Every once in a while the list of errors keeps coming back. Is it something in my project settings or are my methods deprecated? I've installed the latest SDK for Android 4.4.
In your manifest file set the sdk like this based on your requirement..
<uses-sdk
android:maxSdkVersion="17"
android:minSdkVersion="8" />
Restart and invalidate cache if this error just started up for no apparent reason
Change your application minsdk from Preference>Android>select the api level Android1.6

How to force compile error for api method that is not in minSdkVersion

I've been getting NoSuchMethodException crashes on older devices and I'm wondering why the eclipse IDE isn't giving me at least a warning for using methods that aren't supported yet on older devices. I have the minSDKVersion field set in my AndroidManifest.xml correctly. Is there anyway to get a compile error or at least a warning if I use a method that can't be run on minSdkVersion devices?
I've got the following in my AndroidManifest.xml
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" >
</uses-sdk>
I don't want to have to test every screen and function of this huge app with an old device.
Thanks!
Set the Lint check for NewApi and InlineApi to errors.
right click project --> Properties --> Android Lint Preferences.
Find NewApi and InlineApi and set the Severity box to Error or Fatal.
You can use lint. Android Lint is a new tool introduced in ADT 16 (and Tools 16) which scans Android project sources for potential bugs. It is available both as a command line tool, as well as integrated with Eclipse
If you use a method that can't be run on minSdkVersion , the lint will yell saying that the method cannot be used.
http://developer.android.com/tools/help/lint.html
Usage with eclipse
http://tools.android.com/recent/neweclipselintui
List of checks provided
http://tools.android.com/tips/lint-checks
Wrtiing custom lint rules
http://tools.android.com/tips/lint-custom-rules
UsesMinSdkAttributes
Summary: Checks that the minimum SDK and target SDK attributes are defined
Priority: 9 / 10
Severity: Warning
Category: Correctness
The manifest should contain a element which defines the minimum
minimum API Level required for the application to run, as well as the target
version (the highest API level you have tested the version for.)
More information: http://developer.android.com/guide/topics/manifest/uses-sdk-element.html

Changing android:minSdkVersion Has No Effect

I am developing an Android app using eclipse. When I try to run my project I get the error
Call requires API level 13 (current min is 8): android.view.Display#getSize which refers to the line display.getSize(size);.
So in the AndroidManifest.xml I made the following change:
<uses-sdk
android:minSdkVersion="13"
android:targetSdkVersion="17" />
However when I try running the project again, I still get the same error. The target SDK is Android 4.0. Does anyone know what is causing this error?
Try to clean your project. If it still shows error after cleaning then right click on project goto Properties>Android tab and select the Android Build target Android 3.2. And after performing this Build your project. I think it should work after this.

API Method 9 Compiles in API Method 3 Android Project, Runtime Error

I recently completed my first Android game. Made in Eclipse, the android properties have the target platform for Android 1.5 only (API level 3).
In my code, I called:
LinkedList<String> x = new LinkedList<String>();
// ...
x.pop(); // error
I can compile my code and run it on the desktop version of my project. The android project also compiles; but when I deploy it to my phone, DDMS shows me a runtime error to the effect of no such method pop exists.
This is because pop was introduced in API level 9, from what I can understand.
But my project targets API level 3. How did this code actually compile? Why did this end up as a runtime error instead of a compile-time error?
What other dark surprises are lurking in wait for me? This means I have to test every possible scenario in my game to find other errors like this; I thought this is what the compiler does -- find compile-time errors.
How did this become a runtime error? How can I find similar errors at compile time instead of at runtime?
You must have set the project's build target in 'Android properties' to at least API level 9 for it to compile successfully. Maybe your manifest just has a
<uses-sdk android:minSdkVersion="3" /> line in it, which I've always interpreted as meaning 'well it should be OK to run on this but no guarantees". Set your build target to level 3 in the build path and you should get an error marker.
Some libGDX projects don't have the actual game code inside the Android project. That's why an API call doesn't trigger the failure. If that's your situation, you need to move the code into the actual android project, not just link it to the non-android project.

Categories

Resources