I'm studying Flutter and trying to integrate Trust Wallet services into my app. I imported the trust_wallet_core
package from pub.dev (https://pub.dev/packages/trust_wallet_core), and while starting the app, I received an error:
Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
Running Gradle task 'assembleDebug'...
Building with Flutter multidex support enabled.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform wallet-core-3.1.27.aar (com.trustwallet:wallet-core:3.1.27) to match attributes {artifactType=android-aar-metadata, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Could not download wallet-core-3.1.27.aar (com.trustwallet:wallet-core:3.1.27)
> Could not get resource 'https://maven.pkg.github.com/trustwallet/wallet-core/com/trustwallet/wallet-core/3.1.27/wallet-core-3.1.27.aar'.
> Could not HEAD 'https://maven.pkg.github.com/trustwallet/wallet-core/com/trustwallet/wallet-core/3.1.27/wallet-core-3.1.27.aar'. Received status code 401 from server: Unauthorized
* 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 6s
With this error at hand, I started to look at their repository documentation (https://developer.trustwallet.com/developer/wallet-core/integration-guide/android-guide). The documentation explains creating a GitHub personal access token and importing this configuration into your build.gradle
, which is exactly what I did.
Inside my Android folder, I inserted the expected configuration in build.gradle
to access the local.properties variables correctly, but I'm still getting the same error.
The build.gradle file
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
id 'com.google.gms.google-services'
}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
android {
namespace "br.com.coders.concept.crypto_digital_bank"
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
applicationId "br.com.coders.concept.crypto_digital_bank"
minSdkVersion 23
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation(platform("com.google.firebase:firebase-bom:32.3.1"))
implementation("com.google.firebase:firebase-analytics-ktx")
implementation("com.google.firebase:firebase-auth-ktx")
implementation("com.google.firebase:firebase-firestore-ktx")
}
def gprUser = localProperties.getProperty("gpr.user")
def gprToken = localProperties.getProperty("gpr.token")
println "gpr.user: $gprUser"
println "gpr.token: $gprToken"
allprojects {
repositories {
maven {
url "https://maven.pkg.github.com/trustwallet/wallet-core"
credentials {
username gprUser
password gprToken
}
}
}
}
There is something I missed or did wrong?
I tried:
- Generated another key with more access, not just readonly.
- Changed the approach and imported the GitHub path directly into the pubspec.yaml.
- Generated a new access key on GitHub.
- Deleted the entire project and started a new one with only these configurations to see what happens.
- Duplicated the local.properties file from the Android folder to the root project folder.
- Inserted the authentication settings in all the Gradle project files.
What I expect:
- I expect to be able to access the dependency on GitHub Packages and use it within the project normally. However, I always receive a 401 error from this repository.