Bitcoin Forum
May 09, 2024, 05:31:09 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Building bitcoinj for Android  (Read 5688 times)
bitcoinsecurityproject (OP)
Newbie
*
Offline Offline

Activity: 22
Merit: 4


View Profile WWW
January 27, 2014, 04:03:48 PM
 #1

Hey all,

I'm trying to build bitcoinj for use with an Android App using Maven.

For starters, I have built the latest version (commit 4ca476ff353913b33034ff5e5a1f0c4d734d8c64)

I have a generated bitcoinj-0.11-SNAPSHOT.jar file and am importing it into my Android App Lib.

When I try to use the library, I am getting a "java.lang.NoClassDefFoundError: org.bitcoinj.wallet.Protos$Wallet" error. There is a similar discussion here: http://code.google.com/p/bitcoinj/issues/detail?id=133 but I did not understand the solution and am not sure if it would work for me.

When I look inside the generated JAR, the class is in there but am still getting the NoClassDefFoundError. Any help is appreciated.

Thanks!

1715232669
Hero Member
*
Offline Offline

Posts: 1715232669

View Profile Personal Message (Offline)

Ignore
1715232669
Reply with quote  #2

1715232669
Report to moderator
1715232669
Hero Member
*
Offline Offline

Posts: 1715232669

View Profile Personal Message (Offline)

Ignore
1715232669
Reply with quote  #2

1715232669
Report to moderator
In order to get the maximum amount of activity points possible, you just need to post once per day on average. Skipping days is OK as long as you maintain the average.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715232669
Hero Member
*
Offline Offline

Posts: 1715232669

View Profile Personal Message (Offline)

Ignore
1715232669
Reply with quote  #2

1715232669
Report to moderator
Mike Hearn
Moderator
Legendary
*
Offline Offline

Activity: 1526
Merit: 1129


View Profile
January 27, 2014, 04:27:58 PM
 #2

Is your Android app using Maven/Gradle as well? It sounds like the library can't find its dependencies, which can happen if you aren't using something like Maven/Gradle for your own build.
bitcoinsecurityproject (OP)
Newbie
*
Offline Offline

Activity: 22
Merit: 4


View Profile WWW
January 27, 2014, 04:37:31 PM
 #3

No my app is not using Maven. I'm just building it using Eclipse IDE. You'd think it would be fine because I'm not having any issues with any of my other libraries that I'm importing.

Mike Hearn
Moderator
Legendary
*
Offline Offline

Activity: 1526
Merit: 1129


View Profile
January 27, 2014, 08:36:50 PM
 #4

These days you really need to be using a proper build system that understands dependency resolution. BitcoinJ is a large codebase these days, and it depends on other libraries to work.

Try Android Studio. It's the future Android IDE and it uses Gradle, which knows how to depend on Maven targets (there are docs on how to use Maven on the bitcoinj website). Then it will go download protobufs, guava, all the other stuff bitcoinj needs.
bitcoinsecurityproject (OP)
Newbie
*
Offline Offline

Activity: 22
Merit: 4


View Profile WWW
January 27, 2014, 09:56:08 PM
 #5

I'll give it a shot with Android Studio. If I manage to get it working I'll make a little how-to doc as well. Thanks!
varunsin
Sr. Member
****
Offline Offline

Activity: 376
Merit: 250


View Profile
May 15, 2014, 06:11:41 PM
 #6

any updates on your way with Android Studio??
RedStratocaster
Newbie
*
Offline Offline

Activity: 6
Merit: 0


View Profile
May 06, 2016, 10:09:31 PM
 #7

Hi there, I know this is super old, but I didn't search for help when I used bitcoinj on android an had several problems using Android Studio.
The error was: " Failure [INSTALL_FAILED_NO_MATCHING_ABIS] "

It depends on the Android device used (or emulated) but the problem is with the Scrypt library.

I was able to fix it by adding this exclussion at the build.gradle file of the Android project.

        exclude 'lib/x86_64/darwin/libscrypt.dylib'
        exclude 'lib/x86_64/freebsd/libscrypt.so'
        exclude 'lib/x86_64/linux/libscrypt.so'
        exclude 'org/bitcoinj/crypto/cacerts'


Then adding bitcoinj to Java modules in Android Studio works just fine.
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'org.bitcoinj:bitcoinj-core:0.13.3'
    testCompile 'junit:junit:4.12'
}

Hopes it helps someone!
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!