Some Common Android Development Errors and Solutions

Some Common Android Development Errors and Solutions

You might face some issues/problems during your android development. Here we will discuss Some Common Android Development Errors and Solutions. Sometimes your output does not come as you expected. You might face some build errors, some setup errors, configuration errors, Eclipse IDE errors, Android SDK errors, Security errors, Permission errors etc. These kinds of issues are very irritating. In my prior experience, I have faced a lot of issues & solve these as well. So I would like to share some common android issues/errors with solutions with you.

1. Clean Project

Errors:

Sometime you might face the following errors.

1. Error: Unable to open class file R.java.

2. Error: The project could not be built until build path errors are resolved.

3. Error: Project … is missing required source folder: ‘gen’.

Solution:

For the above errors, we have one solution.

  1. Go to the project menu and select ProjectClean.
  2. If you are using libraries projects, then make sure to clean them too.

 

2. Error: Problems with Android Debug Bridge (adb)

Errors:

Sometimes you might face communication error with the emulator or device.

Solution:

As Android Debug Bridge (adb) handles the communication. We need to restart/reset the ADB server.

Open command prompt (cmd). Type below commands in your .command prompt.

adb kill-server

adb start-server

adb-start-stop-command

Also you can do it from your eclipse IDE.

  1.  To reset ADB, Select therefore the DDMS perspective via Window → Open Perspective → Other → DDMS
  2. To restart the adb, select the “Reset adb” in the Device View.

reset-adb-in-android

reset-adb-in-android-reset-adb-in-android--

 

 

3. Error: android.content.ActivityNotFoundException

Errors:

Sometimes you might face the error:  android.content.ActivityNotFoundException

Solution:

Your application might stops during running or debugging . You can see the message in your LogCat View: android.content.ActivityNotFoundException : Unable to find explicit activity class; have you declared this activity in your AndroidManifest.xml?

In this case you need to add your activity in the AndroidManifest.xml file.

4. Error: R.layout.main cannot be found/missing

Errors:

Sometimes you might face the error:  R.layout.main cannot be found.

Solution:

R refers to the resource file. In your source code check if you did not import android.R. An android.R import will prevent Eclipse from finding your R file. Also you can check the spelling of the xml layout file name (Here in ‘R.layout.main’, main is the layout file name) , make sure that the xml file name should not contain any space.

 5.  Error: Emulator does not start

Errors:

Sometimes you might face the error that, you emulator does not start when you run an android application.

Solution:

Make sure that the android-sdk version is in a path without any spaces in the path name.

Example:        D:\my_android\android-sdk-windows

6. Error: Timeout during deployment of android application on device/emulator

Errors:

Sometimes you might timeout issues during deployment of any android application.

Solution:

You can increase the default timeout in the Eclipse. Select WindowPreferencesAndroidDDMS and increase the ADB connection timeout (in ms) value.

 7.  @Override Error in android java source code

 Errors:

Sometime you might face error in you android code regarding  @Override.

Solution:

The @Override is an annotation in Java version 1.6. If you receive an error message for @Override, change the Java compiler level to Java 1.6.

  1. To do this, right-click on the project, select Properties → Java Compiler → Compiler compliance level and select 1.6 in the drop-down box.

You can also delete this annotation from your code. Try, it might work for you.

8. Error: Missing Imports from android java source code

 Errors:

Sometime you might face errors regarding package import errors in your android code.

Solution:

Your android project requires some used classes, which are not part of the standard Java Language.  You can use them, either fully qualified or declared via imports.

If you see an error message like something cannot be resolved to a variable text, then right-click in your Editor and select Source → Organize Imports to important required packages. Also you can move your mouse cursor on that error or click on it, and then you can see a suggestion popup, form that popup click on required package. The package will automatically add into your source code.

import-error-in-java-android

 

  9.  Debug Certificate expired

Errors:

Sometime you might face errors regarding Error: debug certificate expired, while building your android application.

Solution:

You need to delete the old debug.keystore file from the folder, which contains Android AVD. This file is only valid for a year. If the file is not present then Eclipse will regenerate the file for you automatically.

How to know the folder path from which you need to delete the file?

  1. In the Eclipse editor, Goto: Window-Preferences.
  2. Then Goto: Android-Build. Then Find the field “Default build keystore”. Here you will find the path. Goto that path and delete debug.keystore file from that location. Refer below image.

error-debug-certificate-expired-in-eclipse-android

 

 10. Installation failed due to insufficient storage

Error:

Sometime you might face an error: “INSTALL_FAILED_INSUFFICIENT_STORAGE”, when install an application on emulator.

Solution:

By default Android virtual device(AVD) provides only 64M for the memory space for Android applications. You can clean your installed application by re-starting the emulator and selecting the Wipe user data “flag.

Also you can set the data partition size. If you press edit on the AVD, you can set the Ideal size of data partition property via the New button. Follow below image for details.

installation-failed-due-to-insufficient-storage-in-android-emulator

installation-failed-due-to-insufficient-storage-in-android-emulator-1

 11. Android Device not Detected in Eclipse

Error:

Sometime you might face an error: Your android device is not detected in Eclipse. There might be diffrent reason.

Solution:

  1. First Check your Date Cable connection, Some data cables might be damage or not supported for your device.
  2. On your device Check the settings. Your device debugging should be ON. Goto Settings ->Applications->Development. Then Check USB Debugging check box. Note: The path might be different for your device, but it must be in settings.
  3. Check the compatible driver is installed for your device on your PC.

 

 12. Android SDK Update Error: A Folder Failed to Rename or Moved

Error:

Sometime you might face an error: When you update your Android SDK, it shows an error or warning like: A Folder Failed to Rename or Moved.

android-sdk-update-error-a-folder-failed-to-be-rename

Solution:

  1. First Check disable your antivirus temporarily. Then try again. when running abdroid.bat file, make sure to run it as administrator(if required).
  2. If the above trick does not work, then after step 1, copy the tools folder in the same location (in my case ~\android-sdk-windows\..), lets say temp_copy. Run android.bat from that folder with as administrator(if required).
  3. If the above trick also not working, then delete the temp folder from (~\android-sdk-windows\) directory. then try.

 I will post more android development errors and solutions in future, so please keep visiting this site. If you are facing any specific errors, then kindly send me the details, i will respond your queries asap. Good Luck.

13. project has no default.properties file edit the project properties to set one

Error: Sometimes  you download any android sample application and when compile and run it in Eclipse, you can see error project has no default.properties file edit the project properties to set one.

Solution:

That means the default project file (default.properties) is missing. Add this file from any other existing project, then clean and build the project.

Note: If the project already contains a file default.properties, then you can open that file and edit+save it (add a space, save, remove that space, save).

Or: You can use create new project from existing sources option in Eclipse with the location pointing to downloaded project directory.

14. Can’t find lib file in the location …

Error: Sometimes  when you download some example and try to build and run it. You may face the above error like library file is missing in the location .

Solution: Goto your project location, then add the library in the required location. If the lib file is not required, then go to your project root folder, then edit .classpath file and remove the line that contains the location for the required library.

16. Error: Failure [INSTALL_FAILED_OLDER_SDK]

Error: You might get this error while installing any Android apk in your device.

Solution:

If you are getting the above error, that means the Andrid apk is build with the minimun sdk-version above than version present in your device. That means if your Android device version is 2.3.4 (Gingerbread API level 10) and you Android app is build on min-sdk version 11 (Android sdk version 3.0, API level:11 or above), then you can’t install it on 2.3.4 (Gingerbread API lable 10).

So the solution is: You need to rebuild the application with minimum version sdk, which supports your device. To do the job, you need to go into your Android Manifest file, then search the string  like android:minSdkVersion“, then change the value accordingly. Then rebuild the application and install.

Before : <uses-sdkandroid:minSdkVersion=“11”/>

After: <uses-sdkandroid:minSdkVersion=“1o”/>

List of API lable for all Android SDK- versions:

Version API Level
4.1.x Jelly Bean 16
4.0.x Ice Cream Sandwich        14-15
2.3.x Gingerbread        9-11
2.2 Froyo 8
2.0, 2.1 Éclair 7
1.6 Donut 4
1.5 Cupcake 3

 

15. Enable Developer Options/USB debugging in Android Jelly Bean 4.2.2 (Example Samsung S4)

Error: Can’t find developer options in  Android Jelly Bean 4.2.2 Devices.

Solution:

Please refer to the below link.

http://techblogon.com/enable-developer-options-usb-debugging-on-android-4-2-2-devices/

15. Debug certificate expired in Eclipse and it’s solution.

Error: Debug certificate expired on 15/03/2015. You might encounter this error when developing Android application using Eclipse.

Solution: This kind of error comes due to the android certificate has been expired in your Android SDK. So we just need to delete this certificate (debug.keystore) and Eclipse will generate a new certificate for you. Then you have to clean and build your application again after delete the certificate.

Now where you will find the certificate? Location is as below.

Linux and Mac OS X:  ~/.android/debug.keystore ;

Windows OS: Open Run (Windows Key + R). Then Type : %USERPROFILE%. Under this folder you will find another folder called .androidon. Then just search for the file debug.keystore and delete it.

16. Failed to fetch URL https://dl-ssl.google.com/android/repository/addons_list-2.xml.  Reason: Connection to https://dl-ssl.google.com refused.

Error: Failed to update Android SDK.

Solution: This is a common issue when you update your android SDK. There might be for different reasons. However try the below solution it might works for your. I had faced the same issue and the below solution worked for me.

1. Goto your Android SDK path, where you installed your Android SDK. Then search/locate the ”

Once your SDK Manager opened, Then close the error page (if it appeared, else nothing to do). Then go to the Tools->Options

android sdk not updated

Then once click on options, you can see below screen.

android sdk not updated set proxy

Then set “HTTP Proxy Server” as google.com and HTTP Port as 80. You can refer the above image. Then close the SDK manager and re-open it, It will now work and you can update your SDK.

 

Post By SmrutiRanjan (57 Posts)

Working @ Samsung as a Project Lead for Android Smartphones. I have been blogging since 2008. Previously I was writing articles for other bloggers, but finally I have started my own blog-"Techblogon".I am also an active contributor for the blog-"Gadgets n Gizmos World". Job is my necessity, but blogging is my passion.

Website: → Techblogon

Connect

5 Responses to Some Common Android Development Errors and Solutions

  1. How Android says:

    Excellent ! it is very useful post.

  2. Jones sabo it expanding overseas popular online application is super quick growing into all the rage says:

    You have remarked very interesting points! ps decent website.

  3. Joe says:

    what’s about this?
    error:Error reading default devices
    I couldn’t start avd manager!

  4. kalis says:

    hi,
    i have run time error in homeactivity called java.lang.nullpointerexception…what can i do next….

Leave a Reply

Your email address will not be published. Required fields are marked *


× eight = 8

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">