Создайте новую конфигурацию и установите ее BuildTypeAttr для модуля в Android gradle.Android

Форум для тех, кто программирует под Android
Ответить
Anonymous
 Создайте новую конфигурацию и установите ее BuildTypeAttr для модуля в Android gradle.

Сообщение Anonymous »

После этого ответа о переполнении стека Ошибка сборки библиотеки Android: прямые локальные зависимости файлов .aar не поддерживаются для решения моей исходной проблемы. В моем модуле я создал файл build.gradle со следующим содержимым:

Код: Выделить всё

configurations.maybeCreate("default")
artifacts.add("default", file('[nameOfTheAar].aar'))
Пока все хорошо.
Затем я захотел расширить это, чтобы в случае отладки и выпуска использовались два разных aar. Я попробовал:

Код: Выделить всё

configurations.maybeCreate("debug")
configurations.maybeCreate("release")
artifacts.add("debug", file('[nameOfTheAar]-debug.aar'))
artifacts.add("release", file('[nameOfTheAar]-release.aar'))
Но имени конфигурации недостаточно для автоматического выбора, и я получил следующую ошибку:

Код: Выделить всё

Could not determine the dependencies of task ':[moduleName]:buildCMakeDebug[arm64-v8a]'.
> Could not resolve all task dependencies for configuration ':realsense:debugCompileClasspath'.
> Could not resolve project :[submoduleName].
Required by:
project :[moduleName]
> No matching configuration of project :[submoduleName] was found. The consumer was configured to find a library for use during compile-time, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.3.1', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but:
- Configuration 'debug':
- Other compatible attributes:
- Doesn't say anything about com.android.build.api.attributes.AgpVersionAttr (required '8.3.1')
- Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'debug')
- Doesn't say anything about its component category (required a library)
- Doesn't say anything about its target Java environment (preferred optimized for Android)
- Doesn't say anything about its usage (required compile-time)
- Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'androidJvm')
- Configuration 'release':
- Other compatible attributes:
- Doesn't say anything about com.android.build.api.attributes.AgpVersionAttr (required '8.3.1')
- Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'debug')
- Doesn't say anything about its component category (required a library)
- Doesn't say anything about its target Java environment (preferred optimized for Android)
- Doesn't say anything about its usage (required compile-time)
- Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'androidJvm')
Похоже, что ему нужен атрибут типа BuildTypeAttr. Я пробовал что-то вроде следующего, но это неправильный синтаксис/он не работает:
Похоже, что ему нужен атрибут типа BuildTypeAttr. Я пробовал что-то вроде следующего, но это неправильный синтаксис/он не работает:
p>

Код: Выделить всё

configurations.maybeCreate("debug").attributes { it.attribute(BuildTypeAttr, "debug")}
configurations.maybeCreate("release").attributes { it.attribute(BuildTypeAttr, "release")}
artifacts.add("debug", file('librealsense-debug.aar'))
artifacts.add("release", file('librealsense-release.aar'))
Как правильно (с использованием языка сценариев Kotlin) установить атрибут типа сборки в конфигурации?


Подробнее здесь: https://stackoverflow.com/questions/783 ... ndroid-gra
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»