我创建了一个依赖于constraintlayout的库。该库通过aar文件包含在新项目中。该项目为其使用的所有appNS属性提供以下错误。
home / vishal / .gradle / caches / transforms-1 / files-1.1 / my_library.aar / 9012247ff26b45ffb7af7d608db342c5 / res / layout / activity_main.xml:70:AAPT:error:attribute layout_constraintBottom_toTopOf(aka com.example.sampleapp:layout_constraintBottom_toTopOf)not not not找到。
库编译sdk:28支持版本:28.0.0
ConstraintLayout作为库中的实现添加。 aar库包含在项目中如下:
dependencies {
implementation fileTree(include: ['*.aar'], dir: 'libs')
implementation files('libs/my_library.aar')
}
我已经尝试将库和项目转换为androidX,但问题仍然存在。
为了测试具有现有库的场景[更新]:我在刮刮卡库[https://github.com/Veeshal/scratchCardLayout]中添加了约束布局以及实现约束布局的活动及其布局。将其导入为aar文件。我在构建时没有收到任何错误。验证创建示例项目并从上面共享的github存储库中的模块scratchcardlayout添加生成的AAR文件。
activity_main.xml中
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
.....
<!-- Optional Design -->
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal"
android:visibility="gone">
....
</android.support.constraint.ConstraintLayout>
<!-- Selected Design -->
<android.support.constraint.ConstraintLayout
android:id="@+id/cl_cropping_layer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:visibility="visible"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent">
....
</android.support.constraint.ConstraintLayout>
.....
</android.support.constraint.ConstraintLayout>
一个人根本无法添加像qazxsw poi依赖的本地qazxsw poi依赖。
需要在根项目qazxsw poi中设置本地qazxsw poi存储库:
AAR
然后人们可以参考JAR
几乎任何其他依赖;注意flatDir
:
build.gradle
而且很可能,你还必须使用allprojects {
repositories {
...
flatDir {
dirs "libs"
}
}
}
而不是AAR
(在库模块中)
...为了将@aar
暴露给“库消费者”(这是app模块)。