Nativescript无法在单个dex文件中容纳请求的类



我遇到这个问题已经有很长一段时间了,我已经没有东西可以尝试了。我想我已经尝试过所有类似的解决方案,但都无济于事。我想看看我是否能得到更多的建议来解决我的问题。

我正在构建一个包含Firebase的NS8/Angular 11项目。我遵循中的步骤https://github.com/EddyVerbruggen/nativescript-plugin-firebase以设置云消息、远程配置和应用内消息,到目前为止,这些功能正在Android上运行。

使用tns build/run android成功构建并运行后,我在Android Studio中打开我的项目进行重建和签名。重建后,会出现以下错误。

这是我当前的应用程序.gradle(app_Resources/Android/src/main/app.gradle)

dependencies {
implementation 'com.android.support:multidex:2.0.1'
}
android {
defaultConfig {
applicationId "com.XXXX.XXXX"
minSdkVersion 17
generatedDensities = []
multiDexEnabled true
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}

在清理我的项目和重建几次后,我在Android Studio 中得到了这个错误

Execution failed for task ':app:mergeDexDebug'.
Error: null, Cannot fit requested classes in a single dex file (# methods: 120116 > 65536 ; # fields: 70750 > 65536)
Caused by: com.android.tools.r8.utils.b: Error: null, Cannot fit requested classes in a single dex file (# methods: 120116 > 65536 ; # fields: 70750 > 65536)
163 actionable tasks: 161 executed, 2 up-to-date
null, Cannot fit requested classes in a single dex file (# methods: 120116 > 65536 ; # fields: 70750 > 65536)

我尝试过其他解决方案,比如将minSDK更新到21。但我在上仍然出现了同样的错误

// Removed "dependencies"
android {
defaultConfig {
applicationId "com.XXXX.XXXX"
minSdkVersion 21
generatedDensities = []
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}

同样的错误。

我真的不知道还能在哪里检查,或者还能改变什么。显式启用multiDex和更新我的minSDK似乎都不起作用。

如果有用的话,这是我的包.json和AndroidManifest

"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/platform-browser": "~11.2.7",
"@angular/router": "~11.2.7",
"@bradmartin/nativescript-urlhandler": "^2.0.1",
"@mhtghn/nativescript-highcharts": "^1.0.2",
"@nativescript-community/ble": "^3.0.25",
"@nativescript-community/insomnia": "^2.0.2",
"@nativescript-community/ui-drawer": "0.0.28",
"@nativescript/angular": "~11.8.0",
"@nativescript/core": "^8.0.8",
"@nativescript/firebase": "^11.1.3",
"@nativescript/theme": "~3.0.1",
"@triniwiz/nativescript-toasty": "~4.1.3",
"bluebird": "3.5.5",
"crypto-es": "^1.2.7",
"nativescript-iap": "^7.1.1",
"nativescript-sentry": "^2.0.1",
"npm-check-updates": "^11.8.3",
"reflect-metadata": "^0.1.13",
"rxjs": "~6.6.7",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular/compiler-cli": "~11.2.7",
"@nativescript/android": "8.0.0",
"@nativescript/ios": "8.0.0",
"@nativescript/types": "~8.0.0",
"@nativescript/webpack": "5.0.0-dev.5",
"@ngtools/webpack": "^11.2.14",
"webpack": "5.48.0",
"sass": "~1.35.1",
"ts-node": "~10.0.0",
"typescript": "~4.0.0"
},
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="__PACKAGE__"
android:versionCode="XX"
android:versionName="XXX">
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"/>
<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="XXXX"
android:theme="@style/AppTheme"
android:launchMode="singleTop">
<meta-data android:name="io.sentry.dsn" android:value="https://14770d8bac924d4f96ceec0eac2be936@o420930.ingest.sentry.io/XXXXXX" />
<meta-data android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/icon" />
<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>

对我有效的方法实际上是通过Android Studio,通过命令行构建应用程序捆绑包,并上传捆绑包方向。

minSDKVersion被设置为21,而不需要multiDexEnabledimplementation...

最新更新