Solutions for common Android development problems with the Eclipse IDE- Tutorial

Table of Contents

1. Solving typical Android development problems
1.1. Clean Project
1.2. android.content.ActivityNotFoundException
1.3. Problems with Android Debug Bridge (adb)
1.4. LogCat
1.5. Java7
1.6. Eclipse reports file from R.java as missing
2. Solving not so typical Android development problems
2.1. java.lang.IllegalArgumentException: Binary XML file Duplicate id
2.2. Android editor not opened
2.3. Emulator does not start
2.4. Timeout during deployment
2.5. Installation failed due to insufficient storage
2.6. Debug Certificate expired
2.7. Error message for @Override
2.8. Missing Imports
3. About this website
4. Links and Literature
4.1. Android Resources
4.2. vogella GmbH training and consulting support

1. Solving typical Android development problems

Things are not always working as they should during your Android development. This section gives an overview over typical problems and how to solve them.

1.1. Clean Project

Several users report that they get the following errors:

  1. Project ... is missing required source folder: ‘gen‘
  2. The project could not be built until build path errors are resolved.
  3. Unable to open class file R.java.

To solve any of these errors, go to the project menu and select Project → Clean.

If you have library projects, make sure to clean them too.

1.2. android.content.ActivityNotFoundException

During start or during execution of your application, your application stops. In the LogCat view you see the message:android.content.ActivityNotFoundException : Unable to find explicit activity class; have you declared this activity in your AndroidManifest.xml?

Check in this case if you declared your activity in the AndroidManifest.xml file.

1.3. Problems with Android Debug Bridge (adb)

The communication with the emulator or your Android device might have problems. This communication is handled by the Android Debug Bridge (adb).

Eclipse allows you to reset the adb in case this causes problems. Select therefore the DDMS perspective via Window → Open Perspective → Other... → DDMS

To restart the adb, select the "Reset adb" in the Device View.

If this does not work, locate the adb and type the commands adb kill-server followed by an adb start-server.

1.4. LogCat

The LogCat view shows you the log messages of your Android device and helps you to analyze problems. For example Java exceptions in your program would be shown here. To open this view, select Window → Show View → Other... → Android →LogCat.

1.5. Java7

If Android complains that you cannot use Java7 select your right-click on your project and select the Java Compiler entry. Ensure that Java 1.5 or Java 1.6 is used. You may have to select the Enable project specific settings checkbox.

1.6. Eclipse reports file from R.java as missing

Sometimes Eclipse complains that a file, e.g. R.layout.main cannot be found. Check in your source code that you did not importandroid.R. An android.R import will prevent Eclipse from finding your R file.

2. Solving not so typical Android development problems

This sections lists problem which happen sometimes but are not that frequently as the problems from the previous section.

2.1. java.lang.IllegalArgumentException: Binary XML file Duplicate id

Caused by an attempt to load the same fragment twice. The second time it is added to the FragmentManager this exception is thrown.

Solution: ensure that each fragment is only added once to an activity.

2.2. Android editor not opened

Android provides nice editors to edit Android resource files, unfortunately these editor are not always automatically used due to bugs in the ADT. If that happens, you can open this editor manually. Right-click on your menu file and select Open with → Android Menu Editor.

2.3. Emulator does not start

If your emulator does not start, make sure that the android-sdk version is in a path without any spaces in the path name.

2.4. Timeout during deployment

If you face timeout issues during deployment you can increase the default timeout in the Eclipse preferences. Select Window →Preferences → Android → DDMS and increase the ADB connection timeout (in ms) value.

2.5. Installation failed due to insufficient storage

Sometimes the emulator will refuse to install an application with the error message: INSTALL_FAILED_INSUFFICIENT_STORAGE.

An Android virtual device provides by default only 64M for the storaging Android applications. You can clean your installed application by restarting the emulator and selecting the Wipe user data flag.

Alternatively you can set the data partition size. If you press edit on the AVD, you can set the Ideal size of data partitionproperty via the New button.

2.6. Debug Certificate expired

If you get the error message Debug Certificate expired switch to the folder which contains the Android AVD, e.g. .android under Linux and delete the debug.keystore file. This file is only valid for a year and if not present, Eclipse will regenerate the password.

2.7. Error message for @Override

The @Override annotation was introduced in Java 1.6. If you receive an error message for @Override, change the Java compiler level to Java 1.6. To do this, right-click on the project, select Properties → Java Compiler → Compiler compliance level and select1.6 in the drop-down box.

2.8. Missing Imports

Java requires that classes which are not part of the standard Java Language are either fully qualified or declared via imports.

If you see an error message with the XX cannot be resolved to a variable text, right-click in your Editor and select Source →Organize Imports to important required packages.

时间: 2024-11-07 22:11:27

Solutions for common Android development problems with the Eclipse IDE- Tutorial的相关文章

Eclipse 安装 ADT 失败的两种解决办法 [Android Development Tooling]

原因 最近想在新装的 Win7 里搭建一下 Android 的开发环境,虽然现在有 Android Studio 了,不过还是习惯 Eclipse 一点.众所周知的原因,Eclipse 直接安装 ADT(Android Develepment Tooling) 插件是不行的,这里给出两种解决办法,我们的前提是要先安装 Google 的 翻[email protected]!墙工具 GoAgent . 一.使用 Proxy 由于直接访问是不行的,所以你可以使用 VPN 或者 GoAgent 做为

Learn Java for Android Development Second Edition 笔记(六)- Interface

Interface Java里用interface关键字,引入一种没有具体实现的类型. Declaring Interfaces interface一般以大写字母开头,able单词结束,如下例子: interface Drawable { int RED = 1; // For simplicity, integer constants are used. These constants are int GREEN = 2; // not that descriptive, as you wil

Android development tools line_endings hacking

/******************************************************************** * Android development tools line_endings hacking * 说明: * 本文主要是对android源代码中的line_endings开发工具进行了解读, * 目的是为了知道传说中的额dos,unix文件之间转换的工作机制. * * 2016-5-3 深圳 南山平山村 曾剑锋 *********************

Android开发 Unity3D基础 Android Development

开发环境 Window 7 Unity3D 3.3.0 MB525 defy Android 2.1-update1 本次学习: 1.认识Unity 2.Unity3D环境搭建与Android软件生成 3.Unity3D基本使用方法 1.认识Unity3D Unity3D是一个让开发者能够在多平台制作同一款游戏的游戏开发工具,有专业的图像处理和游戏引擎,能做出各式各样的游戏. 羽化以前认为Android游戏开发只能在Eclipse里面死活敲代码,也许是自己阅历不够,不知道游戏引擎能给游戏开发带来

Android Development Environment ADT-BUNDLE android-studio SDK ADT Download

Android ALL VERSIONS DOWNLOAD (64GB ZIPPED) LINK : http://pan.baidu.com/s/1c2v4mXE password: h2mc -- SIZES: -- schema : Android Studio : http://tools.android-studio.org/; Android 开发环境介绍 : 目前 Android 有两种开发环境, 一种是传统的 Eclipse + ADT, 一种就是目前最新并且得到 Google

Do's and Don'ts for Android development

Do's and Don'ts for Android development, by Futurice developers Use Gradle and its recommended project structure Put passwords and sensitive data in gradle.properties Don't write your own HTTP client, use Volley or OkHttp libraries Use the Jackson li

为Eclipse安装ADT(Android Development Tools)

在搭建Android开发环境的时候,我们需要为Eclipse安装ADT(Android Development Tools)插件,这个插件可以为用户提供一个强大的Android集成开发环境.通过给Eclipse安装ADT插件,用户才能够完成快速新建Android项目.创建界面.调试程序.导出apk等一系列的开发任务. 一般论坛或博客上关于Android开发环境搭建的帖子在讲Eclipse安装ADT插件的时候,都是通过在线安装的方式.不过这种方法有几大缺陷,一是由于ADT插件是从http://dl

ADT-bundle(Android Development Tools)环境配置

Android开发环境有两套比较主流的:ADT-bundle和Android Studio,前者是Eclipse插件的形式进行开发,后者是Android的官方IDE. ADT环境的配置与调试:(1)安装JDK,配置环境变量 a.下载地址:http://www.oracle.com/technetwork/java/javase/downloads/index.html b.添加如下环境变量(安装在D:\Android目录): JAVA_HOME D:\Android\Java\jdk1.8.0_

Android JNI programming demo with Eclipse

用Eclipse 建立 JNI 的專案, 示範如何在 JAVA 調用 cpp 的函數. 我們將建立一個名稱為 jnidemo的專案, 在主Activity 將調用一個名為libHello.so 的 cpp 函數庫的 getVersion() 的函數, 將其返回字串寫在主Activity 的TextView 上. 首先用Eclipse建立一個新的 Android Activity 專案.  其他選項都用預設值就可以. 1. 稍微修改主活動配置 layout/activity_main.xml,