Android:Troubleshooting
lastmod 2018-08-17created 2016-12-142 edits
Reports symptoms related to errors that appear when compiling Android, and summarizes solutions.
Category
What to do when ADB is not recognized while debugging on an Android phone, or the device itself is not recognized (connected) as a device
- http://i5on9i.blogspot.kr/2012/07/blog-post_27.html
- http://purepleya.blogspot.kr/2011/07/android-ddms-devices.html
Even with USB connected, the device may charge but the 'Connected as a media device' notification (Notification) does not appear, and the PC does not detect it as a 'removable media device'. Rebooting makes it detected normally again, but the same symptom often recurs, or the device is no longer recognized at all. In this case, reinstall the driver. The default ANDROID driver path is as follows.
If debugging does not work, restarting ADB may fix it.
What to do when the INSTALL_FAILED_INSUFFICIENT_STORAGE error occurs
If porting to Android fails with a console (not Logcat) message like the one below, remove the data previously installed on Android and then port again.
Installation error: INSTALL_FAILED_INSUFFICIENT_STORAGE
Please check logcat output for more details.
Launch canceled!
- This error is a porting error related to LogCat. On the emulator, the fix is to increase the partition size, e.g.
-partition-size 256. - On a device (Device), the fix is to clear the log messages and then disconnect the device from USB several times.
- Clear LogCat. Then disconnect the device, reconnect it, and clear LogCat again. (Sometimes it is not cleared properly on the first try.)
- If this still does not work, for the Android NexusS, add the
android:installLocation="preferExternal"attribute to the Manifest file.
Unable to build: the file dx.jar was not loaded from the SDK folder
- http://manywaypark.tistory.com/205
- http://stackoverflow.com/questions/5228453/android-adt-error-dx-jar-was-not-loaded-from-the-sdk-folder
After upgrading various things in the Android SDK Manager, building the project in eclipse failed to build the package with the message below (of course, it worked fine before).
It says dx.jar is missing... You can fix it by finding dx.jar and copying it to where it should be (platform-tools\lib\), but the method in the second reference link above is easier and cleaner. Close eclipse, then uninstall the following item in the Android SDK Manager and install it again.
Java version 1.5 or 1.6
Currently (2012-09-28), due to various policies, Android uses the version 1.5 Java compiler. Java up to 1.6 has an interface similar to 1.5, but it changed significantly in 1.7, so compiling with 1.7 produces the error message below.
Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools > Fix Project Properties.
If you use Eclipse, the fix is to change the Java version as follows.
Project > Properties > Java Compiler
Compiler compliance level: 1.6 변경.
만약 클릭할 수 없는 상태일 경우 상단의 'Enable project specific settings'를 클릭하면 된다.
Call to OpenGL ES API with no current context (logged once per thread)
- http://respectthecode.tumblr.com/post/27122026167/android-phonegap-call-to-opengl-es-api-with-no-current
- http://stackoverflow.com/questions/9722328/call-to-opengl-es-api-with-no-current-context-logged-once-per-thread
Android Phonegap call to OpenGL ES API with no current context (logged once per thread) Error When using Phonegap on Android I was getting this OpenGL error somewhat randomly. It seemed to be related to CSS animation. Turns out the problem was that hardware acceleration is turned off by default. (If hardware acceleration support is not enabled, the message below is printed.)
Add the following to AndroidManifest.xml.
WARNING
Importantly, after this setting, it may not work properly and the screen may become corrupted. In that case, try the following.
Android Native NDK OpenGL ES: unimplemented API
Reference: http://stackoverflow.com/questions/9468175/android-native-ndk-opengl-es-unimplemented-api When using OpenGL ES-related libraries, the error message below may be printed.
Initialize the EGL context as follows.
EGLint aEGLAttributes[] =
{
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, // <--- OpenGL ES 2.0
...
EGL_NONE
};
...
eglChooseConfig(m_EGLDisplay, aEGLAttributes, aEGLConfigs, 1,
&cEGLConfigs)
...
Or, if you use the NDK, check that the #include <GLES2/gl2.h> header file was added correctly.
About LogCat history disappearing in Eclipse
Enter the following on the command line to view logs without worrying about buffer size.
Explanation of Looper-related solutions
Android Kernel System debugging
- http://gogorchg.tistory.com/entry/Kernel-system-%EB%94%94%EB%B2%84%EA%B9%85
- http://gogorchg.tistory.com/entry/Kernel-System-call-%EC%B6%94%EA%B0%80-%EB%B0%A9%EB%B2%95-ICS
Debugging at the kernel level uses a function called printk. To view these logs, do the following.
- Open a Prompt window and run
adb shell->dmesgto show all logs from boot until now. -
adb shell->dmesg -cshows everything so far and clears the log buffer ->dmesg -
adb shell->cat /proc/kmsgshows logs in real time.
If it is not on the Path, look in sdk/platform-tools.
Fixing runtime errors when using JAR Libraries after the ADT 17 update
- http://www.androidpub.com/2117249
- http://www.androidpub.com/index.php?mid=android_dev_info&document_srl=2049579
- http://android.foxykeep.com/dev/how-to-fix-the-classdefnotfounderror-with-adt-17
The following information may be printed as a LogCat error message.
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo
Caused by: java.lang.ClassNotFoundException:
...
The solution is as follows.
- Right-click the project and go to
Properties > Java Build Path > Order and Export Tab - Check the CheckBox of every item shown in the Order and Export tab and close the window with OK.
- Run Project Clean, then build again.
Dex Loader Unable to execute Multiple dex files define
- http://valley.egloos.com/viewer/?url=http://always19.egloos.com/2911050
- http://blog.naver.com/thanksyo/140184795232
- http://blog.naver.com/sambak99/90173652457
- http://stackoverflow.com/questions/7688828/dex-loader-unable-to-execute-multiple-dex-files-define
This error can appear while trying to fix a java.lang.ClassNotFoundException-related error. Check Java build path > Order and Export > Support library for any libraries that were checked unnecessarily.
Unable to launch cygpath in android
You may see an error message like the following.
[2013-03-17 16:14:15 - Unable to launch cygpath. Is Cygwin on the path?] java.io.IOException: Cannot run program "cygpath": CreateProcess error=2, The system cannot find the file specified
This error message occurs when, after installing Cygwin, the $CYGWIN_HOME/bin/cygpath.exe file cannot be found on the PATH. Set the PATH environment variable correctly.
When a ClassNotFoundException occurs or the Class Definition cannot be found when referencing a JAR library
- http://blog.naver.com/hisukdory/50155565885
- http://stackoverflow.com/questions/3642928/adding-a-library-jar-to-an-eclipse-android-project
When developing an Android app with the ADT plugin in Eclipse and you want to reference an external library, the most common method is probably Right-click project > Properties > Java Build Path > Libraries tab > Add External JARs > Select jar file. However, according to the post above, Android's Dalvik JVM cannot directly reference classes compiled by Java. For this reason, if you reference an external library in the way above, Android throws No Class Definition Found or ClassNotFoundException. To fix this, you need to convert it into a JAR file that Dalvik can reference, and the method is simple. Right-click the libs folder created in the Android project and choose Import, then choose General > File System, which lets you browse for and set From directory. Select the parent directory containing the jar files you want to convert and click OK, and the jar files are listed in the right column. Select all of these jar files and click Finish, and Dalvik-converted JAR files are created inside the libs folder.
UnsupportedOperationException GLES20Canvas.clipPath
- https://plus.google.com/115556134544294206693/posts/UMDdYQVgXbA
- http://stackoverflow.com/questions/7401319/use-hardwareacceleration-flag-with-canvas-clippath
Reported to occur on the Galaxy Nexus running ICS.
java.lang.UnsupportedOperationException
at android.view.GLES20Canvas.clipPath(GLES20Canvas.java:387)
The solution is as follows.
private void safelyCropPath(Canvas c, Path p) {
try {
c.clipPath(p);
} catch (UnsupportedOperationException e) {
if (Build.VERSION.SDK_INT >= 11) {
try {
final int LAYER_TYPE_SOFTWARE = getClass().getField("LAYER_TYPE_SOFTWARE").getInt(this);
Method layerTypeM = getClass().getMethod("setLayerType", Integer.TYPE, Paint.class);
layerTypeM.invoke(this, LAYER_TYPE_SOFTWARE, null);
c.clipPath(p);
} catch (Throwable e1) {
// 이래도 실패하면..@_@
}
}
}
}
Error generating final archive: Debug certificate expired on
This error message sometimes appears while building an Android application in Eclipse.
This problem occurs because the Debug certificate has expired; a Debug certificate expires 365 days after it is created. So you just need to renew the expired Debug certificate. The method is simple. Delete the debug.keystore file, then simply build the Android application again. For the location of the debug.keystore file, see the Default debug keystore item in Window > Preferences > Android > Build.
Activity xxx has leaked window xxxxxxx that was originally added here
Appears when the activity finishes while a dialog it created still exists, causing a memory leak. You must call the dialog's dismiss() before the activity finishes.
Favorite site
- Android ANR(Application Not Responding) 2
- Avoiding Android ListView ANR 3
- Android memory leak (Memory leak)
- Developer android: troubleshooting FAQ