I am getting a new errors and a warning after that for the same application!
Some general advices for those warnings:
These errors look like you can solve them by choosing project > clean from the menu or simply by restarting eclipse (please try both). Also have a look at AndroidManifest.xml.
There should be lines which looks something like this:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
Set minSdkVersion to an API level you want to support at least. Nowadays, this is API level 8 in most cases, if you want to support very old devices, set it to 4 or something. targetSdkVersion should be set to the android version of your test device you use for development. Also, be aware you need to download the matching sdk (in this case API level 18) through Android SDK Manager which you can find in the Window menu entry of eclipse.
Make sure you have The correct build target set in eclipse: right click project > properties > Android > Project Build Target should have a correct check.
Receiving the following message when uploading my latest APK:
You need to use a different version code for your APK because you already have one with version code 1.
I am setting the android:versionCode and android:versionName correctly (in /app/src/main/AndroidManifest.xml):
android:versionCode="2"
android:versionName="1.1"
Also, I am using the same keystore that the project was initialized / originally built with
This is my 5th app and I've never encountered this issue before.
Is there some other place within a typical Android app project that could override the versionCode found in the AndroidManifest.xml file? Or maybe some kind of "de-linter" tool that'll help?
The path names suggest you're using Android Studio. Android Studio is using the Gradle build system. Possibly the build.gradle files specify version name/code that override whatever you set in manifest. So, to change it, edit your build.gradle file(s) and check for overridden versionCode / versionName.
Clean your app. Then save all files and then build
I was developing an application on API 9, 2.3.3 then I changed the build to 4.0.3 because I only had 4.0.3 installed other than 2.3.3 and 2.2 due to admob's policy.
I have tried to embed admob into my Android application but have been failing ever since. I finally did it on my school computer and it works perfectly. However, I imported my project into my own laptop, trying to edit and add on more coding and lots of problems started to arise without even editing any part of the code.
What I know is that my school PCs are using eclipse indigo and I am using juno.
Is it because I did not import my codes properly or it is my eclipse version or something else?
Here's the dummy code I did.
MainActivity.Java
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
XML
<com.google.ads.AdView android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="the right code"
ads:adSize="BANNER"
ads:loadAdOnCreate="true"/>
Manifest
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
So there is it. I have looked into many sites for help but to no avail.
When you move a project in between computers you have to re-import things (because their file path's have changed). Try looking in your imports and seeing if the SDK is still imported.
Whether it is or not, if you are using ADT tools r-17 and up then you have to create a libs/ folder in you main directory, and put a copy of the adMob SDK in there.
Hope this solves your problem
Check for updates and installed sdks in your sdk manager in eclipse and check if the admob sdk for your target is installed.
and do not forget to set your application target to google apis x.y
When I first created my test project I told it that my package was com.example.test. Now, i've renamed the source package to com.imcool.android, and I also updated the package in my manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.imcool.android"
android:versionCode="1"
android:versionName="1.0" >
After a full clean, Android asks me if I want to update my launch configurations, I click yes. I try and run an android unit test and I get this error:
Test run failed: Unable to find instrumentation info for: ComponentInfo{com.imcool.android/android.test.InstrumentationTestRunner}
If I change the package in my manifest back to com.example.test it works, even though my actual source package name is still com.imcool.android.
Whats the deal?
it's not android that has asked you . it's eclipse . :)
anyway, just go to the run-configuarations and delete all of the items that aren't needed anymore , and do the run again . this way it will forget about the previous configuration and will use only those that you ask of it.
This question already has answers here:
R cannot be resolved - Android error
(108 answers)
Closed 10 years ago.
So I copied this tutorial example thing right from Google's android site and I ma getting an error that R.id cannot be resolved.
Here is my Java file
package com.TestApp.HelloWebView;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class HelloWebView extends Activity {
WebView mWebView;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("http://www.google.com");
}
}
Here is my res/layout/main.xml
<?xml version="1.0" encoding="utf-8"?>
<WebView android:id="#+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
You have to import your R class
import com.TestApp.HelloWebView.R;
Also as Demand posted you have to use a namespace for your layout.
?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
I had the same problem when I updated my Android SDK. Suddenly new projects could not generate the R.java file.
importing my R.java didn't help because it wasn't generated
cleaning and building the project didn't help either -- the /gen folder was still empty.
I found that after the upgrade, the adb server didn't start up properly. So a manually started it:
$ cd $ANDROID_SDK/platform-tools
$ adb start-server
Then I restarted Eclipse and did a clean/build on the project, which generated the R.java file.
If using Eclipse, run a clean build (Project/Clean...); this can often clear issues with the resources not being compiled correctly.
Did you try any of the solutions listed here?
R cannot be resolved - Android error
Also, look for your R.java file. Are there any errors with it?
I had this problem too. I can't say a solution in general, but you can make a new workplace and copy the hardcode. In the future never click on clean or build, instead save or start eclipse again.
Go in your main.xml file, delete a char and rewrite it. That will generate the R file again.
On trying an Android beginner's tute (http://mobile.tutsplus.com/tutorials/android/android-sdk-development/) the "R.id cannot be resolved" error had me stumped too. In my case it was an android:onClick in /res/layout/main.xml. It seems onClick is not supported in AVD platform 1.5 API level 3.
A change to a new AVD with platform 1.6 API, level 6 removed the error - also started the project from scratch with the new api and level settings. For absolute Eclipse newbies (like myself) create a new AVD with:
Window -> Android SDK and AVD Manager -> New. Select platform, level number from "Target" drop down list.
Also try deleting the ~.android\debug.keystore (Happened to me, thought it was due to R.id issue). Real problem was debug.keystore was older than a year!
I ran into this problem when I tried to follow Lars Vogel's Android development tutorial...it turns out my problem is simply because I didn't save the layout file. Once I save the file, it works fine.
make sure you do not have any xml files with capitals in the name.
I had the same problem.
all the file names in res (and all its sub folders including layout) must be lower case only. This includes image files, xml files, etc (even if they aren't referenced anywhere within the project.)
if you posted full your main.xml file, then it's not right. You must write a namespace of xml:
xmlns:android="http://schemas.android.com/apk/res/android"
for example:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/label"
android:layout_width="78dip"
android:layout_height="65dip"
android:paddingTop="4dip"
android:textSize="12dip"
android:singleLine="true"
android:ellipsize="end"
android:textColor="#color/bright_text_dark_focused"
android:gravity="center_horizontal|center_vertical" />
Yeah another fix
I started the emulator. By running a helloandroid program, that did compile.
And got out of eclispe and got back in don't know which one fixed the problem..
Cleaning the project etc didn't fix it - can i have 2 hrs of my life back!
import com.TestApp.R;
isn't accepted once R is lost.
My Eclipse now auto creates a new "res" folder everytime I "clean". Yes, I have two folders named "res" in parallel directly under my project folder. The auto created one is empty. String values are still found. No other errors than "R cannot be resolved" are reported by Eclipse.
Eureka! I've managed to make my first android project import to Eclipse!
Earlier I always got "Unable to find system library" under the project's Properties - Java build path - Libraries tab and it was impossible to correct it once it occured. The consequence was that no import statements could be resolved by anything imported.
In this case, I changed the JDK compliance level from 1.6 to 1.5 BEFORE I imported (afterwards its too late and cannot be mended). It must be done from Window - Preferences - Java - Compiler (earlier I thought this option was available only by right-clicking on already imported project). Then right-click on each project and set Properties - Android to a suitable Target (with the errors above, eclipse ignores any selection here). Then, I could even change back to JDK compliance level 1.6.
So, in general, changing the JDK compliance level before importing, might help.
And when deleting a project ALWAYS check the "Delete project content on disk (cannot be undone)" checkbox in the "Are you sure" dialog. Otherwise it is impossible to re-import the project, o if you've imported it with the wrong JDK compliance level the first time, it is impossible to correct the mistake, other than to try in another workspace.
These are the experiences of a very frustrated Eclipse user.
Make sure there is not a hidden error in one of your .xml files.
Sometimes you can delete a statement in the strings.xml file that is important.
For example, in the Vogella example, I got the error:
Error: No resource found that matches the given name (at 'title' with value '#string/menu_settings').
I had deleted the line:
<string name="menu_settings">Settings</string>
Putting this back in or deleting res/menu/main.xml would solve the error.
I had the same problem but got fixed
i dont know exactly how this problem gonna fix
Just try, It might be helpful
add this code at the top of ur code
import com.MyFirstApp.activities.R;
here com.MyFirstApp.activties is my component name replace it with your component name