[Android][Maven] 找不到 androidx 工件
[Android][Maven] Cannot find androidx artifacts
我想将我的 aar 库包推送到 Github 个包。
我用 github 包 link 和所有依赖项创建了一个 pom.xml 文件。
这是 pom.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mypackage.package</groupId>
<artifactId>myartifact</artifactId>
<packaging>aar</packaging>
<version>0.0.1</version>
<name>My Package</name>
<url>https://mywebsite.com</url>
<build>
<plugins>
<plugin>
<groupId>com.simpligility.maven.plugins</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>4.1.0</version>
<extensions>true</extensions>
<configuration>
<sign>
<debug>false</debug>
</sign>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
</dependency>
<dependency>
<groupId>androidx.lifecycle</groupId>
<artifactId>lifecycle-extensions</artifactId>
<version>2.2.0</version>
<type>pom</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>androidx.fragment</groupId>
<artifactId>fragment</artifactId>
<version>1.3.3</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>androidx.recyclerview</groupId>
<artifactId>recyclerview</artifactId>
<version>1.2.0</version>
<type>pom</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>androidx.recyclerview</groupId>
<artifactId>recyclerview-selection</artifactId>
<version>1.1.0</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.android.volley</groupId>
<artifactId>volley</artifactId>
<version>1.2.0</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>androidx.appcompat</groupId>
<artifactId>appcompat</artifactId>
<version>1.2.0</version>
<type>pom</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.android.material</groupId>
<artifactId>material</artifactId>
<version>1.3.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>androidx.legacy</groupId>
<artifactId>legacy-support-v4</artifactId>
<version>1.0.0</version>
<type>pom</type>
<scope>runtime</scope>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>maven_central_repo</id>
<name>Maven repo</name>
<url>https://maven.google.com/</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/myrepo/myrepo</url>
</repository>
</distributionManagement>
</project>
部署时,出现以下错误:
The following artifacts could not be resolved: androidx.fragment:fragment:jar:1.0.0
我收到从 Google Maven 存储库下载的所有 androidx 依赖项的错误。
我的文件似乎正在 androidx.fragment 作为 jar 文件,即使我将类型指定为 pom .
如何获取 androidx 依赖项?
感谢您的帮助。
尝试使用 maven-publish
插件自动生成您的 pom 文件并发布。有例子 here.
apply plugin: 'maven-publish'
// Because the components are created only during the afterEvaluate phase, you must
// configure your publications using the afterEvaluate() lifecycle method.
afterEvaluate {
publishing {
publications {
// Creates a Maven publication called "release".
release(MavenPublication) {
// Applies the component for the release build variant.
from components.release
// You can then customize attributes of the publication as shown below.
groupId = 'com.example.MyLibrary'
artifactId = 'final'
version = '1.0'
}
// Creates a Maven publication called “debug”.
debug(MavenPublication) {
// Applies the component for the debug build variant.
from components.debug
groupId = 'com.example.MyLibrary'
artifactId = 'final-debug'
version = '1.0'
}
}
}
}
我想将我的 aar 库包推送到 Github 个包。 我用 github 包 link 和所有依赖项创建了一个 pom.xml 文件。
这是 pom.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mypackage.package</groupId>
<artifactId>myartifact</artifactId>
<packaging>aar</packaging>
<version>0.0.1</version>
<name>My Package</name>
<url>https://mywebsite.com</url>
<build>
<plugins>
<plugin>
<groupId>com.simpligility.maven.plugins</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>4.1.0</version>
<extensions>true</extensions>
<configuration>
<sign>
<debug>false</debug>
</sign>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
</dependency>
<dependency>
<groupId>androidx.lifecycle</groupId>
<artifactId>lifecycle-extensions</artifactId>
<version>2.2.0</version>
<type>pom</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>androidx.fragment</groupId>
<artifactId>fragment</artifactId>
<version>1.3.3</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>androidx.recyclerview</groupId>
<artifactId>recyclerview</artifactId>
<version>1.2.0</version>
<type>pom</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>androidx.recyclerview</groupId>
<artifactId>recyclerview-selection</artifactId>
<version>1.1.0</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.android.volley</groupId>
<artifactId>volley</artifactId>
<version>1.2.0</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>androidx.appcompat</groupId>
<artifactId>appcompat</artifactId>
<version>1.2.0</version>
<type>pom</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.android.material</groupId>
<artifactId>material</artifactId>
<version>1.3.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>androidx.legacy</groupId>
<artifactId>legacy-support-v4</artifactId>
<version>1.0.0</version>
<type>pom</type>
<scope>runtime</scope>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>maven_central_repo</id>
<name>Maven repo</name>
<url>https://maven.google.com/</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/myrepo/myrepo</url>
</repository>
</distributionManagement>
</project>
部署时,出现以下错误:
The following artifacts could not be resolved: androidx.fragment:fragment:jar:1.0.0
我收到从 Google Maven 存储库下载的所有 androidx 依赖项的错误。
我的文件似乎正在 androidx.fragment 作为 jar 文件,即使我将类型指定为 pom .
如何获取 androidx 依赖项?
感谢您的帮助。
尝试使用 maven-publish
插件自动生成您的 pom 文件并发布。有例子 here.
apply plugin: 'maven-publish'
// Because the components are created only during the afterEvaluate phase, you must
// configure your publications using the afterEvaluate() lifecycle method.
afterEvaluate {
publishing {
publications {
// Creates a Maven publication called "release".
release(MavenPublication) {
// Applies the component for the release build variant.
from components.release
// You can then customize attributes of the publication as shown below.
groupId = 'com.example.MyLibrary'
artifactId = 'final'
version = '1.0'
}
// Creates a Maven publication called “debug”.
debug(MavenPublication) {
// Applies the component for the debug build variant.
from components.debug
groupId = 'com.example.MyLibrary'
artifactId = 'final-debug'
version = '1.0'
}
}
}
}