flutter-unity-view-widget
flutter-unity-view-widget copied to clipboard
Cannot build release version
Hello.
I try to build release version of application which uses ARCore through unity. I get the error below :
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':app:lintVitalRelease'.
Could not resolve all artifacts for configuration ':flutter_unity_widget:profileRuntimeClasspath'. Could not resolve project :unityLibrary. Required by: project :flutter_unity_widget > Unable to find a matching variant of project :unityLibrary: - Variant 'debugApiElements' capability android:unityLibrary:unspecified: - Incompatible attributes: - Required com.android.build.api.attributes.BuildTypeAttr 'profile' and found incompatible value 'debug'. - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'. - Other attributes: - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Variant 'debugRuntimeElements' capability android:unityLibrary:unspecified: - Incompatible attribute: - Required com.android.build.api.attributes.BuildTypeAttr 'profile' and found incompatible value 'debug'. - Other attributes: - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'. - Variant 'releaseApiElements' capability android:unityLibrary:unspecified: - Incompatible attributes: - Required com.android.build.api.attributes.BuildTypeAttr 'profile' and found incompatible value 'release'. - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'. - Other attributes: - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Variant 'releaseRuntimeElements' capability android:unityLibrary:unspecified: - Incompatible attribute: - Required com.android.build.api.attributes.BuildTypeAttr 'profile' and found incompatible value 'release'. - Other attributes: - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
-
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 9s
Can you show the build.gradle file in android/app and android/unityLibrary?
unityLibrary:
buildscript { repositories { google() jcenter() } dependencies { // Must be Android Gradle Plugin 3.6.0 or later. For a list of // compatible Gradle versions refer to: // https://developer.android.com/studio/releases/gradle-plugin classpath 'com.android.tools.build:gradle:3.6.0' } }
allprojects { repositories { google() jcenter() flatDir { dirs 'libs' } } }
apply plugin: 'com.android.library'
dependencies { implementation(name: 'unity-classes', ext:'jar') implementation(name: 'arcore_client', ext:'aar') implementation(name: 'ARPresto', ext:'aar') implementation(name: 'cloud_anchor_manifest', ext:'aar') implementation(name: 'unityandroidpermissions', ext:'aar') implementation(name: 'UnityARCore', ext:'aar') }
android { compileSdkVersion 29 buildToolsVersion '28.0.3'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion 24
targetSdkVersion 29
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a'
}
versionCode 1
versionName '0.1'
consumerProguardFiles 'proguard-unity.txt'
}
lintOptions {
abortOnError false
}
aaptOptions {
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}
packagingOptions {
doNotStrip '*/armeabi-v7a/*.so'
doNotStrip '*/arm64-v8a/*.so'
}
}
androir/app:
def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { localPropertiesFile.withReader('UTF-8') { reader -> localProperties.load(reader) } }
def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") }
def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' }
def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { flutterVersionName = '1.0' }
def keystoreProperties = new Properties() def keystorePropertiesFile = rootProject.file('key.properties') if (keystorePropertiesFile.exists()) { keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) }
apply plugin: 'com.android.application' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android { compileSdkVersion 29
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "$$$$$$$"
minSdkVersion 24
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
//signingConfig signingConfigs.debug
signingConfig signingConfigs.release
}
}
}
flutter { source '../..' }
try insert into the android/app/build.gradle:
dependencies { implementation project(':unityLibrary') }
dependencies { implementation project(':unityLibrary') }
Thank you ! However I get the same error:
Help, I have the same issue.
On commands flutter run --release flutter build apk --release
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':app:lintVitalRelease'.
Could not resolve all artifacts for configuration ':flutter_unity_widget:profileRuntimeClasspath'. Could not resolve project :unityLibrary. Required by: project :flutter_unity_widget > No matching variant of project :unityLibrary was found. The consumer was configured to find a runtime of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'profile', attribute 'com.android.build.gradle.internal.dependency.AndroidTypeAttr' with value 'Aar' but: - Variant 'debugApiElements' capability android:unityLibrary:unspecified declares a component, as well as attribute 'com.android.build.gradle.internal.dependency.AndroidTypeAttr' with value 'Aar': - Incompatible because this component declares an API of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug' and the consumer needed a runtime of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'profile' - Variant 'debugRuntimeElements' capability android:unityLibrary:unspecified declares a runtime of a component, as well as attribute 'com.android.build.gradle.internal.dependency.AndroidTypeAttr' with value 'Aar': - Incompatible because this component declares a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug' and the consumer needed a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'profile' - Variant 'releaseApiElements' capability android:unityLibrary:unspecified declares a component, as well as attribute 'com.android.build.gradle.internal.dependency.AndroidTypeAttr' with value 'Aar': - Incompatible because this component declares an API of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release' and the consumer needed a runtime of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'profile' - Variant 'releaseRuntimeElements' capability android:unityLibrary:unspecified declares a runtime of a component, as well as attribute 'com.android.build.gradle.internal.dependency.AndroidTypeAttr' with value 'Aar': - Incompatible because this component declares a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release' and the consumer needed a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'profile'
-
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 1m 5s Running Gradle task 'assembleRelease'... Running Gradle task 'assembleRelease'... Done 66.7s Gradle task assembleRelease failed with exit code 1
However, Running Gradle task 'assembleDebug' is successful. ('assembleRelease' fails)
try insert into the android/app/build.gradle:
dependencies { implementation project(':unityLibrary') }
Thank you for your reply. But these lines are already there in the android/app/build.gradle file.
Did you find a solution to this? Having the same issue. Already have implementation project in the build gradle. The profile config has also been generated but release is failing to build
Did you find a solution to this? Having the same issue. Already have implementation project in the build gradle. The profile config has also been generated but release is failing to build
Not able to build profile either. Haven't found a solution yet.
To build a release package, you need to add signconfig in UnityLibrary/build.gradle
. The code below use the debug signConfig for all buildTypes, which can be changed as you well if you need specify signConfig.
buildTypes {
release {
signingConfig signingConfigs.debug
}
debug {
signingConfig signingConfigs.debug
}
profile{
signingConfig signingConfigs.debug
}
innerTest {
//...
matchingFallbacks = ['debug', 'release']
}
}
Below is the UnityLibrary/build.gradle
that has been generated by unity. Where do I add the above buildTypes {...}
lines?
// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
buildscript {
repositories {
google()
jcenter()
}
dependencies {
// Must be Android Gradle Plugin 3.6.0 or later. For a list of
// compatible Gradle versions refer to:
// https://developer.android.com/studio/releases/gradle-plugin
classpath 'com.android.tools.build:gradle:3.6.0'
}
}
allprojects {
repositories {
google()
jcenter()
flatDir {
dirs 'libs'
}
}
}
apply plugin: 'com.android.library'
dependencies {
implementation(name: 'unity-classes', ext:'jar')
implementation(name: 'arcore_client', ext:'aar')
implementation(name: 'unityandroidpermissions', ext:'aar')
implementation(name: 'UnityARCore', ext:'aar')
}
android {
compileSdkVersion 29
buildToolsVersion '28.0.3'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion 24
targetSdkVersion 29
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a'
}
versionCode 1
versionName '0.1'
consumerProguardFiles 'proguard-unity.txt'
}
lintOptions {
abortOnError false
}
aaptOptions {
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}
packagingOptions {
doNotStrip '*/armeabi-v7a/*.so'
doNotStrip '*/arm64-v8a/*.so'
}
}
It Should look like this
// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
buildscript {
repositories {
google()
jcenter()
}
dependencies {
// Must be Android Gradle Plugin 3.6.0 or later. For a list of
// compatible Gradle versions refer to:
// https://developer.android.com/studio/releases/gradle-plugin
classpath 'com.android.tools.build:gradle:3.6.0'
}
}
allprojects {
repositories {
google()
jcenter()
flatDir {
dirs 'libs'
}
}
}
apply plugin: 'com.android.library'
dependencies {
implementation(name: 'unity-classes', ext:'jar')
implementation(name: 'arcore_client', ext:'aar')
implementation(name: 'unityandroidpermissions', ext:'aar')
implementation(name: 'UnityARCore', ext:'aar')
}
android {
compileSdkVersion 29
buildToolsVersion '28.0.3'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion 24
targetSdkVersion 29
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a'
}
versionCode 1
versionName '0.1'
consumerProguardFiles 'proguard-unity.txt'
}
lintOptions {
abortOnError false
}
aaptOptions {
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.debug
}
debug {
signingConfig signingConfigs.debug
}
profile{
signingConfig signingConfigs.debug
}
}
packagingOptions {
doNotStrip '*/armeabi-v7a/*.so'
doNotStrip '*/arm64-v8a/*.so'
}
}
where
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
refers to your key.properties file in android dir
Hi, I also facing same issue , when try to apk release. I have added signingConfigs
and buildTypes
to unityLibrary/build.gradle
but it still doesn't work
Guys, have you tried add the code below to the app/build.gradle??
lintOptions {
disable 'InvalidPackage'
checkReleaseBuilds false
}
this pieco of code is on the readme and solved for me.
lintOptions { disable 'InvalidPackage' checkReleaseBuilds false }
This Worked
It worked for me as well
Guys, have you tried add the code below to the app/build.gradle??
lintOptions { disable 'InvalidPackage' checkReleaseBuilds false }
this pieco of code is on the readme and solved for me.
This Worked
Guys, have you tried add the code below to the app/build.gradle??
lintOptions { disable 'InvalidPackage' checkReleaseBuilds false }
this pieco of code is on the readme and solved for me.
This does not build a signed release version. Guys, do you know how to build a signed with keystore release version of the app?