【问题标题】:@nativescript/imagepicker not working on Android (Failed to build plugin)@nativescript/imagepicker 无法在 Android 上运行(无法构建插件)
【发布时间】:2021-08-20 02:47:04
【问题描述】:

我正在尝试构建一个 Nativescript 应用程序来运行我的 Android 设备。我一直在尝试构建和运行,但不幸的是,我不断收到此构建错误:

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

我尝试了两种解决方案,一种在此处发布https://github.com/NativeScript/plugins/issues/124 然后我尝试按照此处概述的步骤操作:https://github.com/NativeScript/plugins/tree/master/packages/imagepicker。然而,我没有成功。如果适用,我也无法弄清楚如何使用nativescript-permissions

编辑:我仍然遇到问题,根本无法在 Android 上构建。我什至尝试从我的 package.json 文件中删除 imagepicker,运行 ns clean,然后运行 ​​tns build android,但我仍然在下面遇到同样的错误。

下面是我的 AndroidManifest 和 package.json 文件

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>

包.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"
  },
...
}

完全错误:

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

编辑 2:我什至尝试使用 1.0.5 和 nativescript/core 8.0.8 重新安装它,但没有。我什至将android:requestLegacyExternalStorage="true" 添加到我的Android Manifest 中,但同样的事情。

任何帮助将不胜感激。

【问题讨论】:

    标签: android nativescript nativescript-angular nativescript-plugin


    【解决方案1】:

    还有一个修复了@nativescript/core 上的android:requestLegacyExternalStorage 的补丁,它需要与imagepicker 更新一起使用。

    您需要将这些依赖项更新为以下内容:

    "@nativescript/core": "~8.0.0",
    "@nativescript/imagepicker": "~1.0.4"
    

    【讨论】:

    • 谢谢,我正在研究其他人也推荐的此修复程序。我还没有完全让它工作,但我知道需要这些更新。我认为我也需要完全迁移到 NS8,但仍然可以正常工作。
    • 您好,实际上我仍然遇到问题。所以我以为我可以正常工作,但事实证明,我没有,即使使用 1.0.4 图像选择器。我仍然遇到同样的错误。有人告诉我,我不再需要 android:requestLegacyExternalStorage。
    猜你喜欢
    • 2023-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多