Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency issues related to Android API 34 #1912

Open
pai-djkim opened this issue Sep 13, 2024 · 0 comments
Open

Dependency issues related to Android API 34 #1912

pai-djkim opened this issue Sep 13, 2024 · 0 comments

Comments

@pai-djkim
Copy link

Issue

I need to upgrade my Android miniapp compileSDKVersion and targetSDKversion to 34. While i was able to upgrade the version in electrode native container, deploying it causes subsequent dependencies issues related to version mismatch.

I use the github workflow file below to deploy the electrode native container.

name: '빌드 배포'
on:
  push:
    branches:
      - master

concurrency:
  group: 5b3a4d21-2774-451a-a7b2-8a446af32863-${{ github.ref }}
  cancel-in-progress: true

jobs:
  main:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Set up JDK 17
        uses: actions/setup-java@v3
        with:
          java-version: '17'
          distribution: 'temurin' # OpenJDK 배포 (temurin, zulu, adopt 등 선택 가능)
    
      - name: Verify Java version
        run: java -version

      - name: 환경 설정
        run: |
          echo "apply from: 'publish.gradle'" > temp.gradle
          cat lib/build.gradle >> temp.gradle
          mv temp.gradle lib/build.gradle
          mv .scripts/publish.gradle lib/publish.gradle

      - name: 빌드
        run: ./gradlew --refresh-dependencies

      - name: 배포 테스트
        run: ./gradlew assembleRelease

      - name: 배포
        run: ./gradlew publish
        env:
          USERNAME: ${{ github.actor }}
          TOKEN: ${{ secrets.PAI_GITHUB_PAT}}

      - name: 알림
        id: slack
        uses: slackapi/[email protected]
        with:
          payload: |
            {
              "message": "${{github.ref}} - AAR 배포 완료",
              "channel_id": "C06791C77GT"
            }
        env:
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_MESSAGE_WEBHOOK_URL }}

When running ./gradlew assembleRelease and ./gradlew publish, the following error occurs.

Run ./gradlew assembleRelease
  ./gradlew assembleRelease
  shell: /usr/bin/bash -e {0}
  env:
    JAVA_HOME: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.1[2](https://github.com/pai-seocho/manual-billing-system-miniapp-android/actions/runs/10827331628/job/30040251574#step:7:2)-7/x64
    JAVA_HOME_17_X64: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.12-7/x64

> Configure project :lib
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
WARNING: The specified Android SDK Build Tools version ([3](https://github.com/pai-seocho/manual-billing-system-miniapp-android/actions/runs/10827331628/job/30040251574#step:7:3)3.0.0) is ignored, as it is below the minimum supported version (33.0.1) for Android Gradle Plugin 8.1.1.
Android SDK Build Tools 33.0.1 will be used.
To suppress this warning, remove "buildToolsVersion '33.0.0'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
WARNING: The specified Android SDK Build Tools version (33.0.0) is ignored, as it is below the minimum supported version (33.0.1) for Android Gradle Plugin 8.1.1.
Android SDK Build Tools 33.0.1 will be used.
To suppress this warning, remove "buildToolsVersion '33.0.0'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
Checking the license for package Android SDK Platform-Tools in /usr/local/lib/android/sdk/licenses
License for package Android SDK Platform-Tools accepted.
Preparing "Install Android SDK Platform-Tools v.35.0.2".
"Install Android SDK Platform-Tools v.35.0.2" ready.
Installing Android SDK Platform-Tools in /usr/local/lib/android/sdk/platform-tools
"Install Android SDK Platform-Tools v.35.0.2" complete.
"Install Android SDK Platform-Tools v.35.0.2" finished.

> Task :lib:preBuild UP-TO-DATE
> Task :lib:preReleaseBuild UP-TO-DATE
> Task :lib:mergeReleaseJniLibFolders
> Task :lib:mergeReleaseNativeLibs NO-SOURCE
> Task :lib:stripReleaseDebugSymbols NO-SOURCE
> Task :lib:copyReleaseJniLibsProjectAndLocalJars
> Task :lib:generateReleaseResValues
> Task :lib:extractDeepLinksForAarRelease
> Task :lib:generateReleaseResources
> Task :lib:packageReleaseResources
> Task :lib:parseReleaseLocalResources
> Task :lib:javaPreCompileRelease
> Task :lib:processReleaseManifest
> Task :lib:mergeReleaseShaders
> Task :lib:compileReleaseShaders NO-SOURCE
> Task :lib:generateReleaseAssets UP-TO-DATE
> Task :lib:packageReleaseAssets
> Task :lib:generateReleaseRFile
> Task :lib:prepareLintJarForPublish

> Task :lib:compileReleaseKotlin FAILED
FAILURE: Build failed with an exception.


* What went wrong:
Execution failed for task ':lib:compileReleaseKotlin'.
> Error while evaluating property 'filteredArgumentsMap' of task ':lib:compileReleaseKotlin'.
   > Could not resolve all files for configuration ':lib:releaseCompileClasspath'.
      > Cannot resolve external dependency androidx.appcompat:appcompat:1.1.0 because no repositories are defined.
        Required by:
            project :lib
      > Cannot resolve external dependency androidx.lifecycle:lifecycle-extensions:2.2.0 because no repositories are defined.
        Required by:
            project :lib
      > Cannot resolve external dependency androidx.swiperefreshlayout:swiperefreshlayout:1.1.0 because no repositories are defined.
        Required by:
            project :lib
      > Cannot resolve external dependency com.walmartlabs.ern:ern.navigation.support.lib:0.0.1 because no repositories are defined.
        Required by:
            project :lib
      > Cannot resolve external dependency com.google.zxing:core:3.3.3 because no repositories are defined.
        Required by:
            project :lib
      > Cannot resolve external dependency com.drewnoakes:metadata-extractor:2.11.0 because no repositories are defined.
        Required by:
            project :lib
      > Cannot resolve external dependency com.google.firebase:firebase-ml-vision:19.0.3 because no repositories are defined.
        Required by:
            project :lib
      > Cannot resolve external dependency com.google.firebase:firebase-ml-vision-face-model:17.0.2 because no repositories are defined.
        Required by:
            project :lib
      > Cannot resolve external dependency com.google.android.gms:play-services-mlkit-text-recognition:16.3.0 because no repositories are defined.
        Required by:
            project :lib
      > Cannot resolve external dependency com.google.android.gms:play-services-mlkit-barcode-scanning:16.2.0 because no repositories are defined.
        Required by:
            project :lib
      > Cannot resolve external dependency com.google.android.gms:play-services-mlkit-face-detection:16.2.0 because no repositories are defined.
        Required by:
            project :lib
      > Cannot resolve external dependency androidx.exifinterface:exifinterface:1.3.2 because no repositories are defined.
        Required by:
            project :lib
      > Cannot resolve external dependency androidx.annotation:annotation:1.0.0 because no repositories are defined.
        Required by:
            project :lib
      > Cannot resolve external dependency androidx.legacy:legacy-support-v[4](https://github.com/pai-seocho/manual-billing-system-miniapp-android/actions/runs/10827331628/job/30040251574#step:7:4):1.0.0 because no repositories are defined.
        Required by:
            project :lib
      > Cannot resolve external dependency com.vanniktech:android-image-cropper:4.3.3 because no repositories are defined.
        Required by:
            project :lib
      > Cannot resolve external dependency com.google.code.gson:gson:2.8.[5](https://github.com/pai-seocho/manual-billing-system-miniapp-android/actions/runs/10827331628/job/30040251574#step:7:5) because no repositories are defined.
        Required by:
            project :lib
      > Cannot resolve external dependency org.jetbrains.kotlin:kotlin-stdlib:1.[7](https://github.com/pai-seocho/manual-billing-system-miniapp-android/actions/runs/10827331628/job/30040251574#step:7:8).22 because no repositories are defined.
        Required by:
            project :lib
      > Cannot resolve external dependency androidx.webkit:webkit:1.4.0 because no repositories are defined.
        Required by:
            project :lib
      > Cannot resolve external dependency com.facebook.react:react-native:+ because no repositories are defined.
        Required by:
            project :lib
      > Cannot resolve external dependency com.github.mhiew:android-pdf-viewer:3.2.0-beta.3 because no repositories are defined.
        Required by:
            project :lib

* 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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

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/[8](https://github.com/pai-seocho/manual-billing-system-miniapp-android/actions/runs/10827331628/job/30040251574#step:7:9).1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in [9](https://github.com/pai-seocho/manual-billing-system-miniapp-android/actions/runs/10827331628/job/30040251574#step:7:10)s
13 actionable tasks: 13 executed

Somehow the gradle is unable to locate project dependencies. I believe this happens because of dependencies that do not align with Android API version 34.

Things I have tried

I have changed the settings in lib/build.gradle and build.gradle as follows.

lib/build.gradle

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
    publishNonDefault true
    compileSdkVersion 34
    buildToolsVersion "33.0.0"
    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 34
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.0'
    }
    sourceSets.main {
        res.srcDirs = [ 'src/main/res/bundle','src/main/res/camera','src/main/res/devassist','src/main/res/miniapp' ]
    }
    lintOptions {
        abortOnError false
    }
    namespace "com.walmartlabs.ern.container"
    kotlinOptions {
        jvmTarget = "17"
    }
}

dependencies {
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
    implementation 'com.walmartlabs.ern:ern.navigation.support.lib:0.0.1'
    implementation 'com.google.zxing:core:3.3.3'
    implementation 'com.drewnoakes:metadata-extractor:2.11.0'
    implementation 'com.google.firebase:firebase-ml-vision:19.0.3'
    implementation 'com.google.firebase:firebase-ml-vision-face-model:17.0.2'
    implementation 'com.google.android.gms:play-services-mlkit-text-recognition:16.3.0'
    implementation 'com.google.android.gms:play-services-mlkit-barcode-scanning:16.2.0'
    implementation 'com.google.android.gms:play-services-mlkit-face-detection:16.2.0'
    implementation 'androidx.exifinterface:exifinterface:1.3.2'
    implementation 'androidx.annotation:annotation:1.0.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.vanniktech:android-image-cropper:4.3.3'
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.7.22'
    implementation 'androidx.webkit:webkit:1.4.0'
//     api 'com.walmartlabs.ern:react-android:0.68.7'
    implementation "com.facebook.react:react-native:+"
    implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'
}

gradle.projectsEvaluated {
    android.buildTypes.each {
        it.resValue 'string', "CODE_PUSH_APK_BUILD_TIME", Long.toString(System.currentTimeMillis())
    }
}

build.gradle

ext {
    pdfViewerVersion = "3.1.0-beta.1" // ---->> Add this
}
buildscript {
    ext.kotlin_version = '1.8.10'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:8.1.1'
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.22'
    }
}

allprojects {
    configurations.all {
        resolutionStrategy {
            dependencySubstitution { // ---->> Add this
                substitute(module("com.github.barteksc:android-pdf-viewer")).using(module("com.github.mhiew:android-pdf-viewer:3.2.0-beta.3")).because("401 error in main repo")
            }
        }
    }
    tasks.withType(JavaCompile) {
        options.compilerArgs << '-Xlint:none'
        options.compilerArgs << '-nowarn'
    }
}
repositories {
        google()
        jcenter() // ---->> Add this
        maven { url 'https://jitpack.io' }
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
        mavenCentral()   // ---->>> try adding this
        mavenLocal()    // ---->>> try adding this
        maven { url "https://jcenter.bintray.com" }
        gradlePluginPortal() 
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

the original lib/build.gradle and build.gradle looked like this.

lib/build.gradle

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
    compileSdkVersion 33
    buildToolsVersion "33.0.0"
    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 33
    }
    buildTypes {
        release {
            minifyEnabled false
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.0'
    }
    sourceSets.main {
        res.srcDirs = [ 'src/main/res/bundle','src/main/res/camera','src/main/res/devassist','src/main/res/miniapp' ]
    }
    lintOptions {
        abortOnError false
    }
}

dependencies {
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
    implementation 'com.walmartlabs.ern:ern.navigation.support.lib:0.0.1'
    implementation 'com.google.zxing:core:3.3.3'
    implementation 'com.drewnoakes:metadata-extractor:2.11.0'
    implementation 'com.google.firebase:firebase-ml-vision:19.0.3'
    implementation 'com.google.firebase:firebase-ml-vision-face-model:17.0.2'
    implementation 'com.google.android.gms:play-services-mlkit-text-recognition:16.3.0'
    implementation 'com.google.android.gms:play-services-mlkit-barcode-scanning:16.2.0'
    implementation 'com.google.android.gms:play-services-mlkit-face-detection:16.2.0'
    implementation 'androidx.exifinterface:exifinterface:1.3.2'
    implementation 'androidx.annotation:annotation:1.0.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.vanniktech:android-image-cropper:4.3.3'
    implementation 'com.github.barteksc:android-pdf-viewer:3.1.0-beta.1'
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.7.22'
    implementation 'androidx.webkit:webkit:1.4.0'
    api 'com.walmartlabs.ern:react-android:0.68.7'
}

gradle.projectsEvaluated {
    android.buildTypes.each {
        it.resValue 'string', "CODE_PUSH_APK_BUILD_TIME", Long.toString(System.currentTimeMillis())
    }
}

build.gradle

buildscript {
    repositories {
        google()
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.4'
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.22'
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        jcenter()
        maven { url 'https://jitpack.io' }
        maven { url "https://jcenter.bintray.com"}
    }

    tasks.withType(JavaCompile) {
        options.compilerArgs << '-Xlint:none'
        options.compilerArgs << '-nowarn'
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

First I upgraded SDK version to 34. But then I needed to have upgraded Java to 17 as well as gradle plugin to 8.1.1, so I did that.
I also had to upgrade project gradle version to 8.1.
I have put bunch of repositories path like maven { url 'https://jitpack.io' }, maven { url "https://jcenter.bintray.com"}, gradlePluginPortal() because maven seemed to not able to find the right directory to the package.
android-pdf-viewer-3.1.0-beta.1 dependency have caused a specific error message so I downgraded to 2.8.2
I have also tried putting

resolutionStrategy {
           dependencySubstitution { // ---->> Add this
               substitute(module("com.github.barteksc:android-pdf-viewer")).using(module("com.github.mhiew:android-pdf-viewer:3.2.0-beta.3")).because("401 error in main repo")
}

code snippet, but it did not work.

The error message in the intro is the last error message I have encountered without being able to think of another solution.

Solving one dependency problem reveals a problem in another dependencies. So I'm assuming there needs to be a version upgrade for the whole dependencies. But I'm having hard time figuring out which version to upgrade to, or which version is compatible for Android API 34.

If someone could provide me some kind of guidance to move forward, I would very much appreciate it.

Note about dependencies
Dependencies that are causing the problem are required for my project. Below is the dependency section of package.json file

"dependencies": {
    "@oguzhnatly/react-native-image-manipulator": "1.0.5",
    "@openspacelabs/react-native-zoomable-view": "2.1.5",
    "@pietile-native-kit/keyboard-aware-scrollview": "1.5.0",
    "@pontusab/react-native-image-manipulator": "1.0.6",
    "@react-native-camera-roll/camera-roll": "5.0.2",
    "@react-native-community/hooks": "3.0.0",
    "@strapbuild/react-native-date-time-picker": "^2.0.3",
    "aes-js": "3.1.2",
    "assert": "2.1.0",
    "axios": "1.6.2",
    "axios-curlirize": "2.0.0",
    "axios-logger": "2.7.0",
    "crypto-js": "4.2.0",
    "date-fns": "2.30.0",
    "ern-navigation": "^2.1.0",
    "fastest-levenshtein": "1.0.16",
    "fbjs": "3.0.5",
    "hoist-non-react-statics": "3.3.2",
    "kled": "0.1.6",
    "lodash": "4.17.21",
    "patch-package": "8.0.0",
    "query-string": "7.1.3",
    "react": "17.0.2",
    "react-native": "0.68.7",
    "react-native-auto-height-image": "3.2.4",
    "react-native-camera": "4.0.3",
    "react-native-crypto": "2.2.0",
    "react-native-fs": "2.20.0",
    "react-native-image-crop-tools": "1.6.4",
    "react-native-image-resizer": "1.2.3",
    "react-native-image-size": "1.1.3",
    "react-native-linear-gradient": "2.7.3",
    "react-native-permissions": "3.6.0",
    "react-native-safe-area-context": "3.0.3",
    "react-native-svg": "12.5.1",
    "react-native-use-modal": "1.0.2",
    "react-native-uuid": "2.0.1",
    "react-native-webview": "11.26.1",
    "react-query": "^3.39.3",
    "rn-fetch-blob": "0.12.0",
    "rxjs": "7.8.1",
    "uuid": "9.0.1",
    "zustand": "4.4.7"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/runtime": "^7.12.5",
    "@react-native-community/eslint-config": "^2.0.0",
    "@types/aes-js": "^3.1.4",
    "@types/assert": "^1.5.10",
    "@types/axios-curlirize": "1.3.5",
    "@types/crypto-js": "^4.2.1",
    "@types/hoist-non-react-statics": "^3.3.5",
    "@types/jest": "^26.0.23",
    "@types/lodash": "4.14.201",
    "@types/react-native": "^0.68.7",
    "@types/react-test-renderer": "^17.0.2",
    "@types/shelljs": "^0.8.15",
    "@types/uuid": "9.0.7",
    "@typescript-eslint/eslint-plugin": "^5.37.0",
    "@typescript-eslint/parser": "^5.37.0",
    "babel-jest": "^26.6.3",
    "eslint": "^7.32.0",
    "jest": "^26.6.3",
    "metro-react-native-babel-preset": "^0.67.0",
    "react-test-renderer": "17.0.2",
    "shelljs": "^0.8.5",
    "ts-node": "^10.9.1",
    "typescript": "^4.8.3"
  },
  "resolutions": {
    "@types/react": "^17"
  },
  "jest": {
    "preset": "react-native",
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js",
      "jsx",
      "json",
      "node"
    ]
  },
  "ern": {
    "moduleName": "ManualBillingSystemMiniapp",
    "moduleType": "ern-miniapp",
    "packageManager": "yarn",
    "version": "0.51.0"
  },
  "keywords": [
    "ern-miniapp"
  ],
  "overrides": {
    "@strapbuild/react-native-perspective-image-cropper": {
      "react-native": "$react-native"
    },
    "react-native-fs": {
      "react-native": "$react-native",
      "react": "17.0.2",
      "react-native-windows": "0.64.0"
    },
    "react-native-windows": {
      "react-native": "$react-native",
      "react": "17.0.2"
    },
    "react-native-perspective-image-cropper": {
      "react-native": "$react-native",
      "react": "17.0.2"
    },
    "@strapbuild/react-native-perspective-image-cropper-2": {
      "react-native": "$react-native",
      "react": "17.0.2"
    },
    "@strapbuild/react-native-perspective-image-cropper-poojan31": {
      "react-native": "$react-native",
      "react": "17.0.2"
    },
    "react-native-image-resizer": {
      "react-native": "$react-native",
      "react": "17.0.2"
    },
    "react-native-auto-height-image": {
      "react-native": "$react-native",
      "react": "17.0.2"
    },
    "@react-native-camera-roll/camera-roll": {
      "react-native": "$react-native",
      "react": "17.0.2"
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant