Android Service Compile failure

Using Delphi 11.2 to try to compile an existing Android project that has an Android service, I’m getting an error whilst linking the service. Creating a new Android Service project gives the same error:

[Exec Error] The command ""C:\Program Files\Eclipse Adoptium\jdk-11.0.15.10-hotspot\bin\javac" -g -Xlint:deprecation -source 11 -target 11 -encoding UTF-8 -d "C:\Users\Admin\Documents\RAD Studio\Projects\AndroidServiceTest3\JavaClasses\Project1" -classpath "C:\Users\Public\Documents\Embarcadero\Studio\22.0\CatalogRepository\AndroidSDK-2525-22.0.46141.0937\platforms\android-32\android.jar";"c:\program files (x86)\embarcadero\studio\22.0\lib\android\Debug\core-1.5.0-rc02.jar";"c:\program files (x86)\embarcadero\studio\22.0\lib\android\Debug\fmx.jar" --system "C:\Program Files\Eclipse Adoptium\jdk-11.0.15.10-hotspot" .\Android\Debug\Project1.java .\Android\Debug\Project1ProxyInterface.java" exited with code 1.

Since “Exit code 1” isn’t particularly useful, I ran it from the command line with the following result:

.\Android\Debug\Project1.java:11: error: package android.app does not exist
import android.app.Service;
                  ^
.\Android\Debug\Project1.java:12: error: package android.content does not exist
import android.content.Intent;
                      ^
.\Android\Debug\Project1.java:13: error: package android.content.res does not exist
import android.content.res.Configuration;
                          ^
.\Android\Debug\Project1.java:14: error: package android.os does not exist
import android.os.IBinder;
                 ^
.\Android\Debug\Project1.java:15: error: package android.os does not exist
import android.os.Binder;
                 ^
.\Android\Debug\Project1.java:19: error: cannot find symbol
public class Project1 extends Service {
                              ^
  symbol: class Service
.\Android\Debug\Project1.java:24: error: cannot find symbol
    public final IBinder mBinder = new LocalBinder();
                 ^
  symbol:   class IBinder
  location: class Project1
.\Android\Debug\Project1.java:51: error: cannot find symbol
    public int onStartCommand(Intent intent, int flags, int startId) {
                              ^
  symbol:   class Intent
  location: class Project1
.\Android\Debug\Project1.java:56: error: cannot find symbol
    public IBinder onBind(Intent intent) {
                          ^
  symbol:   class Intent
  location: class Project1
.\Android\Debug\Project1.java:56: error: cannot find symbol
    public IBinder onBind(Intent intent) {
           ^
  symbol:   class IBinder
  location: class Project1
.\Android\Debug\Project1.java:61: error: cannot find symbol
    public void onRebind(Intent intent) {
                         ^
  symbol:   class Intent
  location: class Project1
.\Android\Debug\Project1.java:66: error: cannot find symbol
    public boolean onUnbind(Intent intent) {
                            ^
  symbol:   class Intent
  location: class Project1
.\Android\Debug\Project1.java:71: error: cannot find symbol
    public void onConfigurationChanged(Configuration newConfig) {
                                       ^
  symbol:   class Configuration
  location: class Project1
.\Android\Debug\Project1.java:30: error: cannot find symbol
    public class LocalBinder extends Binder {
                                     ^
  symbol:   class Binder
  location: class Project1
.\Android\Debug\Project1.java:37: error: method does not override or implement a method from a supertype
    @Override
    ^
.\Android\Debug\Project1.java:40: error: cannot find symbol
        super.onCreate();
        ^
  symbol:   variable super
  location: class Project1
.\Android\Debug\Project1.java:44: error: method does not override or implement a method from a supertype
    @Override
    ^
.\Android\Debug\Project1.java:47: error: cannot find symbol
        super.onDestroy();
        ^
  symbol:   variable super
  location: class Project1
.\Android\Debug\Project1.java:50: error: method does not override or implement a method from a supertype
    @Override
    ^
.\Android\Debug\Project1.java:55: error: method does not override or implement a method from a supertype
    @Override
    ^
.\Android\Debug\Project1.java:60: error: method does not override or implement a method from a supertype
    @Override
    ^
.\Android\Debug\Project1.java:65: error: method does not override or implement a method from a supertype
    @Override
    ^
.\Android\Debug\Project1.java:70: error: method does not override or implement a method from a supertype
    @Override
    ^
.\Android\Debug\Project1.java:75: error: method does not override or implement a method from a supertype
    @Override
    ^
.\Android\Debug\Project1.java:80: error: method does not override or implement a method from a supertype
    @Override
    ^
25 errors

Google isn’t being very useful with providing any clues as to what’s going wrong.

Has anyone else run into this and have a solution or have any suggestions?

I’m assuming this means it was a project created in an earlier version? If so, one thing you could try is to remove the .java files in the service project folder and rebuild (Delphi recreates the .java files).

Hi David,

Thanks for the suggestion. I just tried it but no change.

You’re right that I’m trying to compile a project created in an earlier version, but since I’m getting the same error with a new project, I wasn’t too hopeful that doing this would fix it. Was certainly worth a try though.

Any other suggestions?

Can you double check your SDK settings in Delphi for Android? Make sure there’s no invalid entries

That was it - even though I had selected to install the Android SDK during the Delphi install, it wasn’t actually installed properly.

I found the following page:
https://dannywind.nl/delphi/android-sdk-for-delphi-11-2-alexandria/

The actual steps to resolve the problem were (at an elevated command prompt):

CD "C:\Users\Public\Documents\Embarcadero\Studio\22.0\CatalogRepository\AndroidSDK-2525-22.0.46141.0937\cmdline-tools\latest\bin"
sdkmanager "build-tools;32.0.0"
sdkmanager "platform-tools"
sdkmanager "platforms;android-32"

Strange that it allowed me to compile a regular Android program and only failed when it tried to link an Android service…