0

I'm trying to build a Nativescript app to run an my Android device. I've been trying to build and run, but unfortunately, I keep getting this build error:

FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > 1 exception was raised by workers:
     com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
     /Users/.../platforms/tempPlugin/imagepicker/src/main/AndroidManifest.xml:4:3-61: AAPT: error: attribute android:requestLegacyExternalStorage not found.
* 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 1s
Failed to build plugin @nativescript/imagepicker : 
Error: Command ./gradlew failed with exit code 1

I've tried two solutions, one posted here https://github.com/NativeScript/plugins/issues/124 and then I tried following the steps outlined here: https://github.com/NativeScript/plugins/tree/master/packages/imagepicker. However, I was unsuccessfully. I also wasn't able to figure out how to use nativescript-permissions, if applicable.

EDIT: I'm still having trouble and can't build on Android at all yet. I've even tried deleting imagepicker from my package.json file, ran ns clean, then ran tns build android but I still get the same error below.

Below is my AndroidManifest and package.json file

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="__PACKAGE__">

    <supports-screens
        android:smallScreens="true"
        android:normalScreens="true"
        android:largeScreens="true"
        android:xlargeScreens="true"/>

    <uses-sdk
        android:minSdkVersion="17"
        android:targetSdkVersion="__APILEVEL__"/>

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

    <application
        android:name="com.tns.NativeScriptApplication"
        android:allowBackup="true"
        android:icon="@drawable/icon"
        android:label="Row Forge"
        android:theme="@style/AppTheme"
        android:launchMode="singleTop">

        <activity
            android:name="com.tns.NativeScriptActivity"
            android:label="@string/title_activity_kimera"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|locale|uiMode"
            android:theme="@style/LaunchScreenTheme">

            <meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" /> 
                <data android:scheme="rowforge" />
            </intent-filter>
        </activity>
        <activity android:name="com.tns.ErrorReportActivity"/>
    </application>
</manifest>

Package.json

...
  "dependencies": {
    "@angular/animations": "~11.2.7",
    "@angular/cdk": "~11.2.7",
    "@angular/common": "~11.2.7",
    "@angular/compiler": "~11.2.7",
    "@angular/core": "~11.2.7",
    "@angular/forms": "~11.2.7",
    "@angular/material": "~11.2.7",
    "@angular/platform-browser": "~11.2.7",
    "@angular/platform-browser-dynamic": "~11.2.7",
    "@angular/router": "~11.2.7",
    "@bradmartin/nativescript-urlhandler": "^2.0.1",
    "@nativescript-community/ble": "^3.0.25",
    "@nativescript-community/insomnia": "^2.0.2",
    "@nativescript-community/ui-chart": "^1.1.38",
    "@nativescript-community/ui-drawer": "0.0.28",
    "@nativescript/angular": "~11.8.0",
    "@nativescript/camera": "~5.0.8",
    "@nativescript/core": "~8.0.0",
    "@nativescript/theme": "~3.0.1",
    "@sentry/node": "6.8.0",
    "@triniwiz/nativescript-toasty": "~4.1.3",
    "bluebird": "3.5.5",
    "crypto-es": "^1.2.7",
    "nativescript-purchase": "^2.0.14",
    "nativescript-sentry": "^2.0.1",
    "nativescript-ui-chart": "^8.0.2",
    "nativescript-ui-gauge": "^7.0.2",
    "nativescript-ui-sidedrawer": "~9.0.3",
    "reflect-metadata": "^0.1.13",
    "rxjs": "~6.6.7",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular/compiler-cli": "~11.2.7",
    "@nativescript/ios": "8.0.0",
    "@nativescript/android": "8.0.0",
    "@nativescript/types": "~8.0.0",
    "@nativescript/webpack": "beta",
    "@ngtools/webpack": "~11.2.6",
    "sass": "~1.35.1",
    "ts-node": "~10.0.0",
    "typescript": "~4.0.0"
  },
...
}

FULL ERROR:

Built aar for @nativescript-community/ble
Built aar for @nativescript/camera
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Built aar for @nativescript-community/gesturehandler
Note: /Users/JoseChavez/Desktop/.../platforms/tempPlugin/ui_canvas/src/main/java/com/akylas/canvas/StaticLayout.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Built aar for @nativescript-community/ui-canvas

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > 1 exception was raised by workers:
     com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
     /Users/JoseChavez/Desktop/.../platforms/tempPlugin/imagepicker/src/main/AndroidManifest.xml:4:3-61: AAPT: error: attribute android:requestLegacyExternalStorage not found.
         


* 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 1s
Failed to build plugin @nativescript/imagepicker : 
Error: Command ./gradlew failed with exit code 1

EDIT 2: I even tried re-installing it, with 1.0.5 and nativescript/core 8.0.8 but nothing. I even added the android:requestLegacyExternalStorage="true" into my Android Manifest, but same thing.

Any help would be much appreciated.

Jose Chavez
  • 115
  • 9

1 Answers1

1

There was also a patch with a fix for android:requestLegacyExternalStorage on @nativescript/core which needs to go in together with the imagepicker update.

You will need to update these dependencies to the following:

"@nativescript/core": "~8.0.0",
"@nativescript/imagepicker": "~1.0.4"
William Juan
  • 1,395
  • 1
  • 7
  • 10
  • Thanks, I was looking into this fix that someone else also recommended. I haven't quite gotten it to work yet but I know that those updates are needed. I think I need to fully migrate to NS8 as well, but still getting it to work. – Jose Chavez Jun 03 '21 at 14:43
  • Hello there, I'm still having trouble with this actually. So I thought I had it working but turns out, I didn't, even with 1.0.4 imagepicker. I'm still getting the same error. Someone told me that I don't need the android:requestLegacyExternalStorage anymore. – Jose Chavez Jun 30 '21 at 16:45