Android上的Bitcoinj库挂在安装APK [英] Bitcoinj library on android hung on installing APK

查看:108
本文介绍了Android上的Bitcoinj库挂在安装APK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获得一个基本的正在运行的应用程序,该应用程序将使用bitcoinj库来创建钱包并进行同步.很基本.我为我的桌面应用程序使用了bitcoinj库,没有任何问题.当我尝试为Android制作一个时,尝试在手机上运行它时,它挂在"...正在安装APK"上.

I am trying to get a basic running app that would use the bitcoinj library to create a wallet and sync. Very basic. I used bitcoinj library for my desktop application with no problems. When i try to make one for android it hangs on "...Installing APK" when trying to run it on my phone.

这是我的代码.

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ProgressBar;
import org.bitcoinj.core.Context;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.core.listeners.DownloadProgressTracker;
import org.bitcoinj.kits.WalletAppKit;
import org.bitcoinj.params.TestNet3Params;

import java.io.File;
import java.util.Date;

public class MainActivity extends AppCompatActivity {

    public static NetworkParameters BTCparams = TestNet3Params.get();
    public static WalletAppKit BTCkit = new WalletAppKit(BTCparams,new File("."),"BTC-Test");
    private ProgressBar BTCProgress;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        BTCProgress = findViewById(R.id.BTCProgress);
        Context.propagate(new Context(BTCparams));
        DownloadProgressTracker BTCListener = new DownloadProgressTracker() {
            @Override
            public void progress(double pct, int blocksSoFar, Date date) {
                System.out.println("Syncing..."+pct+"%");
                BTCProgress.setProgress((int) pct);
            }
            @Override
            public void doneDownload() {
                System.out.println("Sync Done.");
                BTCProgress.setProgress(100);
            }
        };
        BTCkit.setDownloadListener(BTCListener).setBlockingStartup(false).startAsync().awaitRunning();
    }
}

这是我的应用文件夹中的build.gradle.

This is my build.gradle in my app folder.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.testapp.testapp"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:design:28.0.0'
    implementation 'org.bitcoinj:bitcoinj-core:0.14.7'
    implementation 'org.slf4j:slf4j-api:1.7.12'
    implementation 'org.slf4j:slf4j-simple:1.7.12'
}

我最终得到这个对话框.

I eventually get this dialog box.

对话框

当我单击确定"时,我会收到此错误.

When i click ok i get this error.

错误

将您带到这里...

Binder.java

我很困惑,无法弄清楚为什么这不起作用.我怀疑一旦解决了这个问题,我的发展就会变得轻而易举.请提供详细信息,因为我仍在学习android开发.

I am stumped and cannot figure out why this isnt working. I suspect once i resolve this issue then my development will be a breeze. Please provide details as im still learning the android development.

推荐答案

将其更改为:

implementation "org.slf4j:slf4j-simple:1.7.25"
api "org.slf4j:slf4j-api:1.7.25"

这看起来也很奇怪:

Context.propagate(new Context(BTCparams));

因为它甚至不是NULL,但没有价值.

because it is not even NULL, but has no value.

这篇关于Android上的Bitcoinj库挂在安装APK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆