Hello everyone! I am relatively new to programming and am trying to teach myself how to build a simple android app. I am building my app using eclipse Kepler, and one of the the last things I need to do is to allow my app to spend bitcoins. The first thing I did was turn my android application project into a maven android application project so I could use more resources. (Am i saying this right? I just needed to be able to import bitcoinj so i downloaded maven and maven 2 eclipse, then added some dependencies)
First, I read that I can integrate my app with an existing wallet, such as coinbases or the schildbach bitcoin-wallet (
https://github.com/schildbach/bitcoin-wallet) so I can spend bitcoin out of this wallet by pressing a button in my app, but I cannot figure out how to do this. I tried to follow the sample-android-integration project for the schildbach wallet:
My best guess is to include the following in my pom.xml file, which based on my knowledge should work:
<parent>
<groupId>de.schildbach.wallet</groupId>
<artifactId>base</artifactId>
<version>1</version>
</parent>
<dependency>
<groupId>de.schildbach.wallet</groupId>
<artifactId>integration-android</artifactId>
<version>2.0</version>
</dependency>
When I put the <parent> in my pom.xml file, i get the error "Non-resolvable parent POM". Do I even need this?
When i put the dependency in my pom.xml file I get plenty of errors, such as failed to read artifact descriptor, failed to transfer de.schildbach-wallet:integration... , and 26 missing artifact errors. I am getting "Missing artifact:com.google:bitcoinj:jar:0.11.1" Even though under my project in the maven dependencies section i see bitcoin-0.11.1.jar.
Does anyone have any idea what I am doing wrong here?The way I understand it, if I am "depending" on this artifact, I should be able to use the methods in it as part of my project. How far off from the truth am I? Am i doing anything right?
So, after failing at this for a while, I decided I would try to make my own simple wallet using bitcoinj. I just want to create a wallet I can load with a few $ of bitcoin and be able to send the coins to a specified address.
I have been able to create addresses and a wallet, but I need to save the wallet. However when I run the method wallet.saveToFile(File f) I get the following errors:
log4j:WARN No appenders could be found for logger (com.google.bitcoin.core.Wallet).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See
http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" java.lang.NoSuchMethodError: org.bitcoinj.wallet.Protos$Key$Builder.setPrivateKey(Lcom/google/protobuf/ByteString;)Lorg/bitcoinj/wallet/Protos$Key$Builder;
at com.google.bitcoin.store.WalletProtobufSerializer.walletToProto(WalletProtobufSerializer.java:131)
at com.google.bitcoin.store.WalletProtobufSerializer.writeWallet(WalletProtobufSerializer.java:94)
at com.google.bitcoin.core.Wallet.saveToFileStream(Wallet.java:468)
at com.google.bitcoin.core.Wallet.saveToFile(Wallet.java:303)
at com.google.bitcoin.core.Wallet.saveToFile(Wallet.java:342)
at Main.main(Main.java:55)
Under maven dependencies I have log4j-1.2.16.jar and slf4j-log4j12-1.6.4.jar. Besides setting up slf4j as a dependency, what else do i need to do to "iniatilize the log4j system properly".
And my final question, will this be a recurring theme? Will different objects/methods I use from bitcoinj require me to set up ever more dependencies and jars?
If anyone has any suggestions, can answer any questions, or can point me to some material i should read, I would be very grateful!!!!