coturiv / setup-ionic

Set up your GitHub Actions workflow with Cordova/Ionic environment
MIT License
25 stars 14 forks source link

Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'. #16

Open omkarpattanaik opened 3 years ago

omkarpattanaik commented 3 years ago

Hello everyone,

I tried creating an android package using these steps but I am getting error.

 runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-java@v2
      with:
       distribution: 'adopt' # See 'Supported distributions' for available options
       java-version: '8'
    - name: Use coturiv/setup-ionic
      uses: ./
    - name: Run cordova project tests
      run: |
        ionic start testapp blank --cordova --type angular --no-link --no-git --no-interactive --confirm
        cd testapp
        ionic cordova platform add android@latest
        ionic cordova build android

Action Error Logs:


You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.1.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 13s
1 actionable task: 1 executed
Subproject Path: CordovaLib
Subproject Path: app
Downloading https://services.gradle.org/distributions/gradle-7.1.1-all.zip
..............10%...............20%...............30%...............40%..............50%...............60%...............70%...............80%..............90%...............100%
Observed package id 'ndk;21.4.7075529' in inconsistent location '/usr/local/lib/android/sdk/ndk-bundle' (Expected '/usr/local/lib/android/sdk/ndk/21.4.7075529')
Build-tool 31.0.0 is missing DX at /usr/local/lib/android/sdk/build-tools/31.0.0/dx
Observed package id 'ndk;21.4.7075529' in inconsistent location '/usr/local/lib/android/sdk/ndk-bundle' (Expected '/usr/local/lib/android/sdk/ndk/21.4.7075529')
File /home/runner/.android/repositories.cfg could not be loaded.

Observed package id 'ndk;21.4.7075529' in inconsistent location '/usr/local/lib/android/sdk/ndk-bundle' (Expected '/usr/local/lib/android/sdk/ndk/21.4.7075529')
FAILURE: Build failed with an exception.
Build-tool 31.0.0 is missing DX at /usr/local/lib/android/sdk/build-tools/31.0.0/dx

* What went wrong:
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.1.1/userguide/command_line_interface.html#sec:command_line_warnings
> Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 46s
Command failed with exit code 1: /home/runner/work/setup-ionic/setup-ionic/testapp/platforms/android/gradlew cdvBuildDebug -b /home/runner/work/setup-ionic/setup-ionic/testapp/platforms/android/build.gradle
[ERROR] An error occurred while running subprocess cordova.

        cordova build android exited with exit code 1.

        Re-running this command with the --verbose flag may provide more information.

From what I could understand from the logs is it could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.

So I also tried using this

- uses: actions/setup-java@v1
      with:
        java-version: 1.8

and

    - uses: actions/setup-java@v2
      with:
       distribution: 'adopt' # See 'Supported distributions' for available options
       java-version: '11'

but still I am facing the same error as above.

I also tried creating the same in my local machine and build was successful.

Can someone plz help ?

Thanks you in advance.

spacedog4 commented 3 years ago

Have you solved your problem? I'm having an similar error, but for me is Could not determine the dependencies of task ':app:compileReleaseJavaWithJavac'.

It seens to be related to build tools version as you can see on this line Build-tool 31.0.0 is missing DX at /usr/local/lib/android/sdk/build-tools/31.0.0/dx on my machine it runs at build tool version 29, and looking up in the internet it seens that this version has this problem

Is there a way to change this build tool version? I already have android-minSdkVersion on my config.xml

kevinboosten commented 3 years ago

`# Workaround to use older build-tools on Github virtual-environments

See: https://stackoverflow.com/a/68488745/2087831

  - run: $ANDROID_SDK_ROOT/tools/bin/sdkmanager --uninstall 'build-tools;31.0.0'
    name: Remove build-tools version 31 `

this works in the Fastlane + Github Actions setup that I’m using.

omkarpattanaik commented 3 years ago

Thank You @kevinboosten

Build-tool 31.0.0 installed in virtual environment was causing this error. Adding your solution worked for me

- name: Uninstall  build-tool version 31.0.0
  run: $ANDROID_SDK_ROOT/tools/bin/sdkmanager --uninstall 'build-tools;31.0.0'

Also i had to remove
ionic cordova platform add android@latest uses (cordova-android@10.0.1)
and add ionic cordova platform add android uses (cordova-android@9.0.0)

As cordova-android@10.0.1 was also causing app:compileReleaseJavaWithJavac FAILED

Task :app:compileReleaseJavaWithJavac FAILED ^ symbol: class Whitelist location: package org.apache.cordova /home/runner/work/setup-ionic/testapp /platforms/android/app/src/main/java/org/apache/cordova/whitelist/WhitelistPlugin.java:32: error: cannot find symbol private Whitelist allowedNavigations; ^ symbol: class Whitelist location: class org.apache.cordova.whitelist.WhitelistPlugin /home/runner/work/setup-ionic/testapp /platforms/android/app/src/main/java/org/apache/cordova/whitelist/WhitelistPlugin.java:33: error: cannot find symbol

Modified Working Workflow:

runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-java@v2
      with:
       distribution: 'adopt' # See 'Supported distributions' for available options
       java-version: '8'
    - name: Use coturiv/setup-ionic
      uses: coturiv/setup-ionic@v1.0.4

    - name: Uninstall 31.0.0 Build tool
      run: $ANDROID_SDK_ROOT/tools/bin/sdkmanager --uninstall 'build-tools;31.0.0'

    - name: Run cordova project tests
      run: |
        ionic start testapp blank --cordova --type angular --no-link --no-git --no-interactive --confirm
        cd testapp
        ionic cordova platform add android
        ionic cordova build android
bazini commented 2 years ago

If not, open your Android project part in Android Studio to install all necessary tools for Android development under Ionic. It solves my problems

zdhiu commented 2 years ago

I have the same issue when run 'ionic cordova build android'. The output is as: FAILURE: Build failed with an exception.

I re-install the Android SDK Build-tools 33.00rc4, does not solve this issue. I then open file ...\platforms\android\build.gradle, it's said "defaultBuildToolsVersion="29.0.2"". After I uninstalling current revision and installing revision 29.0.2 of Android SDK Build-tools, I passed the 'ionic cordova build android'!

etiennejoel commented 1 year ago

I have the same problem but i use flutter in Android studio

etiennejoel commented 1 year ago

How can i do?

subins829 commented 11 months ago

Any commnets on this issue ?

image

image

Will-at-FreedomDev commented 1 month ago

I setup Android via command line to avoid Android studio and I setup my ANDROID_HOME & ANDROID_SDK_ROOT paths incorrectly. I had them set to C:\Android\cmd-line-tools but it had to be changed to the parent directory of cmd-line-tools (C:\Android). That's all it was.