2
votes

I decided to try programming for Android. I started their tutorial, but could not run the application which the first project automatically creates. I suspect that I have set up my computer wrong, but don't know where to search for the error.

The tutorial says to go to the directory of the newly created project and run ant debug. This throws an error for me: java.lang.NoClassDefFoundError: com.android.sdklib.internal.build.DebugKeyProvider. I suspect a bad installation of the SDK, but have no idea what is wrong or how to repair it.

My computer runs openSUSE 12.1 64 bit. I have the Oracte JDK version 1.7.0_04 installed, and the Android SDK including Tools and the platforms Android 4.0 and 4.0.3. After the installation, I added the android tools folder to my path environment and added a udev rule for my phone, but have done no further customization. Adb sees my phone and I can capture a screenshot with ddms. I don't use Eclipse.

Did I miss some part of the setup? How do I troubleshoot this problem?

Update I found a mailing list discussion about somebody with the same problem. He solved it by updating a symlink called "keytool" in their /usr/bin, to point at the correct file. I didn't have such a link, so I created it. The problem persists. Somebody who answered the thread suggested that a file called "jarutil.jar" may be missing from the SDK. I don't have such a file in my SDK, even after a reinstall from scratch. As the discussion is over an year old, I don't even know if such a file should be present in the current version.

Here is the full output from the ant debug command:

rumtscho@bradbury:~/dev/learn-android/MyFirstApp> ant debug Buildfile: /home/rumtscho/dev/learn-android/MyFirstApp/build.xml

-set-mode-check:

-set-debug-files:

-set-debug-mode:

-debug-obfuscation-check:

-setup: [echo] Creating output directories if needed... [echo] Gathering info for MyFirstApp... [setup] Android SDK Tools Revision 19 [setup] Project Target: Android 4.0.3 [setup] API level: 15 [setup] [setup] ------------------ [setup] Resolving library dependencies: [setup] No library dependencies. [setup] [setup] ------------------ [setup] API<=15: Adding annotations.jar to the classpath. [setup] [setup] ------------------ [setup] WARNING: No minSdkVersion value set. Application will install on all Android versions.

-build-setup:

-pre-build:

-code-gen: [echo] ---------- [echo] Handling aidl files... [aidl] No AIDL files to compile. [echo] ---------- [echo] Handling RenderScript files... [renderscript] No RenderScript files to compile. [echo] ---------- [echo] Handling Resources... [aapt] No changed resources. R.java and Manifest.java untouched. [echo] ---------- [echo] Handling BuildConfig class... [buildconfig] Generating BuildConfig class.

-pre-compile:

-compile: [javac] Compiling 1 source file to /home/rumtscho/dev/learn-android/MyFirstApp/bin/classes

-post-compile:

-obfuscate:

-dex: [dex] Found modified input file [dex] Converting compiled files and external libraries into /home/rumtscho/dev/learn-android/MyFirstApp/bin/classes.dex...

-crunch: [crunch] Crunching PNG Files in source dir: /home/rumtscho/dev/learn-android/MyFirstApp/res [crunch] To destination dir: /home/rumtscho/dev/learn-android/MyFirstApp/bin/res
[crunch] Crunched 0 PNG files to update cache

-package-resources: [aapt] Creating full resource package...

-package: [apkbuilder] Current build type is different than previous build: forced apkbuilder run. [apkbuilder] Creating MyFirstApp-debug-unaligned.apk and signing it with a debug key...

BUILD FAILED /home/rumtscho/android-sdk-linux/tools/ant/build.xml:886: The following error occurred while executing this line: /home/rumtscho/android-sdk-linux/tools/ant/build.xml:897: The following error occurred while executing this line: /home/rumtscho/android-sdk-linux/tools/ant/build.xml:307: java.lang.NoClassDefFoundError: com.android.sdklib.internal.build.DebugKeyProvider at java.lang.Class.initializeClass(libgcj.so.12) at com.android.sdklib.build.ApkBuilder.getDebugKeystore(ApkBuilder.java:919) at com.android.ant.ApkBuilderTask.execute(ApkBuilderTask.java:334)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at java.lang.reflect.Method.invoke(libgcj.so.12) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at java.lang.reflect.Method.invoke(libgcj.so.12) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:398) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at java.lang.reflect.Method.invoke(libgcj.so.12) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
at com.android.ant.IfElseTask.execute(IfElseTask.java:124) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at java.lang.reflect.Method.invoke(libgcj.so.12) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
at com.android.ant.IfElseTask.execute(IfElseTask.java:124) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at java.lang.reflect.Method.invoke(libgcj.so.12) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at java.lang.reflect.Method.invoke(libgcj.so.12) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:398) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at java.lang.reflect.Method.invoke(libgcj.so.12) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.Target.execute(Target.java:390) at org.apache.tools.ant.Target.performTasks(Target.java:411) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.Main.runBuild(Main.java:809) at org.apache.tools.ant.Main.startAnt(Main.java:217) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109) Caused by: java.lang.ClassNotFoundException: java.security.KeyStore$ProtectionParameter at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1361) at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1311) at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1064) at java.lang.ClassLoader.loadClass(libgcj.so.12) at java.lang.Class.initializeClass(libgcj.so.12) ...48 more

Total time: 3 seconds

1
Is there a reason you're not using eclipse? I would imagine this has to do with the SDK not being on your classpath. Also, is there a reason you're doing this under java 1.7? I'm just curious since I've never heard of it working (or not working).Falmarri
@Falmarri The reason is that I want to learn it without Eclipse - the last time I had to do with a project written in Eclipse (not for Android), we ran into a dll-hell-like situation and nobody knew what was wrong. Also, I did put the SDK (or at least the tools and platform-tools folders, as suggested in the Android tutorial) into my PATH. And what is so strange about java 1.7? It is just the current version of the JDK, so that's what I installed. I use the Oracle java because I have some programms which don't run with the open one.rumtscho
@rumtscho : I'd seriously reconsider using eclipse. The way it works with the ADT, Android SDK and AVD Manager makes it worth it. Not the best IDE I've ever used but it makes my life much easier. Just my opinion, your choice.Squonk
I might start using eclipse some time in the future. I just want to learn the details first without letting it shield me from them. When I am comfortable that I have the knowledge of creating an app without relying on eclipse, I may start using it for convenience.rumtscho

1 Answers

1
votes

The Oracle JDK rpm doesn't configure Java the SuSE way. In particular, your JAVA_HOME may not be set correctly.

Try JAVA_HOME=/usr/java/default ant debug.

Also make sure that readlink -f `which java` points to your Oracle JDK

It appears you can set JAVA_HOME permanently in /etc/java/java.conf

The Apache Ant manual recommends to set the environmental variables ant needs by using:

export ANT_HOME=/usr/local/ant
export JAVA_HOME=/usr/local/jdk-1.5.0.05
export PATH=${PATH}:${ANT_HOME}/bin 

Where the jdk number should point to the JDK number installed on the computer. This sets the variable permanently too.