*Issue: *I have two classes MainActivity and BitcoinConfig (see below). Can 
someone please help me fix issues I'm having syncing the blockchain?

The AndroidManifest.xml and Build.gradle files are also below.

*Errors: * I’ve attached the full logcat with the getCause info because it 
was hard to read on this but one of the errors is:



*W/System.err: java.lang.IllegalStateException: Expected the service 
[FAILED] to be RUNNING, but the service has FAILED (line 50 
kit.awaitSync()) *Thanks (sorry if this is obvious)!

MAIN ACTIVITY

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

   private BitcoinConfig btcService;

   @Override

   protected void onCreate(Bundle savedInstanceState) {

       super.onCreate(savedInstanceState);

       setContentView(R.layout.activity_main);

       btcService = new BitcoinConfig();

       btcService.settingUp();

   }

}

import android.util.Log;

import org.bitcoinj.core.ECKey;

import org.bitcoinj.core.NetworkParameters;

import org.bitcoinj.core.listeners.DownloadProgressTracker;

import org.bitcoinj.kits.WalletAppKit;

import org.bitcoinj.params.RegTestParams;

import org.bitcoinj.params.TestNet3Params;

import org.bitcoinj.utils.BriefLogFormatter;

import java.io.File;

import java.util.Date;

public class BitcoinConfig {

   private NetworkParameters params;

   private WalletAppKit kit;

   private File walletPath;

   private static final String TAG = BitcoinConfig.class.getSimpleName();

   public BitcoinConfig() {

   }

   public void settingUp() {

       params = TestNet3Params.get();

       Log.d(TAG, "getting network");

       BriefLogFormatter.init();

       Log.d(TAG, "creating wallet");

       kit = new WalletAppKit(params, new File("/home/annab"), "UserWallet") 
{

           @Override

           protected void onSetupCompleted() {

               if (wallet().getImportedKeys().size() < 1)

                   wallet().importKey(new ECKey());

               Log.d(TAG, "in on set up");

           }

       };

       if (params == RegTestParams.get()) {

           kit.connectToLocalHost();

           Log.d(TAG, "in connect to regtestnet");

       }

       kit.setBlockingStartup(false);

       Log.d(TAG, "setBlockingStartup(false)");

       try {

           kit.startAsync();

           Log.d(TAG, "startAsync()");

       } catch(Throwable t){

           Log.d(TAG, "startAsync error"); // never goes here

           t.getCause();

       }

       try {

           kit.awaitRunning(); // error: java.lang.IllegalStateException: 
Expected the service  [FAILED] to be RUNNING, but the service has FAILED

           Log.d(TAG, "awaitRunning()");

       } catch (Throwable t) {

           System.out.println("awaitingRunning exception");  // goes here

           t.getCause();

       }

   }

}



build.gradle(:module)

// Top-level build file where you can add configuration options common to 
all sub-projects/modules.

buildscript {

   repositories {

       google()

       mavenCentral()

   }

   dependencies {

       classpath "com.android.tools.build:gradle:4.2.0"

   }

}

allprojects {

   repositories {

       google()

       mavenCentral()

       jcenter() // Warning: this repository is going to shut down soon

   }

}

task clean(type: Delete) {

   delete rootProject.buildDir

}


build.gradle(:app)

plugins {

   id 'com.android.application'

}

android {

   compileSdkVersion 31

   buildToolsVersion "31.0.0"

   defaultConfig {

       applicationId "com.example.walletexample"

       minSdkVersion 23

       targetSdkVersion 31

       versionCode 1

       versionName "1.0"

       testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

   }

   buildTypes {

       release {

           minifyEnabled true

           proguardFiles getDefaultProguardFile(
'proguard-android-optimize.txt'), 'proguard-rules.pro'

       }

   }

   compileOptions {

       sourceCompatibility JavaVersion.VERSION_1_8

       targetCompatibility JavaVersion.VERSION_1_8

   }

}

dependencies {

   // already here

   implementation 'androidx.appcompat:appcompat:1.3.1'

   implementation 'com.google.android.material:material:1.4.0'

   implementation 'androidx.constraintlayout:constraintlayout:2.1.1'

   androidTestImplementation 'androidx.test.ext:junit:1.1.3'

   androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

   implementation "androidx.annotation:annotation:1.2.0"

   // BitcoinJ SDK

   implementation 'org.bitcoinj:bitcoinj-core:0.15.10'

   // logging

   implementation 'org.slf4j:slf4j-api:1.7.12'

   implementation 'org.slf4j:slf4j-simple:1.7.12'

   implementation 'com.google.guava:guava:29.0-android'

   testImplementation 'junit:junit:4.13.2'

}


AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android";

         package="com.example.walletexample">

   <uses-permission android:name="android.permission.INTERNET"/>

   <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
/>

   <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
/>

   <application

           android:allowBackup="true"

           android:icon="@mipmap/ic_launcher"

           android:label="@string/app_name"

           android:roundIcon="@mipmap/ic_launcher_round"

           android:supportsRtl="true"

           android:exported ="true"

           android:theme="@style/Theme.WalletExample">

       <activity android:name=".MainActivity">

           <intent-filter>

               <action android:name="android.intent.action.MAIN"/>

               <category android:name="android.intent.category.LAUNCHER"/>

           </intent-filter>

       </activity>

   </application>

</manifest>

-- 
You received this message because you are subscribed to the Google Groups 
"bitcoinj" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bitcoinj/ae413a3e-9b62-49d2-81d9-ad117118e5d2n%40googlegroups.com.
10/30 14:02:39: Launching 'MainActivity' on samsung SM-G9730.
Install successfully finished in 192 ms.
$ adb shell am start -n 
"com.example.walletexample/com.example.walletexample.MainActivity" -a 
android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 15603 on device 'samsung-sm_g9730-R28M50DX0ML'.
Capturing and displaying logcat messages from application. This behavior can be 
disabled in the "Logcat output" section of the "Debugger" settings page.
W/e.walletexampl: Accessing hidden method 
Landroid/app/ResourcesManager;->getConfiguration()Landroid/content/res/Configuration;
 (greylist-max-o, linking, denied)
    Accessing hidden method 
Landroid/app/ResourcesManager;->getDisplayMetrics()Landroid/util/DisplayMetrics;
 (greylist-max-o, linking, denied)
    Accessing hidden method Landroid/app/ActivityThread;->isInDexDisplay()Z 
(blacklist, linking, denied)
    Accessing hidden method 
Landroid/app/ResourcesManager;->getDisplayMetrics(ILandroid/view/DisplayAdjustments;)Landroid/util/DisplayMetrics;
 (greylist-max-o, linking, denied)
    Accessing hidden method 
Landroid/app/ResourcesManager;->getAdjustedDisplay(ILandroid/view/DisplayAdjustments;)Landroid/view/Display;
 (greylist-max-o, linking, denied)
    Accessing hidden method 
Landroid/app/ResourcesManager;->getResources(Landroid/os/IBinder;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/String;ILandroid/content/res/Configuration;Landroid/content/res/CompatibilityInfo;Ljava/lang/ClassLoader;Ljava/util/List;)Landroid/content/res/Resources;
 (blacklist, linking, denied)
    Accessing hidden method 
Landroid/app/ResourcesManager;->getResources(Landroid/os/IBinder;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/String;ILandroid/content/res/Configuration;Landroid/content/res/CompatibilityInfo;Ljava/lang/ClassLoader;Ljava/util/List;Ljava/lang/String;)Landroid/content/res/Resources;
 (blacklist, linking, denied)
W/e.walletexampl: Accessing hidden method 
Landroid/app/ResourcesManager;->getResources(Landroid/os/IBinder;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/String;ILandroid/content/res/Configuration;Landroid/content/res/CompatibilityInfo;Ljava/lang/ClassLoader;Ljava/util/List;Ljava/lang/String;)Landroid/content/res/Resources;
 (blacklist, linking, denied)
    Accessing hidden method 
Landroid/app/ResourcesManager;->rebaseKeyForActivity(Landroid/os/IBinder;Landroid/content/res/ResourcesKey;)V
 (blacklist, linking, denied)
    Accessing hidden method 
Landroid/app/ResourcesManager;->createResources(Landroid/os/IBinder;Landroid/content/res/ResourcesKey;Ljava/lang/ClassLoader;)Landroid/content/res/Resources;
 (blacklist, linking, denied)
    Accessing hidden method 
Landroid/app/ResourcesManager;->rebaseKeyForActivity(Landroid/os/IBinder;Landroid/content/res/ResourcesKey;)V
 (blacklist, linking, denied)
    Accessing hidden method 
Landroid/app/ResourcesManager;->createResources(Landroid/os/IBinder;Landroid/content/res/ResourcesKey;Ljava/lang/ClassLoader;)Landroid/content/res/Resources;
 (blacklist, linking, denied)
    Accessing hidden method 
Landroid/app/ResourcesManager;->invalidatePath(Ljava/lang/String;)V 
(greylist-max-o, linking, denied)
    Accessing hidden method 
Landroid/content/res/ResourcesKey;->isPathReferenced(Ljava/lang/String;)Z 
(greylist-max-o, linking, denied)
    Accessing hidden field 
Landroid/app/ResourcesManager;->mCachedApkAssets:Landroid/util/ArrayMap; 
(greylist-max-o, linking, denied)
W/e.walletexampl: Accessing hidden field 
Landroid/app/ResourcesManager;->mCachedApkAssets:Landroid/util/ArrayMap; 
(greylist-max-o, linking, denied)
    Accessing hidden field 
Landroid/app/ResourcesManager$ApkKey;->path:Ljava/lang/String; (greylist-max-o, 
linking, denied)
    Accessing hidden field 
Landroid/app/ResourcesManager;->mCachedApkAssets:Landroid/util/ArrayMap; 
(greylist-max-o, linking, denied)
    Accessing hidden method Landroid/content/res/ApkAssets;->close()V 
(blacklist, linking, denied)
    Accessing hidden field 
Landroid/app/ResourcesManager;->mCachedApkAssets:Landroid/util/ArrayMap; 
(greylist-max-o, linking, denied)
    Accessing hidden field 
Landroid/app/ResourcesManager$ApkKey;->path:Ljava/lang/String; (greylist-max-o, 
linking, denied)
    Accessing hidden field 
Landroid/app/ResourcesManager;->mCachedApkAssets:Landroid/util/ArrayMap; 
(greylist-max-o, linking, denied)
    Accessing hidden method Landroid/content/res/ApkAssets;->close()V 
(blacklist, linking, denied)
    Accessing hidden method 
Landroid/app/ResourcesManager;->isSameResourcesOverrideConfig(Landroid/os/IBinder;Landroid/content/res/Configuration;)Z
 (greylist-max-o, linking, denied)
W/e.walletexampl: Accessing hidden field 
Landroid/app/ResourcesManager$ActivityResources;->overrideConfig:Landroid/content/res/Configuration;
 (greylist-max-o, linking, denied)
    Accessing hidden field 
Landroid/app/ResourcesManager$ActivityResources;->overrideConfig:Landroid/content/res/Configuration;
 (greylist-max-o, linking, denied)
    Accessing hidden field 
Landroid/app/ResourcesManager$ActivityResources;->overrideConfig:Landroid/content/res/Configuration;
 (greylist-max-o, linking, denied)
    Accessing hidden method 
Landroid/content/res/Configuration;->diffPublicOnly(Landroid/content/res/Configuration;)I
 (greylist-max-o, linking, denied)
    Accessing hidden method 
Landroid/app/ResourcesManager;->leaveLogCurrentState()V (blacklist, linking, 
denied)
    Accessing hidden method 
Landroid/app/ResourcesManager;->getResourcesHashList()Ljava/lang/String; 
(blacklist, linking, denied)
    Accessing hidden method 
Landroid/app/ResourcesManager;->overrideTokenDisplayAdjustments(Landroid/os/IBinder;Ljava/util/function/Consumer;)Z
 (blacklist, linking, denied)
    Accessing hidden field 
Landroid/app/ResourcesManager$ActivityResources;->activityResources:Ljava/util/ArrayList;
 (greylist-max-o, linking, denied)
W/e.walletexampl: Accessing hidden method 
Landroid/content/res/Resources;->overrideDisplayAdjustments(Ljava/util/function/Consumer;)V
 (blacklist, linking, denied)
    Accessing hidden method 
Landroid/app/ResourcesManager;->setDisplayPolicyResources(Landroid/content/res/Resources;I)V
 (blacklist, linking, denied)
    Accessing hidden field 
Landroid/app/ResourcesManager;->mSavedLogs:Landroid/app/ResourcesManager$EvictingArrayQueue;
 (blacklist, linking, denied)
    Accessing hidden field 
Landroid/app/ResourcesManager;->mFormatter:Ljava/time/format/DateTimeFormatter; 
(blacklist, linking, denied)
    Accessing hidden method 
Landroid/app/ResourcesManager$EvictingArrayQueue;-><init>(Landroid/app/ResourcesManager;I)V
 (blacklist, linking, denied)
    Accessing hidden field Landroid/app/ResourcesManager;->mDPResHash:I 
(blacklist, linking, denied)
    Accessing hidden field Landroid/app/ResourcesManager;->mDPImplHash:I 
(blacklist, linking, denied)
    Accessing hidden method 
Landroid/app/ResourcesManager;->save(Ljava/lang/String;)V (blacklist, linking, 
denied)
    Accessing hidden method 
Landroid/app/ResourcesManager;->updateResourcesForActivity(Landroid/os/IBinder;Landroid/content/res/Configuration;IZ)V
 (greylist-max-o, linking, denied)
    Accessing hidden method 
Landroid/app/ResourcesManager;->getOrCreateActivityResourcesStructLocked(Landroid/os/IBinder;)Landroid/app/ResourcesManager$ActivityResources;
 (greylist-max-o, linking, denied)
W/e.walletexampl: Redefining intrinsic method java.lang.Thread 
java.lang.Thread.currentThread(). This may cause the unexpected use of the 
original definition of java.lang.Thread java.lang.Thread.currentThread()in 
methods that have already been compiled.
    Redefining intrinsic method boolean java.lang.Thread.interrupted(). This 
may cause the unexpected use of the original definition of boolean 
java.lang.Thread.interrupted()in methods that have already been compiled.
I/studio.deploy: Finished instrumenting
D/ActivityThread: handleBindApplication()++ app=com.example.walletexample
D/LoadedApk: LoadedApk::makeApplication() 
appContext=android.app.ContextImpl@a359449 
appContext.mOpPackageName=com.example.walletexample 
appContext.mBasePackageName=com.example.walletexample 
appContext.mPackageInfo=android.app.LoadedApk@574914e
D/NetworkSecurityConfig: No Network Security Config specified, using platform 
default
D/NetworkSecurityConfig: No Network Security Config specified, using platform 
default
D/ActivityThread: handleBindApplication() -- skipGraphicsSupport=false
I/AdrenoGLES-0: QUALCOMM build                   : 4e552d6, I7befcd4846
    Build Date                       : 04/04/21
    OpenGL ES Shader Compiler Version: EV031.32.02.02
    Local Branch                     : 
    Remote Branch                    : 
refs/tags/AU_LINUX_ANDROID_LA.UM.9.1.R1.11.00.00.604.073
    Remote Branch                    : NONE
    Reconstruct Branch               : NOTHING
    Build Config                     : S P 10.0.7 AArch64
    Driver Path                      : /vendor/lib64/egl/libGLESv2_adreno.so
I/AdrenoGLES-0: PFP: 0x016ee190, ME: 0x00000000
I/DecorView: [INFO] isPopOver=false, config=true
I/DecorView: updateCaptionType >> DecorView@76c355f[], isFloating=false, 
isApplication=true, hasWindowDecorCaption=false, 
hasWindowControllerCallback=true
D/DecorView: setCaptionType = 0, this = DecorView@76c355f[]
W/e.walletexampl: Accessing hidden method 
Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z
 (greylist, reflection, allowed)
W/e.walletexampl: Accessing hidden method 
Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, 
reflection, allowed)
W/System.err: [main] INFO org.bitcoinj.crypto.LinuxSecureRandom - Secure 
randomness will be read from /dev/urandom only.
D/BitcoinConfig: getting network
D/BitcoinConfig: creating wallet
W/System.err: [main] INFO org.bitcoinj.core.Context - Creating bitcoinj 0.15.10 
context.
D/BitcoinConfig: setBlockingStartup(false)
D/BitcoinConfig: startAsync()
W/System.err: java.lang.IllegalStateException: Expected the service  [FAILED] 
to be RUNNING, but the service has FAILED
W/System.err:     at 
com.google.common.util.concurrent.AbstractService.checkCurrentState(AbstractService.java:366)
        at 
com.google.common.util.concurrent.AbstractService.awaitRunning(AbstractService.java:302)
        at 
com.google.common.util.concurrent.AbstractIdleService.awaitRunning(AbstractIdleService.java:163)
        at 
com.example.walletexample.BitcoinConfig.settingUp(BitcoinConfig.java:50)
        at com.example.walletexample.MainActivity.onCreate(MainActivity.java:16)
        at android.app.Activity.performCreate(Activity.java:8207)
        at android.app.Activity.performCreate(Activity.java:8191)
        at 
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
        at 
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3800)
W/System.err:     at 
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4003)
        at 
android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
        at 
android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at 
android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2317)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:246)
        at android.app.ActivityThread.main(ActivityThread.java:8595)
        at java.lang.reflect.Method.invoke(Native Method)
W/System.err:     at 
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
    Caused by: java.io.IOException: Could not create directory /home/annab
        at org.bitcoinj.kits.WalletAppKit.startUp(WalletAppKit.java:292)
        at 
com.google.common.util.concurrent.AbstractIdleService$DelegateService$1.run(AbstractIdleService.java:60)
        at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
        at java.lang.Thread.run(Thread.java:923)
D/InputTransport: Input channel constructed: 'bf476b5', fd=79
I/ViewRootImpl@3c1062f[MainActivity]: setView = 
com.android.internal.policy.DecorView@76c355f TM=true
I/ViewRootImpl@3c1062f[MainActivity]: stopped(true) old=false
I/SurfaceControl: assignNativeObject: nativeObject = 0 
Surface(name=null)/@0x32ebee6 / android.view.SurfaceControl.readFromParcel:1117 
android.view.IWindowSession$Stub$Proxy.relayout:1810 
android.view.ViewRootImpl.relayoutWindow:9005 
android.view.ViewRootImpl.performTraversals:3360 
android.view.ViewRootImpl.doTraversal:2618 
android.view.ViewRootImpl$TraversalRunnable.run:9971 
android.view.Choreographer$CallbackRecord.run:1010 
android.view.Choreographer.doCallbacks:809 
android.view.Choreographer.doFrame:744 
android.view.Choreographer$FrameDisplayEventReceiver.run:995 
I/SurfaceControl: assignNativeObject: nativeObject = 0 
Surface(name=null)/@0x4f58c27 / android.view.SurfaceControl.readFromParcel:1117 
android.view.IWindowSession$Stub$Proxy.relayout:1820 
android.view.ViewRootImpl.relayoutWindow:9005 
android.view.ViewRootImpl.performTraversals:3360 
android.view.ViewRootImpl.doTraversal:2618 
android.view.ViewRootImpl$TraversalRunnable.run:9971 
android.view.Choreographer$CallbackRecord.run:1010 
android.view.Choreographer.doCallbacks:809 
android.view.Choreographer.doFrame:744 
android.view.Choreographer$FrameDisplayEventReceiver.run:995 
I/ViewRootImpl@3c1062f[MainActivity]: Relayout returned: old=(0,0,1080,2280) 
new=(0,0,1080,2280) req=(0,0)8 dur=17 res=0x1 s={false 0} ch=false fn=-1
W/System: A resource failed to call close. 
W/System: A resource failed to call close. 

Reply via email to