我正在尝试为我从 github 克隆的 android 构建莱特币钱包:https ://github.com/Litecoin-Java/bitcoin-wallet
几天来我一直在用头撞墙,因为试图构建这个东西会不断地导致越来越多的错误。github上的说明只是说运行“mvn clean install”,但对我来说似乎并不那么简单。这是我第一次使用 maven,也是我第一次用 bitcoinj 库做任何事情。
这是合二为一的问题,因为当我尝试将 bitcoinj 依赖项设置为 v0.12.3(最新)而不是 v0.10.3(非常旧......)时,我也遇到了错误
几天后,经过一些更改,我终于让它工作了:
- 使用 Maven 3.1.1 而不是最新版本 Maven 3.3.3
- 在我的项目的 POM 中将 bitcoinj 依赖项设置为 v0.10.3 而不是最新版本 v0.12.3
- 修复 POM 内容,例如将 maven-android-plugin 版本更改为 3.8(这修复了一些错误)并
在 POM 中为 maven-compiler-plugin 设置 source,target=1.7(这也修复了我在
编译项目时遇到的错误)
已正确设置 HOME_JAVA 和 ANDROID_HOME 等环境变量。我还确保将 maven、androidsdk/tools 和 /platform-tools 添加到我的 PATH 中。
我正在运行 Ubuntu 14.04。
运行 maven 3.1.1 和 bitcoinj v0.10.3 我得到
[INFO] base .............................................. SUCCESS [0.384s]
[INFO] Bitcoin Integration for Android ................... SUCCESS [1.448s]
[INFO] Bitcoin Wallet .................................... SUCCESS [49.624s]
[INFO] Sample for Bitcoin Integration for Android ........ SUCCESS [2.128s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
升级到 maven 3.3.3(同时仍然使用 bitcoinj v0.10.3)我得到:
[INFO] base ............................................... SUCCESS [ 0.453 s]
[INFO] Bitcoin Integration for Android .................... SUCCESS [ 1.937 s]
[INFO] Bitcoin Wallet ..................................... FAILURE [ 41.376 s]
[INFO] Sample for Bitcoin Integration for Android ......... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 45.952 s
[INFO] Finished at: 2015-05-22T11:23:01+00:00
[INFO] Final Memory: 29M/332M
[INFO] ------------------------------------------------------------------------
[ERROR] Unable to provision, see the following errors:
[ERROR]
[ERROR] 1) No implementation for org.eclipse.aether.connector.wagon.WagonProvider was bound.
[ERROR] while locating org.eclipse.aether.connector.wagon.WagonRepositoryConnectorFactory
[ERROR] at ClassRealm[extension>com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.8.0, parent: sun.misc.Launcher$AppClassLoader@665ce0fe] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
[ERROR] at ClassRealm[extension>com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.8.0, parent: sun.misc.Launcher$AppClassLoader@665ce0fe] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
[ERROR] while locating org.eclipse.aether.spi.connector.RepositoryConnectorFactory annotated with @com.google.inject.name.Named(value=wagon)
[ERROR]
[ERROR] 1 error
将 bitcoinj 依赖的版本设置为 0.12.3 我得到:
[ERROR] Failed to execute goal on project wallet: Could not resolve dependencies for project de.schildbach.wallet:wallet:apk:3.29-test: Could not find artifact com.google:bitcoinj:jar:0.12.3 in central (http://repo.maven.apache.org/maven2) ->
我不,这意味着我需要自己获取和构建 0.12.3,但我不知道如何让我的项目知道在哪里可以找到我的自定义构建版本。
我不知道是什么原因造成的,因为我没有像我之前所说的那样使用 bitcoinj 或 maven。我遇到的大多数错误至少会出现一些对我有帮助的谷歌结果,但是当我搜索其中任何一个的版本问题时,我找不到太多。
这是整个项目的 POM:
<?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>de.schildbach.wallet</groupId>
<artifactId>base</artifactId>
<name>base</name>
<version>1</version>
<packaging>pom</packaging>
<modules>
<module>wallet</module>
<module>integration-android</module>
<module>sample-integration-android</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.15</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<genDirectory>${basedir}/gen</genDirectory>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.7</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
这是“钱包”文件夹的POM:
<?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>
<artifactId>wallet</artifactId>
<packaging>apk</packaging>
<version>3.29-test</version>
<name>Bitcoin Wallet</name>
<parent>
<groupId>de.schildbach.wallet</groupId>
<artifactId>base</artifactId>
<version>1</version>
</parent>
<dependencies>
<!-- android.*, java.*, javax.* -->
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.0.1.2</version>
<scope>provided</scope>
</dependency>
<!-- android.annotation.* -->
<dependency>
<groupId>com.google.android</groupId>
<artifactId>annotations</artifactId>
<!-- version should match android artifact, but not available on maven central -->
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
<!-- android.support.v4.* -->
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
<version>r7</version>
</dependency>
<!-- com.actionbarsherlock.* -->
<dependency>
<groupId>com.actionbarsherlock</groupId>
<artifactId>library</artifactId>
<version>4.1.0</version>
<type>apklib</type>
</dependency>
<!-- com.google.bitcoin.* -->
<dependency>
<groupId>com.google</groupId>
<artifactId>bitcoinj</artifactId>
<version>0.12.3</version>
</dependency>
<!-- de.schildbach.wallet.integration.android.* -->
<dependency>
<groupId>de.schildbach.wallet</groupId>
<artifactId>integration-android</artifactId>
<version>1.0</version>
</dependency>
<!-- com.google.zxing.* -->
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>2.2</version>
</dependency>
<!-- org.slf4j.* -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<!-- ch.qos.logback.classic.* -->
<dependency>
<groupId>com.github.tony19</groupId>
<artifactId>logback-android-classic</artifactId>
<version>1.0.10-2</version>
</dependency>
<!-- ch.qos.logback.core.* -->
<dependency>
<groupId>com.github.tony19</groupId>
<artifactId>logback-android-core</artifactId>
<version>1.0.10-2</version>
</dependency>
<!-- javax.annotation.* -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>2.0.1</version>
</dependency>
<!-- org.junit.* -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<release>true</release>
<proguard>
<skip>false</skip>
</proguard>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<!-- to build, run: mvn clean install -->
<!-- then to install on an android device, run: mvn android:deploy -->
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.8.2</version>
<configuration>
<excludeJarResources>
<excludeJarResource>.*\.jar$</excludeJarResource>
</excludeJarResources>
<sdk>
<platform>14</platform>
</sdk>
<sign>
<debug>both</debug>
</sign>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>false</downloadJavadocs>
<additionalProjectnatures>
<projectnature>com.android.ide.eclipse.adt.AndroidNature</projectnature>
</additionalProjectnatures>
<additionalBuildcommands>
<buildcommand>com.android.ide.eclipse.adt.ResourceManagerBuilder</buildcommand>
<buildcommand>com.android.ide.eclipse.adt.PreCompilerBuilder</buildcommand>
<buildcommand>com.android.ide.eclipse.adt.ApkBuilder</buildcommand>
</additionalBuildcommands>
<classpathContainers>
<classpathContainer>com.android.ide.eclipse.adt.ANDROID_FRAMEWORK</classpathContainer>
<!-- This is a workaround: we do not want JRE_CONTAINER, however if we remove it, it will be automatically added, and
placed first. So we add it in the second position, so that the project is recognized as an Android project. -->
<classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
</classpathContainers>
<excludes>
<exclude>android:android</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<!-- to generate reports, run: mvn clean install site -->
<!-- then browse to: target/site/index.html -->
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<onlyAnalyze>de.schildbach.wallet.-</onlyAnalyze>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
谢谢你的帮助。