• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Issue installing APK, possible missing native libraries

ChrisTheGuy

Lurker
Jan 9, 2019
9
0
I am currently trying to use BitcoinJ for android.

you can check their jar and gradle builds here at https://bitcoinj.github.io/#getting-started

I added their library into my build.gradle which is...

Code:
android {
    compileSdkVersion 28
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    defaultConfig {
        applicationId "com.example.coinpayapp.coinpayapp"
        minSdkVersion 24
        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'
    implementation('me.dm7.barcodescanner:zxing:1.9') { exclude module: 'support-v4' }
    implementation 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
    implementation 'org.bitcoinj:bitcoinj-core:0.14.7'
    api 'org.slf4j:slf4j-api:1.7.25'
    implementation 'org.slf4j:slf4j-simple:1.7.12'
}

Code:
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    createNotificationChannel();
    display();
    MainPage.context = getAppContext();
    BackWork bwork = new BackWork(this);
    bwork.execute("server",null,null);
    TextView tVBTCPer = (TextView)findViewById(R.id.tVBTCPer);
    DownloadProgressTracker BTCListener = new DownloadProgressTracker() {
        @Override
        public void progress(double pct, int blocksSoFar, Date date) {
            tVBTCPer.setText((int) pct+"%");
        }
        @Override
        public void doneDownload() {
            tVBTCPer.setText("100%");
        }
    };
    BTCkit.setDownloadListener(BTCListener).setBlockingStartup(false).startAsync().awaitRunning();
}

ive posted on stackoverflow regarding this issue where you can find all the images at https://stackoverflow.com/questions/53620658/bitcoinj-library-on-android-hung-on-installing-apk

a response below was from Martin Zeitler where he said this in his comment.

"this a) exceeds the scope of the question and b) that build.gradle does not even build any native assembly... which might come from some jar in the libs directory. please accept the answer for the actual question and feel free to ask a new one question, for the new one problem. searching that error message might already provide some clue"

Could someone help explain this to me im confused on what i need and the steps.
 
That is the problem. it sits at Installing APK but never actually does it. If you would check the stackoverflow topic i posted it would show the errors i gotten from it.

the APK did not install. Ill post the pictures below to quicken this up.

I eventually get this dialog box.

https://ibb.co/dOCjuq

When i click ok i get this error.

https://ibb.co/dL7W7A

which brings you to here...

https://ibb.co/kAdtLV
 
Upvote 0
So instead of continually bumping this thread, which I doubt very much if anyone here can answer, I tried doing what was suggested way back when you asked your SO question, and that is to Google the exact error message you got. It turns up results, including another SO question which offers a lot of responses.
You might want to spend some time looking into this

https://stackoverflow.com/questions...id-os-binder-exectransactbinder-java565-error
 
Upvote 0
tried it.

disabled instant run, build > clean project . run, failed. enabled instant run, tried running it again failed.

I firmly believe that its the bitcoinj jar. Given that when i extract the jar i see the libs folder then x86_64 folder which gives me reason to think that the app is trying to install the apk using x86_64 arch type.

I am trying to remove the folder and rebuild the jar but no luck. is there a way that i can specifically omit those folders and just read my library? How is this done in gradle? Because i seen a few examples with no luck.
 
Upvote 0
got it to work somewhat. the issues is writing to the file needed to read the wallet and chain files. my sample code is this
Code:
public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        String filename = "myfile";
        String fileContents = "Hello world!";
        FileOutputStream outputStream;
        TextView tv = (TextView)findViewById(R.id.textView);
        File file = new File(this.getFilesDir(), filename);


        try {
            outputStream = openFileOutput(filename, Context.MODE_APPEND);
            outputStream.write(fileContents.getBytes());
            outputStream.close();
            tv.setText("Done: "+getDataDir(this));
        } catch (Exception e) {
            Writer writer = new StringWriter();
            e.printStackTrace(new PrintWriter(writer));
            String s = writer.toString();
            e.printStackTrace();
            tv.setText(s);
        }

    }
    public String getDataDir(final Context context) throws Exception {
        return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).applicationInfo.dataDir;
    }
}

privs in androidmanifest are
Code:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

yet im getting this error...

01-15 10:54:37.313 27411 27432 E AndroidRuntime: FATAL EXCEPTION: WalletAppKit STARTING
01-15 10:54:37.313 27411 27432 E AndroidRuntime: Process: com.example.coinpayapp.coinpayapp, PID: 27411
01-15 10:54:37.313 27411 27432 E AndroidRuntime: java.lang.RuntimeException: java.io.IOException: Read-only file system
01-15 10:54:37.313 27411 27432 E AndroidRuntime: at com.google.common.base.Throwables.propagate(Throwables.java:160)
01-15 10:54:37.313 27411 27432 E AndroidRuntime: at com.google.common.util.concurrent.AbstractIdleService$2$1.run(AbstractIdleService.java:58)
01-15 10:54:37.313 27411 27432 E AndroidRuntime: at com.google.common.util.concurrent.Callables$3.run(Callables.java:95)
01-15 10:54:37.313 27411 27432 E AndroidRuntime: at java.lang.Thread.run(Thread.java:764)
01-15 10:54:37.313 27411 27432 E AndroidRuntime: Caused by: java.io.IOException: Read-only file system
01-15 10:54:37.313 27411 27432 E AndroidRuntime: at java.io.UnixFileSystem.createFileExclusively0(Native Method)
01-15 10:54:37.313 27411 27432 E AndroidRuntime: at java.io.UnixFileSystem.createFileExclusively(UnixFileSystem.java:281)
01-15 10:54:37.313 27411 27432 E AndroidRuntime: at java.io.File.createTempFile(File.java:2001)
01-15 10:54:37.313 27411 27432 E AndroidRuntime: at org.bitcoinj.wallet.Wallet.saveToFile(Wallet.java:1333)
01-15 10:54:37.313 27411 27432 E AndroidRuntime: at org.bitcoinj.kits.WalletAppKit.createOrLoadWallet(WalletAppKit.java:375)
01-15 10:54:37.313 27411 27432 E AndroidRuntime: at org.bitcoinj.kits.WalletAppKit.startUp(WalletAppKit.java:273)
01-15 10:54:37.313 27411 27432 E AndroidRuntime: at com.google.common.util.concurrent.AbstractIdleService$2$1.run(AbstractIdleService.java:54)
01-15 10:54:37.313 27411 27432 E AndroidRuntime: ... 2 more
01-15 10:54:37.317 27411 27411 E AndroidRuntime: FATAL EXCEPTION: main
01-15 10:54:37.317 27411 27411 E AndroidRuntime: Process: com.example.coinpayapp.coinpayapp, PID: 27411
01-15 10:54:37.317 27411 27411 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.coinpayapp.coinpayapp/com.example.coinpayapp.coinpayapp.MainPage}: java.lang.IllegalStateException: Expected the service to be RUNNING, but the service has FAILED
01-15 10:54:37.317 27411 27411 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
01-15 10:54:37.317 27411 27411 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
01-15 10:54:37.317 27411 27411 E AndroidRuntime: at android.app.ActivityThread.-wrap11(Unknown Source:0)
01-15 10:54:37.317 27411 27411 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
01-15 10:54:37.317 27411 27411 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
01-15 10:54:37.317 27411 27411 E AndroidRuntime: at android.os.Looper.loop(Looper.java:164)
01-15 10:54:37.317 27411 27411 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6494)
01-15 10:54:37.317 27411 27411 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
01-15 10:54:37.317 27411 27411 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
01-15 10:54:37.317 27411 27411 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
01-15 10:54:37.317 27411 27411 E AndroidRuntime: Caused by: java.lang.IllegalStateException: Expected the service to be RUNNING, but the service has FAILED
01-15 10:54:37.317 27411 27411 E AndroidRuntime: at com.google.common.util.concurrent.AbstractService.checkCurrentState(AbstractService.java:285)
01-15 10:54:37.317 27411 27411 E AndroidRuntime: at com.google.common.util.concurrent.AbstractService.awaitRunning(AbstractService.java:229)
01-15 10:54:37.317 27411 27411 E AndroidRuntime: at com.google.common.util.concurrent.AbstractIdleService.awaitRunning(AbstractIdleService.java:151)
01-15 10:54:37.317 27411 27411 E AndroidRuntime: at com.example.coinpayapp.coinpayapp.MainPage.onCreate(MainPage.java:92)
01-15 10:54:37.317 27411 27411 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:7009)
01-15 10:54:37.317 27411 27411 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:7000)
01-15 10:54:37.317 27411 27411 E AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
01-15 10:54:37.317 27411 27411 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
01-15 10:54:37.317 27411 27411 E AndroidRuntime: ... 9 more
01-15 10:54:37.317 27411 27411 E AndroidRuntime: Caused by: java.io.IOException: Read-only file system
01-15 10:54:37.317 27411 27411 E AndroidRuntime: at java.io.UnixFileSystem.createFileExclusively0(Native Method)
01-15 10:54:37.317 27411 27411 E AndroidRuntime: at java.io.UnixFileSystem.createFileExclusively(UnixFileSystem.java:281)
01-15 10:54:37.317 27411 27411 E AndroidRuntime: at java.io.File.createTempFile(File.java:2001)
01-15 10:54:37.317 27411 27411 E AndroidRuntime: at org.bitcoinj.wallet.Wallet.saveToFile(Wallet.java:1333)
01-15 10:54:37.317 27411 27411 E AndroidRuntime: at org.bitcoinj.kits.WalletAppKit.createOrLoadWallet(WalletAppKit.java:375)
01-15 10:54:37.317 27411 27411 E AndroidRuntime: at org.bitcoinj.kits.WalletAppKit.startUp(WalletAppKit.java:273)
01-15 10:54:37.317 27411 27411 E AndroidRuntime: at com.google.common.util.concurrent.AbstractIdleService$2$1.run(AbstractIdleService.java:54)
01-15 10:54:37.317 27411 27411 E AndroidRuntime: at com.google.common.util.concurrent.Callables$3.run(Callables.java:95)
01-15 10:54:37.317 27411 27411 E AndroidRuntime: at java.lang.Thread.run(Thread.java:764)
 
Upvote 0
the blockchain is attempting to sync but it cant because the files it needs (filename.wallet and filename.spvchain) cant be created because a lack of permissions. But in my android manifest has the user permission for write external.

I was able to have it up and running and works but only because i had to use the same library to create the files on my desktop computer then copy those files over to my device. ITs the only workaround i got right now because for whatever reason...

WalletAppKit BTCkit = new WalletAppKit(BTCparams, new File(Environment.getExternalStorageDirectory().getAbsolutePath()), "BTC-Test");

the new File() is failing to create it citing permission issues..
 
Upvote 0
the blockchain is attempting to sync but it cant because the files it needs (filename.wallet and filename.spvchain) cant be created because a lack of permissions. But in my android manifest has the user permission for write external.

I was able to have it up and running and works but only because i had to use the same library to create the files on my desktop computer then copy those files over to my device. ITs the only workaround i got right now because for whatever reason...

WalletAppKit BTCkit = new WalletAppKit(BTCparams, new File(Environment.getExternalStorageDirectory().getAbsolutePath()), "BTC-Test");

the new File() is failing to create it citing permission issues..

The problem is that as of android 6.0+ you need to have the write permissions in the manifest, but also need to request permissions at runtime.

Here is a sample of how I do it. Make sure that if you're gonna run it from your onCreate() method that you run it on a background thread so that you do not slow your UI loading...

Java:
if (Build.VERSION.SDK_INT >= 23) {
    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
    }
}

The user will get a one-time dialog asking for storage permission with the above.
 
Upvote 0
Correct GT. Specific code needs to be written in the app, to confirm the permission at run time. That's in addition to having the permission request in the Manifest.

Yeah I explained that in a previous post with a sample I use, but he said he verified that which I'm not clear if he means that he already did that (both manifest & run time).
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones