如何解决@nativescript/imagepicker 不适用于 Android无法构建插件
我正在尝试构建一个 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>
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"
},...
}
完全错误:
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:requestLegacyExternalStorage
上的 @nativescript/core
,需要与 imagepicker
更新一起进行。
您需要将这些依赖项更新为以下内容:
"@nativescript/core": "~8.0.0","@nativescript/imagepicker": "~1.0.4"
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。