voximplant / react-native-foreground-service

React native module to start foreground service on android
MIT License
159 stars 91 forks source link

Issues building Android APK #9

Closed Connor-Y-Evenset closed 5 years ago

Connor-Y-Evenset commented 5 years ago

Attempting to build a release Android APK while using this library results in an error when compiling.

Compilation made using ./android/gradlew assembleRelease

* What went wrong:
Execution failed for task ':@voximplant_react-native-foreground-service:verifyReleaseResources'.
> 1 exception was raised by workers:
  com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
  /home/evenset/Desktop/myant/mobile-app/node_modules/@voximplant/react-native-foreground-service/android/build/intermediates/res/merged/release/values-v28/values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
  /home/evenset/Desktop/myant/mobile-app/node_modules/@voximplant/react-native-foreground-service/android/build/intermediates/res/merged/release/values-v28/values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
  /home/evenset/Desktop/myant/mobile-app/node_modules/@voximplant/react-native-foreground-service/android/build/intermediates/res/merged/release/values/values.xml:2714: error: resource android:attr/fontVariationSettings not found.
  /home/evenset/Desktop/myant/mobile-app/node_modules/@voximplant/react-native-foreground-service/android/build/intermediates/res/merged/release/values/values.xml:2715: error: resource android:attr/ttcIndex not found.
  error: failed linking references.

This issue appears to be resolved by setting compileSdkVersion 28 and targetSdkVersion 28 inside the android/build.gradle file. I am not sure if there are any other side effects to this change however.

Edit: Noticed afterwards that there is a PR for this already open. Is there any intent to merge this @YuliaGrigorieva ?

beige229 commented 5 years ago

I also have this issue, but my compileSdkVersion and targetSdkVersion are already set at 28. What do you have for buildToolsVersion and supportLibVersion?

Thank you!

Connor-Y-Evenset commented 5 years ago

I don't recall changing any of the other options here. For reference my forground service build.gradle file is as follows


apply plugin: 'com.android.library'

def safeExtGet(prop, fallback) {
    rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
    }
    lintOptions {
        abortOnError false
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'com.facebook.react:react-native:+'
    api "com.android.support:appcompat-v7:${safeExtGet('supportLibVersion', '27.1.1')}"
}
beige229 commented 5 years ago

It worked, thank you! My mistake is that I was modifying my own apps' build.gradle, not the correct one.

Connor-Y-Evenset commented 5 years ago

One thing to be careful of here is that this will only work for your local installation of the module. If you install/build on a different device the changes will not persist.

Connor-Y-Evenset commented 5 years ago

This should have been resolved by https://github.com/voximplant/react-native-foreground-service/pull/5